update according to hardware changes
This commit is contained in:
parent
a8a1f5e983
commit
b3ee15ebe2
|
@ -100,7 +100,7 @@ actuators = {
|
||||||
'humidifier': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
|
'humidifier': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
|
||||||
wattage=25),
|
wattage=25),
|
||||||
'heater2': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
|
'heater2': PIN(pin=17, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
|
||||||
wattage=2000),
|
wattage=400),
|
||||||
'freezer': PIN(pin=14, initial=GPIO.HIGH, onstate=GPIO.LOW, offstate=GPIO.HIGH,
|
'freezer': PIN(pin=14, initial=GPIO.LOW, onstate=GPIO.HIGH, offstate=GPIO.LOW,
|
||||||
wattage=165),
|
wattage=165),
|
||||||
}
|
}
|
||||||
|
|
25
app.py
25
app.py
|
@ -149,17 +149,22 @@ def read_sensors():
|
||||||
scantime = 0.5
|
scantime = 0.5
|
||||||
periodic_state_every_s = 5
|
periodic_state_every_s = 5
|
||||||
periodic_state_every_loop = int(periodic_state_every_s/scantime)
|
periodic_state_every_loop = int(periodic_state_every_s/scantime)
|
||||||
|
last_scan = 0
|
||||||
while True:
|
while True:
|
||||||
sensors.read()
|
# This should be more precise than sleep(0.5) and gives the OS the
|
||||||
socketio.emit('sensors', (sensors.get(),))
|
# control to do other things
|
||||||
if periodic_counter % periodic_state_every_loop == 0:
|
sleep(0.01)
|
||||||
## peridoic refresh other data, too, like:
|
if perf_counter() - last_scan > scantime:
|
||||||
# - current phase (time in this phase)
|
sensors.read()
|
||||||
# - actuators (consumption)
|
socketio.emit('sensors', (sensors.get(),))
|
||||||
# Issuing a full state update is easiest
|
if periodic_counter % periodic_state_every_loop == 0:
|
||||||
updateState()
|
## peridoic refresh other data, too, like:
|
||||||
periodic_counter += 1
|
# - current phase (time in this phase)
|
||||||
sleep(scantime)
|
# - actuators (consumption)
|
||||||
|
# Issuing a full state update is easiest
|
||||||
|
updateState()
|
||||||
|
periodic_counter += 1
|
||||||
|
last_scan = perf_counter()
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -180,7 +180,7 @@ class State():
|
||||||
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
|
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
|
||||||
actuators[controller].enable(response)
|
actuators[controller].enable(response)
|
||||||
except Exception as e:
|
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.check():
|
||||||
if self.next() is None:
|
if self.next() is None:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -220,7 +220,7 @@ class Sensors():
|
||||||
'H_ext2': AHT40('Humidity'),
|
'H_ext2': AHT40('Humidity'),
|
||||||
'heater': GPIOState(22),
|
'heater': GPIOState(22),
|
||||||
'humidifier/heater2': GPIOState(17),
|
'humidifier/heater2': GPIOState(17),
|
||||||
'freezer': GPIOState(14),
|
'freezer': GPIOState(14, transform=lambda x: x),
|
||||||
'fan': GPIOState(27),
|
'fan': GPIOState(27),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue