Skip to content

Commit f80276b

Browse files
committed
Make PixelStrip a subclass of _LED_Data
1 parent 3f7f031 commit f80276b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/rpi_ws281x/rpi_ws281x.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ def __setitem__(self, pos, value):
4545
# Handle if a slice of positions are passed in by setting the appropriate
4646
# LED data values to the provided values.
4747
if isinstance(pos, slice):
48-
index = 0
4948
for n in xrange(*pos.indices(self.size)):
50-
ws.ws2811_led_set(self.channel, n, value[index])
51-
index += 1
49+
ws.ws2811_led_set(self.channel, n, value)
5250
# Else assume the passed in value is a number to the position.
5351
else:
5452
return ws.ws2811_led_set(self.channel, pos, value)
5553

5654

57-
class PixelStrip(object):
55+
class PixelStrip(_LED_Data):
5856
def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False,
5957
brightness=255, channel=0, strip_type=None, gamma=None):
6058
"""Class to represent a SK6812/WS281x LED display. Num should be the
@@ -91,6 +89,9 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False,
9189

9290
# Initialize the channel in use
9391
self._channel = ws.ws2811_channel_get(self._leds, channel)
92+
93+
super(PixelStrip, self).__init__(self._channel, num)
94+
9495
ws.ws2811_channel_t_gamma_set(self._channel, gamma)
9596
ws.ws2811_channel_t_count_set(self._channel, num)
9697
ws.ws2811_channel_t_gpionum_set(self._channel, pin)

0 commit comments

Comments
 (0)