Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from gpiozero import LEDBoard, CompositeOutputDevice, Button
  2. from collections import OrderedDict
  3.  
  4. class StatusZero(LEDBoard):
  5. def __init__(self, *labels, **kwargs):
  6. pins = (
  7. (4, 17),
  8. (27, 22),
  9. (10, 9),
  10. )
  11. if len(labels) == 0:
  12. labels = ['one', 'two', 'three'][:len(pins)]
  13. elif len(labels) > len(pins):
  14. raise ValueError
  15. strips = OrderedDict()
  16. for index, label in enumerate(labels):
  17. green, red = pins[index]
  18. strips[label] = LEDBoard(red=red, green=green, **kwargs)
  19. super(StatusZero, self).__init__(_order=strips.keys(), **strips)
  20.  
  21.  
  22. class StatusBoard(CompositeOutputDevice):
  23. def __init__(self, *labels, **kwargs):
  24. pins = (
  25. (4, 17, 14),
  26. (27, 22, 19),
  27. (10, 9, 15),
  28. (11, 5, 26),
  29. (6, 13, 18),
  30. )
  31. if len(labels) == 0:
  32. labels = ['one', 'two', 'three', 'four', 'five'][:len(pins)]
  33. elif len(labels) > len(pins):
  34. raise ValueError
  35. strips = OrderedDict()
  36. for index, label in enumerate(labels):
  37. green, red, button = pins[index]
  38. strips[label] = CompositeOutputDevice(
  39. button=Button(button),
  40. lights=LEDBoard(
  41. red=red, green=green, _order=('red', 'green'), **kwargs
  42. ), _order=('button', 'lights'), **kwargs)
  43. super(StatusBoard, self).__init__(_order=strips.keys(), **strips)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement