Skip to content

Commit da1aca0

Browse files
Fix DotStar conversion
1 parent 6a2561c commit da1aca0

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

CLUE_Light_Painter/code.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ def dotstar_write(self, _, data):
146146
data (bytearray) : Pixel data in LED strip's native color order,
147147
3 bytes/pixel. Also takes ulab uint8 ndarray.
148148
"""
149-
num_leds = len(data) // 3
150149
pixel_start = bytearray([255]) # Per-pixel marker
151150
data_bytes = [x for l in [pixel_start + data[i:i+3]
152-
for i in range(num_leds)] for x in l]
151+
for i in range(0, len(data), 3)] for x in l]
153152
# SPI is NOT locked or configured here -- the application performs
154153
# that once at startup and never relinquishes control of the port.
155154
# Anything to save a few cycles.
156155
self.spi.write(bytearray([0] * 4) + bytearray(data_bytes) +
157-
bytearray([255] * ((num_leds + 15) // 16)))
156+
bytearray([255] * (((len(data) // 3) + 15) // 16)))
158157

159158

160159
def clear_strip(self):

CLUE_Light_Painter/richbutton.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# pylint: disable=import-error, too-many-instance-attributes, too-few-public-methods
2-
31
"""Glorified button class with debounced tap, double-tap, hold and release"""
42

3+
# pylint: disable=import-error
54
from time import monotonic
65
from digitalio import DigitalInOut, Direction, Pull
76

7+
# pylint: disable=too-many-instance-attributes, too-few-public-methods
88
class RichButton:
99
"""
1010
A button class handling more than basic taps: adds debounced tap,

0 commit comments

Comments
 (0)