Skip to content

Commit eb1f0a8

Browse files
author
Brennen Bearnes
committed
only apply mask to _led_buffer if < 256
This works on CPython. I _think_ it will work on CircuitPython, since the old behavior is effectively a no-op there. On CPython it was throwing a `ValueError`. I want to be clear that I don't understand this code, so I'm definitely not confident that this change is the Correct Thing.
1 parent 92fc6fb commit eb1f0a8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

adafruit_trellis.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def __setitem__(self, x, value):
9191
led = ledLUT[x % 16] >> 4
9292
mask = 1 << (ledLUT[x % 16] & 0x0f)
9393
if value:
94-
self._parent._led_buffer[x // 16][(led * 2) + 1] |= mask
94+
if mask < 256:
95+
self._parent._led_buffer[x // 16][(led * 2) + 1] |= mask
9596
self._parent._led_buffer[x // 16][(led * 2) + 2] |= mask >> 8
9697
elif not value:
9798
self._parent._led_buffer[x // 16][(led * 2) + 1] &= ~mask

0 commit comments

Comments
 (0)