瀏覽代碼

Gradient monitor improvement

spike_filter
Dirk Alders 3 年之前
父節點
當前提交
afedf43bdf
共有 1 個檔案被更改,包括 4 行新增3 行删除
  1. 4
    3
      dht.py

+ 4
- 3
dht.py 查看文件

@@ -90,14 +90,15 @@ class gradient_monitor(object):
90 90
         self.__last_time__ = None
91 91
 
92 92
     def process(self, value, time):
93
-        rv = True
94 93
         if self.__last_value__ is not None and self.__last_time__ is not None:
94
+            # Valid last value exists
95 95
             gradient = abs((value - self.__last_value__) / (time - self.__last_time__))
96 96
             if gradient > self.__max_gradient__:
97
-                rv = False
97
+                return False
98
+
98 99
         self.__last_value__ = value
99 100
         self.__last_time__ = time
100
-        return rv
101
+        return True
101 102
 
102 103
 
103 104
 class dht_22_monitor(object):

Loading…
取消
儲存