Skip to content

Commit 5151423

Browse files
author
Brennen Bearnes
committed
replace conditional with bitwise and, per @tannewt
Confirmed working on Pi.
1 parent eb1f0a8 commit 5151423

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

adafruit_trellis.py

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

0 commit comments

Comments
 (0)