Adds the rgb_2_rgbw() algorithm targeted for the SK6812 chipset in experimental #1501
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 a zero-dependency (other than the stdlib) demo implementation of the
rgb_2_rgbw()
conversion function demo.It should be noted that this conversion is done entirely in uint8_t space. So it should be very fast on 8-bit AVR chipsets.
This PR does NOT change any runtime behavior and is purely a demo. And essentially unblocks platform development of the SK6812 chipset into the core library. This conversion function is preferable to a null conversation function which would map RGB(r, g, b) -> RGBW(r, g, b, 0)
You can copy the entire file and run it locally "as-is" or in the Online C++ environments, such as this one
What is not included in this PR is any platform code related to driving the SK6812 chipset. It's expected that the white color component is:
The provided unit test embedded in
main()
of this file shows that a roundtrip RGB -> RGBW -> RGB conversion has a 0% error rate. This is a bit surprising, though I checked it with a manual debugger. I would put the real error rate at around 0.4%, which is approximately 1.f/255, which assumes there is int truncation which is masking the actual error rate.In case the results of this conversion function are not to the expectation of the user (for example, there is an SK6812 chipset that uses warm white components) then the user can override this function via SFINAE mechanism. This is made possible by making the conversion function a template with an unused template parameter. The user simply has to supply their own
rgb_2_rgbw()
function and the compiler or linker will bind to that instead.#1279 (comment)