Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gpiozero import LEDBoard, CompositeOutputDevice, Button
- from collections import OrderedDict
- class StatusZero(LEDBoard):
- def __init__(self, *labels, **kwargs):
- pins = (
- (4, 17),
- (27, 22),
- (10, 9),
- )
- if len(labels) == 0:
- labels = ['one', 'two', 'three'][:len(pins)]
- elif len(labels) > len(pins):
- raise ValueError
- strips = OrderedDict()
- for index, label in enumerate(labels):
- green, red = pins[index]
- strips[label] = LEDBoard(red=red, green=green, **kwargs)
- super(StatusZero, self).__init__(_order=strips.keys(), **strips)
- class StatusBoard(CompositeOutputDevice):
- def __init__(self, *labels, **kwargs):
- pins = (
- (4, 17, 14),
- (27, 22, 19),
- (10, 9, 15),
- (11, 5, 26),
- (6, 13, 18),
- )
- if len(labels) == 0:
- labels = ['one', 'two', 'three', 'four', 'five'][:len(pins)]
- elif len(labels) > len(pins):
- raise ValueError
- strips = OrderedDict()
- for index, label in enumerate(labels):
- green, red, button = pins[index]
- strips[label] = CompositeOutputDevice(
- button=Button(button),
- lights=LEDBoard(
- red=red, green=green, _order=('red', 'green'), **kwargs
- ), _order=('button', 'lights'), **kwargs)
- super(StatusBoard, self).__init__(_order=strips.keys(), **strips)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement