Skip to content

Commit b65c8c1

Browse files
authored
Fix setting a pixels slice
When setting the pixels with a slice, set the correct pixel to a value provided (not to the index). This was discovered using `adafruit_led_animation.animation.rainbow` ```py from adafruit_led_animation.animation.rainbow import Rainbow rainbow = Rainbow(macropad.pixels, speed=.1, period=2) while True: rainbow.animate() ``` And tested with this (with all values of rotation) ```py from adafruit_macropad import MacroPad import time macropad = MacroPad(rotation=0) macropad.pixels[:] = ( (255,0,0), (128,255,0), (0,255,0), (0,255,128), (0,0,255), (128,0,255), (255,255,255), (0,0,0), (255,0,0), (128,255,0), (0,255,0), (0,255,128), ) time.sleep(2) for x in range(9): macropad.pixels.fill(0) macropad.pixels[x:x+4] = ( (255,0,0), (0,255,0), (0,0,255), (255,255,255) ) time.sleep(1) ```
1 parent 73f85d2 commit b65c8c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

adafruit_macropad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ def __init__(self, pixels, order=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)):
925925
def __setitem__(self, index, val):
926926
if isinstance(index, slice):
927927
for val_i, in_i in enumerate(range(*index.indices(self._num_pixels))):
928-
self._pixels[in_i] = self._order[val_i]
928+
self._pixels[self._order[in_i]] = val[val_i]
929929
else:
930930
self._pixels[self._order[index]] = val
931931

0 commit comments

Comments
 (0)