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_select.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. import uasyncio as asyncio
  3. from workflows import workflows
  4. class StateSelect:
  5. def __init__(self, lcd):
  6. self.lcd = lcd
  7. def enter(self, val = None):
  8. self.client = val
  9. self.current = 0
  10. def exit(self):
  11. return self.client, workflows[self.current]
  12. def draw_list(self):
  13. for i, wf in enumerate(workflows):
  14. s1 = "{}".format(wf["name"])
  15. s2 = "by: {}".format(wf["author"])
  16. off = i * 25 + 30
  17. if off >= self.lcd.height:
  18. break
  19. c = self.lcd.white
  20. if self.current == i:
  21. c = self.lcd.red
  22. self.lcd.hline(0, off, self.lcd.width, self.lcd.blue)
  23. self.lcd.text(s1, 0, off + 2, c)
  24. self.lcd.text(s2, 0, off + 12, c)
  25. async def draw(self):
  26. self.lcd.text("Please select your Workflow", 0, 10, self.lcd.red)
  27. keys = self.lcd.buttons()
  28. if keys.once("y"):
  29. return 5
  30. elif keys.once("up"):
  31. if self.current > 0:
  32. self.current -= 1
  33. elif keys.once("down"):
  34. if self.current < (len(workflows) - 1):
  35. self.current += 1
  36. elif keys.once("enter"):
  37. return 1
  38. self.draw_list()
  39. return -1