You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was having an issue with the RGB struct in color.h:
typedefstructPACKEDrgb_led_t {
#if (WS2812_BYTE_ORDER==WS2812_BYTE_ORDER_GRB)
uint8_tg; uint8_tr; uint8_tb;
#elif (WS2812_BYTE_ORDER==WS2812_BYTE_ORDER_RGB)
uint8_tr; uint8_tg; uint8_tb;
// removed some of the other defines that I am not using#endif
} rgb_led_t;
typedefrgb_led_tRGB;
My controller is using WS2812_BYTE_ORDER_GRB.
When I was using the struct I was trying to do something like this:
(RGB){RGB_RED}
// which would get converted to something like:
(RGB){ g=0xFF, r=0x00, b=0x00 }
Problem is that it has the g and r values flipped, since the struct gets defined as:
This works and properly handles all combinations of the defined rgb_led_t struct.
As a user I can then call something like:
rgb_led_tmy_indicator=get_rgb_led(RGB_RED);
and get a properly defined rgb_led_t regardless of which ordering the struct is using.
I propose to add the above sample code snippet to the documentation and a blurb on how to use it.
I can write the documentation and create a PR if the team feels this is a good idea.
Having something like this would have saved me a lot of time, since I thought there was something I was doing wrong or had wired something wrong where it was just a matter of the values being assigned wrong.
The text was updated successfully, but these errors were encountered:
Really, rgb_led_t should not need to know anything about any specific LED driver in the first place.
I'm already working on refactoring the WS2812 driver API to match the other LED drivers and move the handling of byte ordering to an internal ws2812_led_t array:
Issue Description
I would like to add a blurb and sample code to the RGB Matrix Documentation
I was having an issue with the RGB struct in color.h:
My controller is using
WS2812_BYTE_ORDER_GRB
.When I was using the struct I was trying to do something like this:
Problem is that it has the g and r values flipped, since the struct gets defined as:
After asking for help on the Disord channel, @elpekenin suggested using something like this:
This works and properly handles all combinations of the defined rgb_led_t struct.
As a user I can then call something like:
and get a properly defined rgb_led_t regardless of which ordering the struct is using.
I propose to add the above sample code snippet to the documentation and a blurb on how to use it.
I can write the documentation and create a PR if the team feels this is a good idea.
Having something like this would have saved me a lot of time, since I thought there was something I was doing wrong or had wired something wrong where it was just a matter of the values being assigned wrong.
The text was updated successfully, but these errors were encountered: