Merge branch 'stagger'
This commit is contained in:
commit
b4003246a8
|
@ -18,6 +18,7 @@ try:
|
||||||
except KeyError:
|
except KeyError:
|
||||||
is_mock = False
|
is_mock = False
|
||||||
|
|
||||||
|
print("controller start")
|
||||||
process = None
|
process = None
|
||||||
def start_process():
|
def start_process():
|
||||||
global process
|
global process
|
||||||
|
@ -190,6 +191,7 @@ class Controller:
|
||||||
self.target_lower = 85
|
self.target_lower = 85
|
||||||
self.target_upper = 90
|
self.target_upper = 90
|
||||||
self.feedforward_coeff = 50
|
self.feedforward_coeff = 50
|
||||||
|
self.last_toggle = 0
|
||||||
|
|
||||||
self._manual_mode = False
|
self._manual_mode = False
|
||||||
self.manual_on = False
|
self.manual_on = False
|
||||||
|
@ -208,6 +210,11 @@ class Controller:
|
||||||
self._manual_mode = on
|
self._manual_mode = on
|
||||||
send_update({"status": {"manual_mode": on}})
|
send_update({"status": {"manual_mode": on}})
|
||||||
|
|
||||||
|
def toggle_checked(self, humidifier, s):
|
||||||
|
if time.time() - self.last_toggle > 0.8:
|
||||||
|
humidifier.toggle(s)
|
||||||
|
self.last_toggle = time.time()
|
||||||
|
|
||||||
def update(self, humidifier, humidifier2, humidity):
|
def update(self, humidifier, humidifier2, humidity):
|
||||||
if self.first_sample:
|
if self.first_sample:
|
||||||
self.humidifier_history[:] = humidity
|
self.humidifier_history[:] = humidity
|
||||||
|
@ -227,20 +234,24 @@ class Controller:
|
||||||
# TODO add in support for manual control of second humidifier
|
# TODO add in support for manual control of second humidifier
|
||||||
if self.manual_mode:
|
if self.manual_mode:
|
||||||
if humidifier.off and self.manual_on:
|
if humidifier.off and self.manual_on:
|
||||||
humidifier.toggle(s)
|
self.toggle_checked(humidifier, s)
|
||||||
elif humidifier.on and not self.manual_on:
|
elif humidifier.on and not self.manual_on:
|
||||||
humidifier.toggle(s)
|
self.toggle_checked(humidifier, s)
|
||||||
|
if humidifier2.off and self.manual_on:
|
||||||
|
self.toggle_checked(humidifier2, s)
|
||||||
|
elif humidifier2.on and not self.manual_on:
|
||||||
|
self.toggle_checked(humidifier2, s)
|
||||||
else:
|
else:
|
||||||
if comp_humidity < self.target_lower:
|
if comp_humidity < self.target_lower:
|
||||||
if humidifier.off:
|
if humidifier.off:
|
||||||
humidifier.toggle(s)
|
self.toggle_checked(humidifier, s)
|
||||||
if humidifier2.off:
|
if humidifier2.off:
|
||||||
humidifier2.toggle(s)
|
self.toggle_checked(humidifier2, s)
|
||||||
elif comp_humidity > self.target_upper:
|
elif comp_humidity > self.target_upper:
|
||||||
if humidifier.on:
|
if humidifier.on:
|
||||||
humidifier.toggle(s)
|
self.toggle_checked(humidifier, s)
|
||||||
if humidifier2.on:
|
if humidifier2.on:
|
||||||
humidifier2.toggle(s)
|
self.toggle_checked(humidifier2, s)
|
||||||
|
|
||||||
humidifier = HumidifierV2(b"n")
|
humidifier = HumidifierV2(b"n")
|
||||||
humidifier2 = HumidifierV2()
|
humidifier2 = HumidifierV2()
|
||||||
|
|
Loading…
Reference in New Issue