-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
RGBW NeoPixel setter: W only works with 4-element tuples, is ignored in packed integers #5725
Comments
More on the white+blue peculiarity:
One would expect: |
Neopixels don't support setting the white pixel explicitly when setting with a number. You can set it implicitly if you set each rgb value equal to each other (i.e. 0xffffff), as then the library will turn off the color pixels and set the white pixel to that value. So:
If you'd like to explicitly set the white pixel, you need to set it as a tuple. So most of the behavior you are describing makes sense. However, what's happening with the white+blue combo seems like a bug. The output should be (0, 0, 255, 0). |
The internal pixelbuf does the numeric conversion here: https://github.com/adafruit/circuitpython/blob/main/shared-module/adafruit_pixelbuf/PixelBuf.c#L155-L198 The Python version is here: https://github.com/adafruit/Adafruit_CircuitPython_Pixelbuf/blob/main/adafruit_pixelbuf.py#L218-L265 |
@tannewt I checked the pixelbuf code, the problem only happens when using the CP version, the python version spits out an error. Since it is only when using a number and not a tuple, the only line I can think that would be the culprit is:
I could be wrong about that line being the problem, but either way I'd be happy to try and debug it later. Is there anything about that line that jumps out to you? I know there are different functions you can use to get an int, does |
Ah, right. This could have a problem on boards without long int support. Otherwise we won't be able to have all 32 bits set. I think the functionality may need to change a little. If only <=24 bits are used then do the current behavior of using white when all channels equal. If >24 bits are used then assume the highest byte is white. |
Is this a good place to object to the behavior of setting the white channel when R==G==B?
Really really very strongly feel that W in RGBW should be maintained as its own distinct thing, and up to user code how that distinct thing is handled. |
This is a good place to discuss it.
Ya, I get that. This was done as a "just works" option.
I'm not exactly sure what you are arguing for here. I think it's important to note that this behavior is not new for this library. I believe I added this W behavior in the first versions of the NeoPixel library four years ago or so. I don't think we have any super confusing aspects of the current implementation.
W is available as it's own distinct thing with the tuple form for setting. I suppose you are arguing that it should be for the getter as well.
Yes definitely. Most are SAMD21s without external flash. You can search for Even with longints, a full 32 bit int will cause an allocation and be closer to what using a tuple would be. Maybe the goal here then should be to make the getter return tuple instead of int. |
Good points. Maybe user’s issue is best fixed over in FancyLED by providing some alternative to pack() that instead provides an integer 3-tuple. In the meantime, I’ll suggest they just keep doing what they’re doing. I mean it’s not wrong, just peculiar, and the first time I’ve seen it come up. |
CircuitPython version
Code/REPL
Behavior
No error, but incorrect colors from integer values; white is not set (tuples are correct).
What’s more, and particularly strange, is when attempting the white+blue integer setting above, if white is anything other than 0 or 255, the LED is lit green rather than blue (it might be a different primary if a strip uses different pixel_order, but this is what I’m seeing here with a particular RGBW strip), which kind of suggests some bits aren’t being properly masked or something.
Description
Please see this issue:
adafruit/Adafruit_CircuitPython_FancyLED#25
Additional information
No response
The text was updated successfully, but these errors were encountered: