fix couple of problems in the smooth
This commit is contained in:
parent
f11fa59dcc
commit
ec53f98ded
11
sensors.py
11
sensors.py
|
@ -33,8 +33,8 @@ WINDOW_SIZE_S = 5
|
||||||
|
|
||||||
class Sensor():
|
class Sensor():
|
||||||
def __init__(self, autocorr=0.7):
|
def __init__(self, autocorr=0.7):
|
||||||
# We won't sample at more than 10Hz, so this is safe
|
# FIXME: DEPENDS ON SAMPLING RATE
|
||||||
self.history = deque([], int(WINDOW_SIZE_S * 10))
|
self.history = deque([], int(WINDOW_SIZE_S * 2))
|
||||||
|
|
||||||
## This is just for debugging
|
## This is just for debugging
|
||||||
self.prevval = random() * 100
|
self.prevval = random() * 100
|
||||||
|
@ -73,7 +73,12 @@ class GPIOState(Sensor):
|
||||||
self.value = 0
|
self.value = 0
|
||||||
self.time = perf_counter()
|
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):
|
class Temperature1W(Sensor):
|
||||||
def __init__(self, address):
|
def __init__(self, address):
|
||||||
|
|
Loading…
Reference in New Issue