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

Adds the rgb_2_rgbw() algorithm targeted for the SK6812 chipset in experimental #1501

Closed
wants to merge 0 commits into from

Conversation

zackees
Copy link
Member

@zackees zackees commented May 3, 2023

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:

  • Equivalent to 3 color component rgb LEDs mixing together to create neutral white.
  • The white led has the same brightness as the other color components.

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)

@zackees zackees changed the title Adds the rgb_2_rgbw() algorithm targeted for the SK6812 chipset in src/experimental Adds the rgb_2_rgbw() algorithm targeted for the SK6812 chipset in experimental May 3, 2023
@zackees zackees closed this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant