S&B Volcano vaporizer remote control with Pi Pico W
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

state_wait_time.py 1000B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. import time
  3. from state_wait_temp import draw_graph
  4. class StateWaitTime:
  5. def __init__(self, lcd):
  6. self.lcd = lcd
  7. def enter(self, val = None):
  8. self.value = val
  9. device, workflow, index = self.value
  10. self.start = time.time()
  11. self.end = self.start + int(workflow["steps"][index][1])
  12. def exit(self):
  13. return (self.value[0], self.value[1], self.value[2])
  14. async def draw(self):
  15. device, workflow, index = self.value
  16. self.lcd.text("Running Workflow - Wait {}".format(workflow["steps"][index][1]), 0, 10, self.lcd.red)
  17. keys = self.lcd.buttons()
  18. if keys.once("y"):
  19. print("user abort")
  20. return 4 # heat off
  21. now = time.time()
  22. draw_graph(self.lcd, 0.0, now - self.start, self.end - self.start)
  23. if now >= self.end:
  24. print("switch, {} >= {}".format(now, self.end))
  25. return 8 # pump
  26. return -1 # stay in this state