Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Commit cce02b8

Browse files
authored
Merge pull request #23 from dunkmann00/rgbw-tuple-bug
Only override white pixel when not given
2 parents 939fb82 + 7a39dd0 commit cce02b8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

adafruit_pypixelbuf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,14 @@ def _parse_color(self, value):
255255
# same as math.ceil(brightness * 31) & 0b00011111
256256
# Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions
257257
w = (32 - int(32 - w * 31) & 0b00011111) | DOTSTAR_LED_START
258-
elif self._has_white and r == g and g == b:
258+
elif (
259+
self._has_white
260+
and (isinstance(value, int) or len(value) == 3)
261+
and r == g
262+
and g == b
263+
):
259264
# If all components are the same and we have a white pixel then use it
260-
# instead of the individual components.
265+
# instead of the individual components when all 4 values aren't explicitly given.
261266
w = r
262267
r = 0
263268
g = 0

0 commit comments

Comments
 (0)