Browse Source

Gradient monitor improvement

spike_filter
Dirk Alders 3 years ago
parent
commit
afedf43bdf
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      dht.py

+ 4
- 3
dht.py View File

@@ -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…
Cancel
Save