Change LEDBoard.leds to return a static tuple

fixes #337
This commit is contained in:
Andrew Scheller
2016-05-28 10:42:49 +01:00
parent b581719c8c
commit 871c9268b2

View File

@@ -116,19 +116,22 @@ class LEDCollection(CompositeOutputDevice):
LEDClass(pin_or_collection, active_high, initial_value)
for name, pin_or_collection in kwargs.items()
})
leds = []
for item in self:
if isinstance(item, LEDCollection):
for subitem in item.leds:
leds.append(subitem)
else:
leds.append(item)
self._leds = tuple(leds)
@property
def leds(self):
"""
A flat iterator over all LEDs contained in this collection (and all
A flat tuple of all LEDs contained in this collection (and all
sub-collections).
"""
for item in self:
if isinstance(item, LEDCollection):
for subitem in item.leds:
yield subitem
else:
yield item
return self._leds
@property
def active_high(self):