raspberry pi zero based drum machine
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.

sUpdate.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import FSM
  2. import utils as u
  3. import menus as m
  4. import git
  5. #====================================
  6. State = type("State", (object,), {})
  7. #====================================
  8. class State(object):
  9. def __init__(self, FSM):
  10. self.FSM = FSM
  11. def Enter(self):
  12. pass
  13. def Execute(self):
  14. pass
  15. def Exit(self):
  16. pass
  17. class Update(State):
  18. def __init__(self,FSM):
  19. super(Update, self).__init__(FSM)
  20. def Enter(self):
  21. o = self.FSM.owner
  22. o.header_text = "Update"
  23. o.pub.register("beat", self)
  24. g = git.cmd.Git("/home/pi/zpc_ct/")
  25. self.msg = g.pull()
  26. if o.keyState[16] > 0 or o.keyState[17] > 0:
  27. pass
  28. else:
  29. u.draw_header(o)
  30. o.update_display(0)
  31. super(Update, self).Enter()
  32. def Execute(self):
  33. o = self.FSM.owner
  34. m.menu1_actions(self, o)
  35. if o.keyState[16] == 1:
  36. m.draw_menu1(o)
  37. o.update_display(0)
  38. elif o.keyState[16] == 4:
  39. u.draw_header(o)
  40. self.draw_main(o)
  41. o.update_display(0)
  42. if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
  43. u.draw_header(o)
  44. self.draw_main(o)
  45. o.update_display(0)
  46. if o.keyState[16] > 0 or o.keyState[17] > 0:
  47. pass
  48. else:
  49. pass
  50. def draw_main(self, o):
  51. o.center_block(self.msg, o.h2, [0, 0, o.width, o.height], o.light_grey)
  52. def ReceiveMessage(self, message):
  53. o = self.FSM.owner
  54. u.play_seq(o, message)
  55. def Exit(self):
  56. self.FSM.owner.pub.unregister("beat", self)