Mapping matrix.Color333(7,0,0) to a name

I'm using Adafruit RGBmatrixPanel library for my 16x32 pixel matrix (5 feet wide x 2 feet high). I would like to equate the long command Color333(r,g,b) to a name, eg Color333(7,0,0) is Red. How do I do that?

The full statement is matrix.fillRect(16,0,16,8,matrix.Color333(7,0,0));


If you look in the library source code, you can see that this function returns a uint16_t value
( see RGB-matrix-Panel/RGBmatrixPanel.h at master · adafruit/RGB-matrix-Panel · GitHub )

So, you can do like this :

uint16_t red = matrix.Color333(7,0,0);

Thanks. I found this out by reading the GFX manual, again. There on the 3rd page was a table equating colors to hex values, eg #define MAGENTA 0xF81F. I tried your version but "red" was not declared so I just replaced the colors in upper case (e.g. MAGENTA) with lower case "magenta"...for easier typing. Works well. This can be closed.

The code suggested by @guix declares "red" so if you got an error that it was not declared, you cannot have done it correctly. Could be a scope problem. Post the code that gave that error and we can help.

I wrote a big long treatise about what I was seeing and what I tried, but then looked AGAIN at what guix had written. He is correct. For some reason (maybe my 72 year old eyes) MISSED the declaration on the first line! I like it, so simple. This is exactly what I wanted and needed. (I hadn't tried the line, I "looked at it", thought I knew what I was looking at. One should never assume...).

Below is my code that worked with the Defines. However, I think I'll go with the guix's suggestion because the code is self explanatory whereas the Defines are not.

 // FullFunctionLEDTest
    // to test 16x32 FE matrix, all LEDs all colors
    #include <RGBmatrixPanel.h>
    #define CLK  8 //these are UNO "logic" pin numbers,not physical Atmega
    #define OE   9
    #define LAT 10
    #define A   A0
    #define B   A1
    #define C   A2
    RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
    #define black   0x0000
    #define blue    0x001F
    #define red     0xF800
    #define green   0x07E0
    #define cyan    0x07FF
    #define magenta 0xF81F
    #define yellow  0xFFE0
    #define white   0xFFFF
    int d = 1000;
    void setup() {
    /****************************Function Loop**************************/
    void loop()
    { //LineTest();
    void quad1(int colour)
    { matrix.fillRect(16, 0, 16, 8, colour);}
    void quad2(int colour)
    { matrix.fillRect(0, 0, 16, 8, colour);}
    void quad3(int colour)
    { matrix.fillRect(16, 8, 16, 8, colour);}
    void quad4(int colour)
    { matrix.fillRect(0, 8, 16, 8, colour);}
    /*********************Function QuadrantColorTest*****************/
    void QuadrantColorTest( int colour)
    { matrix.fillRect(0, 0, 16, 8, colour); //Col,Row,Width,Height=rows  Quadrant 2
      //matrix.fillRect(16,0,16,8,matrix.Color333(7,0,0));//Quadrant 1
      //matrix.fillRect(16,8,16,8,matrix.Color333(7,0,0));//Quadrant 3
      //matrix.fillRect(0, 8, 16, 8, magenta); //Quadrant 4