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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_footer(o)
  41. self.draw_main(o)
  42. o.update_display(0)
  43. 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:
  44. u.draw_header(o)
  45. #self.draw_footer(o)
  46. self.draw_main(o)
  47. o.update_display(0)
  48. if o.keyState[16] > 0 or o.keyState[17] > 0:
  49. pass
  50. else:
  51. pass
  52. #o.update_display(0)
  53. def draw_main(self, o):
  54. #o.center_text(self.msg, o.h1, o.width, 25, o.light_grey)
  55. o.center_block(self.msg, o.h2, [0, 0, o.width, o.height], o.light_grey)
  56. def ReceiveMessage(self, message):
  57. o = self.FSM.owner
  58. u.play_seq(o, message)
  59. def Exit(self):
  60. self.FSM.owner.pub.unregister("beat", self)