update according to hardware changes

This commit is contained in:
Nicolò Balzarotti 2023-03-30 15:45:02 +02:00
parent a8a1f5e983
commit b3ee15ebe2
4 changed files with 19 additions and 14 deletions

View File

@ -100,7 +100,7 @@ actuators = {
'humidifier': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
wattage=25),
'heater2': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
wattage=2000),
'freezer': PIN(pin=14, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
wattage=400),
'freezer': PIN(pin=14, initial=GPIO.LOW, onstate=GPIO.HIGH, offstate=GPIO.LOW,
wattage=165),
}

7
app.py
View File

@ -149,7 +149,12 @@ def read_sensors():
scantime = 0.5
periodic_state_every_s = 5
periodic_state_every_loop = int(periodic_state_every_s/scantime)
last_scan = 0
while True:
# This should be more precise than sleep(0.5) and gives the OS the
# control to do other things
sleep(0.01)
if perf_counter() - last_scan > scantime:
sensors.read()
socketio.emit('sensors', (sensors.get(),))
if periodic_counter % periodic_state_every_loop == 0:
@ -159,7 +164,7 @@ def read_sensors():
# Issuing a full state update is easiest
updateState()
periodic_counter += 1
sleep(scantime)
last_scan = perf_counter()
import threading
if __name__ == '__main__':

View File

@ -180,7 +180,7 @@ class State():
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
actuators[controller].enable(response)
except Exception as e:
print(f"UNKNOWN BUG HERE in run_step {e}")
print(f"UNKNOWN BUG HERE in run_step {e} on controller {ctrl}")
if self.check():
if self.next() is None:
return True

View File

@ -220,7 +220,7 @@ class Sensors():
'H_ext2': AHT40('Humidity'),
'heater': GPIOState(22),
'humidifier/heater2': GPIOState(17),
'freezer': GPIOState(14),
'freezer': GPIOState(14, transform=lambda x: x),
'fan': GPIOState(27),
}