Minor bug in Arduino Example: RGB order for AlphaSquare?


(danbernier) #1

Hi! Just got my keyboardio on Saturday, and I’m learning about flashing the firmware.

I was reading through the example firmware sketch in Arduino, and saw these lines:

  // We configure the AlphaSquare effect to use RED letters
  AlphaSquare.color = { 255, 0, 0 };

But I could’ve sworn the alpha-square plugin was using blue. I experimented, and it seems like the common RGB order is reversed? It’s actually BGR?

I cross-checked with solidRed, solidOrange, etc, and those seem to have the colors in the usual RGB order: (160, 0, 0) is red, (140, 70, 0) is orange. I looked through the AlphaSquare code, but it seems to use the same cRGB type, and the same function ::LEDControl.setCrgbAt, as LEDEffect-SolidColor.

This is about where I get out of my depth with C++. Has anyone else noticed this? If you can explain it, I’d love to see where I’m going wrong…


(James Cash) #2

Others know more about this than I, but I believe that yes, the Model 01 firmware gets LED colours in BGR order. I believe the solidColor things use a wrapper over that (the CRGB macro), to accept colours in normal RGB order (which most plugins should be doing), but the AlphaSquare plugin is reading a “raw” colour value.


(Michael Richters) #3

It should work to use this:

AlphaSquare.color = CRGB(red, green, blue);

(danbernier) #4

Yep, that fixes it! Thanks for the help. I’ll file a pull request to https://github.com/keyboardio/Model01-Firmware, I think that’s the right place - it’s the only repo that has that code comment.