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

Only override white pixel when not given #23

Merged
merged 2 commits into from
Jul 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions adafruit_pypixelbuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,14 @@ def _parse_color(self, value):
# same as math.ceil(brightness * 31) & 0b00011111
# Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions
w = (32 - int(32 - w * 31) & 0b00011111) | DOTSTAR_LED_START
elif self._has_white and r == g and g == b:
elif (
self._has_white
and (isinstance(value, int) or len(value) == 3)
and r == g
and g == b
):
# If all components are the same and we have a white pixel then use it
# instead of the individual components.
# instead of the individual components when all 4 values aren't explicitly given.
w = r
r = 0
g = 0
Expand Down