Allow user code to set W element of RGBW pixels via pack() function (issue #25) #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is NOT True and Robust RGBW Handling™, but does allow easy setting of the W element of RGBW NeoPixels without having to unpack() a previously-pack()ed result. The pack() function accepts an optional W value, in which case it returns a 4-tuple that can be used with the NeoPixel() setter. This is esoteric but the need for it is discussed in issue #25, due to the way the CircuitPython NeoPixel setter works (tuples are preferred to packed ints). This provides a relatively benign quick compromise without having to implement a whole CRGBW class.
There’s some notes in the library, but here’s an example of it in use (from the fancyled_neopixel_rotate_simpletest.py example, adapted for RGBW)…this shows how if the RGB color gets gamma-corrected, the W value must be separately gamma-corrected before merging it in via pack(). Produces an RGB swirl with a white ramp overlaid.
Also took care of some minor refactoring that was mentioned as a TODO in there.