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,
|
||||
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),
|
||||
}
|
||||
|
|
25
app.py
25
app.py
|
@ -149,17 +149,22 @@ 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:
|
||||
sensors.read()
|
||||
socketio.emit('sensors', (sensors.get(),))
|
||||
if periodic_counter % periodic_state_every_loop == 0:
|
||||
## peridoic refresh other data, too, like:
|
||||
# - current phase (time in this phase)
|
||||
# - actuators (consumption)
|
||||
# Issuing a full state update is easiest
|
||||
updateState()
|
||||
periodic_counter += 1
|
||||
sleep(scantime)
|
||||
# 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:
|
||||
## peridoic refresh other data, too, like:
|
||||
# - current phase (time in this phase)
|
||||
# - actuators (consumption)
|
||||
# Issuing a full state update is easiest
|
||||
updateState()
|
||||
periodic_counter += 1
|
||||
last_scan = perf_counter()
|
||||
|
||||
import threading
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue