-
Notifications
You must be signed in to change notification settings - Fork 0
/
flush.py
53 lines (43 loc) · 1.09 KB
/
flush.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import time
from espresso import *
DELTA = 0.1
def main_loop():
boot_screen()
state = BrewState(
start = time.ticks_ms(),
seconds = 0.,
temperature = poll_temp(),
temp_targ = 95.,
pressure = poll_pressure(),
pres_targ = 9.,
flow = 0.,
flow_targ = 2.,
total_flow = 0.,
mass_targ = 30.,
pump_level = 0.,
heat_level = 0.
)
gamma = 1
while True:
state.temperature = gamma * poll_temp() + (1 - gamma) * state.temperature
state.pressure = gamma * poll_pressure() + (1 - gamma) * state.pressure
if not SWT_BREW.value():
# turn on heat
open_valve()
pump_on()
else:
# turn off heat
pump_off()
close_valve()
update_display(
state.temperature,
state.pressure,
state.flow,
state.temp_targ,
state.pres_targ,
state.total_flow,
state.seconds,
"FLUSH"
)
time.sleep(DELTA)
main_loop()