Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support white neopixel strings #6758

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3123,7 +3123,7 @@ pin:
# Neopixel is connected to the pin).
#color_order: GRB
# Set the pixel order required by the LED hardware (using a string
# containing the letters R, G, B, W with W optional). Alternatively,
# containing the letters R, G, B, W). Alternatively,
# this may be a comma separated list of pixel orders - one for each
# LED in the chain. The default is GRB.
#initial_RED: 0.0
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, config):
raise config.error("color_order does not match chain_count")
color_indexes = []
for lidx, co in enumerate(color_order):
if sorted(co) not in (sorted("RGB"), sorted("RGBW")):
if any(c not in "RGBW" for c in co):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This validation is insufficient, it allows strings like RRRRR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was certain that I saw other single color cob strips on aliexpress, but I can't seem to find them now :-)
What do you think the best approach here would be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you're bringing up single colors. The best approach would be to perform sufficient validation so that strings like RRRRRRRRRRRRRRRRRRGBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB aren't accepted.

raise config.error("Invalid color_order '%s'" % (co,))
color_indexes.extend([(lidx, "RGBW".index(c)) for c in co])
self.color_map = list(enumerate(color_indexes))
Expand Down