S&B Volcano vaporizer remote control with Pi Pico W
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

state_wait_time.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python3
  2. # ----------------------------------------------------------------------------
  3. # Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # See <http://www.gnu.org/licenses/>.
  16. # ----------------------------------------------------------------------------
  17. import time
  18. from state_wait_temp import draw_graph
  19. class StateWaitTime:
  20. def __init__(self, lcd):
  21. self.lcd = lcd
  22. def enter(self, val = None):
  23. self.value = val
  24. device, workflow, index = self.value
  25. self.start = time.time()
  26. self.end = self.start + int(workflow["steps"][index][1])
  27. def exit(self):
  28. return (self.value[0], self.value[1], self.value[2])
  29. async def draw(self):
  30. device, workflow, index = self.value
  31. self.lcd.text("Running Workflow - Wait {}".format(workflow["steps"][index][1]), 0, 10, self.lcd.red)
  32. keys = self.lcd.buttons()
  33. if keys.once("y"):
  34. return 4
  35. now = time.time()
  36. draw_graph(self.lcd, 0.0, now - self.start, self.end - self.start)
  37. if now >= self.end:
  38. return 8
  39. return -1