fix couple of problems in the smooth
This commit is contained in:
parent
f11fa59dcc
commit
ec53f98ded
13
sensors.py
13
sensors.py
|
@ -33,8 +33,8 @@ WINDOW_SIZE_S = 5
|
|||
|
||||
class Sensor():
|
||||
def __init__(self, autocorr=0.7):
|
||||
# We won't sample at more than 10Hz, so this is safe
|
||||
self.history = deque([], int(WINDOW_SIZE_S * 10))
|
||||
# FIXME: DEPENDS ON SAMPLING RATE
|
||||
self.history = deque([], int(WINDOW_SIZE_S * 2))
|
||||
|
||||
## This is just for debugging
|
||||
self.prevval = random() * 100
|
||||
|
@ -72,8 +72,13 @@ class GPIOState(Sensor):
|
|||
print(f"Could not read pin {self.pin}")
|
||||
self.value = 0
|
||||
self.time = perf_counter()
|
||||
|
||||
return self.store(self.time, self.transform(self.value))
|
||||
|
||||
# Even if we don't need to return the smoothed value, we still smooth it
|
||||
# to get the percentage of use over the period (if it will be needed)
|
||||
value = self.transform(self.value)
|
||||
self.store(self.time, value)
|
||||
|
||||
return (self.time, value)
|
||||
|
||||
class Temperature1W(Sensor):
|
||||
def __init__(self, address):
|
||||
|
|
Loading…
Reference in New Issue