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 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 + 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. self.lcd.fill(self.lcd.black)
  16. device, workflow, index = self.value
  17. self.lcd.text("Volcano Remote Control App", 0, 0, self.lcd.green)
  18. self.lcd.text("Running Workflow - Wait {}".format(workflow["steps"][index][1]), 0, 10, self.lcd.red)
  19. keys = self.lcd.buttons()
  20. if keys.once("y"):
  21. print("user abort")
  22. return 4 # heat off
  23. now = time.time()
  24. draw_graph(self.lcd, 0.0, now - self.start, self.end - self.start)
  25. if now >= self.end:
  26. print("switch, {} >= {}".format(now, self.end))
  27. return 8 # pump
  28. self.lcd.show()
  29. return -1 # stay in this state