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.

states.py 781B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. import uasyncio as asyncio
  3. from lcd import LCD
  4. from state_scan import StateScan
  5. class States:
  6. def __init__(self):
  7. self.states = []
  8. self.current = None
  9. def add(self, s):
  10. self.states.append(s)
  11. def run(self):
  12. if self.current == None:
  13. self.current = 0
  14. self.states[self.current].enter()
  15. next = asyncio.run(self.states[self.current].draw())
  16. if next >= 0:
  17. self.states[self.current].exit()
  18. self.current = next
  19. self.states[self.current].enter()
  20. if True:#__name__ == "__main__":
  21. lcd = LCD()
  22. lcd.brightness(1.0)
  23. states = States()
  24. # 0 - Scan
  25. scan = StateScan(lcd)
  26. states.add(scan)
  27. while True:
  28. states.run()