S&B Volcano vaporizer remote control with Pi Pico W
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.fill(self.lcd.black)
  27. self.lcd.text("Volcano Remote Control App", 0, 0, self.lcd.green)
  28. self.lcd.text("Please select your Workflow", 0, 10, self.lcd.red)
  29. keys = self.lcd.buttons()
  30. if keys.once("y"):
  31. print("user abort")
  32. return 5 # disconnect
  33. elif keys.once("up"):
  34. if self.current > 0:
  35. self.current -= 1
  36. elif keys.once("down"):
  37. if self.current < (len(workflows) - 1):
  38. self.current += 1
  39. elif keys.once("enter"):
  40. return 3 # heater on
  41. self.draw_list()
  42. self.lcd.show()
  43. return -1 # stay in this state