Color value statements

I'm using some code from another post on this forum for my santa suit matrix (23x5 of 2812).
But I'm confused about the long ColVar statment variables. How does one arrive at those numbers? I would like to replace them with green/white/red/white/repeat. I've looked at places like http://colorizer.org/ but they do not export a straight number value, so I'm confused as to what format this is also.

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 6

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(23, 5, PIN,
  NEO_MATRIX_TOP     + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS    + NEO_MATRIX_PROGRESSIVE,
  NEO_GRB            + NEO_KHZ800);

long ColVar[192]={63488, 63552, 63616, 63680, 63744, 63808, 63872, 63936, 64000, 64064, 64128, 64192, 64256, 64320, 64384, 64448, 64512, 64576, 64640, 64704, 64768, 64832, 64896, 64960, 65024, 65088, 65152, 65216, 65280, 65344, 65408, 65472, 
                  65504, 63456, 61408, 59360, 57312, 55264, 53216, 51168, 49120, 47072, 45024, 42976, 40928, 38880, 36832, 34784, 32736, 30688, 28640, 26592, 24544, 22496, 20448, 18400, 16352, 14304, 12256, 10208, 8160,  6112,  4064,  2016, 
                  2016,  2017,  2018,  2019,  2020,  2021,  2022,  2023,  2024,  2025,  2026,  2027,  2028,  2029,  2030,  2031,  2032,  2033,  2034,  2035,  2036,  2037,  2038,  2039,  2040,  2041,  2042,  2043,  2044,  2045,  2046,  2047, 
                  2015,  1951,  1887,  1823,  1759,  1695,  1631,  1567,  1503,  1439,  1375,  1311,  1247,  1183,  1119,  1055,  991,   927,   863,   799,   735,   671,   607,   543,   479,   415,   351,   287,   223,   159,   95,    31, 
                  31,    2079,  4127,  6175,  8223,  10271, 12319, 14367, 16415, 18463, 20511, 22559, 24607, 26655, 28703, 30751, 32799, 34847, 36895, 38943, 40991, 43039, 45087, 47135, 49183, 51231, 53279, 55327, 57375, 59423, 61471, 63519, 
                  63519, 63518, 63517, 63516, 63515, 63514, 63513, 63512, 63511, 63510, 63509, 63508, 63507, 63506, 63505, 63504, 63503, 63502, 63501, 63500, 63499, 63498, 63497, 63496, 63495, 63494, 63493, 63492, 63491, 63490, 63489, 63488};

int Col1 = 0;
int Col2 = 5;
int Col3 = 10;
int Col4 = 15;
int Col5 = 20;
int Col6 = 25;
int Col7 = 30;
int Col8 = 35;
int Col9 = 40;
int Col10 = 45;
int Col11 = 50;
int Col12 = 55;
int Col13 = 60;
int Col14 = 65;
int Col15 = 70;
int Col16 = 75;
int Col17 = 80;
int Col18 = 85;
int Col19 = 90;
int Col20 = 95;
int Col21 = 100;
int Col22 = 105;
int Col23 = 110;
int Col24 = 115;
int Col25 = 120;
int Col26 = 125;
int Col27 = 130;
int Col28 = 135;
int Col29 = 140;
int Col30 = 145;
int Col31 = 150;
int Col32 = 155;
int Col33 = 160;
int Col34 = 165;

unsigned long startMillis;  
unsigned long ColMillis1;
unsigned long ColMillis2;
unsigned long ColMillis3;
unsigned long ColMillis4;
unsigned long ColMillis5;
unsigned long ColMillis6;
unsigned long ColMillis7;
unsigned long ColMillis8;
unsigned long ColMillis9;
unsigned long ColMillis10;
unsigned long ColMillis11;
unsigned long ColMillis12;
unsigned long ColMillis13;
unsigned long ColMillis14;
unsigned long ColMillis15;
unsigned long ColMillis16;
unsigned long ColMillis17;
unsigned long ColMillis18;
unsigned long ColMillis19;
unsigned long ColMillis20;
unsigned long ColMillis21;
unsigned long ColMillis22;
unsigned long ColMillis23;
unsigned long ColMillis24;
unsigned long ColMillis25;
unsigned long ColMillis26;
unsigned long ColMillis27;
unsigned long ColMillis28;
unsigned long ColMillis29;
unsigned long ColMillis30;
unsigned long ColMillis31;
unsigned long ColMillis32;
unsigned long ColMillis33;
unsigned long ColMillis34;
unsigned long currentMillis;

void setup() {
  startMillis = millis();  //initial start time
  ColMillis1 = millis();
  ColMillis2 = millis();
  ColMillis3 = millis();
  ColMillis4 = millis();
  ColMillis5 = millis();
  ColMillis6 = millis();
  ColMillis7 = millis();
  ColMillis8 = millis();
  ColMillis9 = millis();
  ColMillis10 = millis();
  ColMillis11 = millis();
  ColMillis12 = millis();
  ColMillis13 = millis();
  ColMillis14 = millis();
  ColMillis15 = millis();
  ColMillis16 = millis();
  ColMillis17 = millis();
  ColMillis18 = millis();
  ColMillis19 = millis();
  ColMillis20 = millis();
  ColMillis21 = millis();
  ColMillis22 = millis();
  ColMillis23 = millis();
  ColMillis24 = millis();
  ColMillis25 = millis();
  ColMillis26 = millis();
  ColMillis27 = millis();
  ColMillis28 = millis();
  ColMillis29 = millis();
  ColMillis30 = millis();
  ColMillis31 = millis();
  ColMillis32 = millis();
  ColMillis33 = millis();
  ColMillis34 = millis();
  matrix.begin();
  matrix.setBrightness(20);
}

void loop() {
  currentMillis = millis();  
 // fastRect();
  colSpectr();
  timer();
  HueControll();
}

void colSpectr(){
  if ((currentMillis - startMillis >= 0) && (currentMillis - startMillis <= 35000)) {
    colSpectrD();
  }
}

void timer() {
  //Reset Loop-Timer
  if (currentMillis - startMillis > 35000) {
    startMillis = currentMillis;
  }
}

void HueControll(){
  #define HueSpeed 10

  if (currentMillis - ColMillis1 >= HueSpeed) {        
    Col1++;                                            
    ColMillis1 = currentMillis;                        
  }
  if (currentMillis - ColMillis2 >= HueSpeed) {        
    Col2++;                                            
    ColMillis2 = currentMillis;                        
  }
  if (currentMillis - ColMillis3 >= HueSpeed) {        
    Col3++;                                            
    ColMillis3 = currentMillis;                        
  }
  if (currentMillis - ColMillis4 >= HueSpeed) {        
    Col4++;                                            
    ColMillis4 = currentMillis;                        
  }
  if (currentMillis - ColMillis5 >= HueSpeed) {        
    Col5++;                                            
    ColMillis5 = currentMillis;                        
  }
  if (currentMillis - ColMillis6 >= HueSpeed) {        
    Col6++;                                            
    ColMillis6 = currentMillis;                        
  }
  if (currentMillis - ColMillis7 >= HueSpeed) {        
    Col7++;                                            
    ColMillis7 = currentMillis;                        
  }
  if (currentMillis - ColMillis8 >= HueSpeed) {        
    Col8++;                                            
    ColMillis8 = currentMillis;                        
  }
  if (currentMillis - ColMillis9 >= HueSpeed) {        
    Col9++;                                            
    ColMillis9 = currentMillis;                        
  }
  if (currentMillis - ColMillis10 >= HueSpeed) {       
    Col10++;                                           
    ColMillis10 = currentMillis;                       
  }
  if (currentMillis - ColMillis11 >= HueSpeed) {       
    Col11++;                                           
    ColMillis11 = currentMillis;                       
  }
  if (currentMillis - ColMillis12 >= HueSpeed) {       
    Col12++;                                           
    ColMillis12 = currentMillis;                       
  }
  if (currentMillis - ColMillis13 >= HueSpeed) {        
    Col13++;                                            
    ColMillis13 = currentMillis;                        
  }
  if (currentMillis - ColMillis14 >= HueSpeed) {        
    Col14++;                                            
    ColMillis14 = currentMillis;                        
  }
  if (currentMillis - ColMillis15 >= HueSpeed) {        
    Col15++;                                            
    ColMillis15 = currentMillis;                        
  }
  if (currentMillis - ColMillis16 >= HueSpeed) {        
    Col16++;                                            
    ColMillis16 = currentMillis;                        
  }
  if (currentMillis - ColMillis17 >= HueSpeed) {        
    Col17++;                                            
    ColMillis17 = currentMillis;                        
  }
  if (currentMillis - ColMillis18 >= HueSpeed) {        
    Col18++;                                            
    ColMillis18 = currentMillis;                        
  }
  if (currentMillis - ColMillis19 >= HueSpeed) {        
    Col19++;                                            
    ColMillis19 = currentMillis;                        
  }
    if (currentMillis - ColMillis20 >= HueSpeed) {       
    Col20++;                                           
    ColMillis20 = currentMillis;                       
  }
  if (currentMillis - ColMillis21 >= HueSpeed) {       
    Col21++;                                           
    ColMillis21 = currentMillis;                       
  }
  if (currentMillis - ColMillis22 >= HueSpeed) {       
    Col22++;                                           
    ColMillis22 = currentMillis;                       
  }
  if (currentMillis - ColMillis23 >= HueSpeed) {        
    Col23++;                                            
    ColMillis23 = currentMillis;                        
  }
  if (currentMillis - ColMillis24 >= HueSpeed) {        
    Col24++;                                            
    ColMillis24 = currentMillis;                        
  }
  if (currentMillis - ColMillis25 >= HueSpeed) {        
    Col25++;                                            
    ColMillis25 = currentMillis;                        
  }
  if (currentMillis - ColMillis26 >= HueSpeed) {        
    Col26++;                                            
    ColMillis26 = currentMillis;                        
  }
  if (currentMillis - ColMillis27 >= HueSpeed) {        
    Col27++;                                            
    ColMillis27 = currentMillis;                        
  }
  if (currentMillis - ColMillis28 >= HueSpeed) {        
    Col28++;                                            
    ColMillis28 = currentMillis;                        
  }
  if (currentMillis - ColMillis29 >= HueSpeed) {        
    Col29++;                                            
    ColMillis29 = currentMillis;                        
  }
    if (currentMillis - ColMillis30 >= HueSpeed) {       
    Col30++;                                           
    ColMillis30 = currentMillis;                       
  }
  if (currentMillis - ColMillis31 >= HueSpeed) {       
    Col31++;                                           
    ColMillis31 = currentMillis;                       
  }
  if (currentMillis - ColMillis32 >= HueSpeed) {       
    Col32++;                                           
    ColMillis32 = currentMillis;                       
  }
  if (currentMillis - ColMillis33 >= HueSpeed) {        
    Col33++;                                            
    ColMillis33 = currentMillis;                        
  }
  if (currentMillis - ColMillis34 >= HueSpeed) {        
    Col34++;                                            
    ColMillis34 = currentMillis;                        
  }
  
  if (Col1 >= 192) {                               
    Col1 = 0;
  }
  if (Col2 >= 192) {                               
    Col2 = 0;
  }
  if (Col3 >= 192) {                               
    Col3 = 0;
  }
  if (Col4 >= 192) {                               
    Col4 = 0;
  }
  if (Col5 >= 192) {                               
    Col5 = 0;
  }
  if (Col6 >= 192) {                               
    Col6 = 0;
  }
  if (Col7 >= 192) {                               
    Col7 = 0;
  }
  if (Col8 >= 192) {                               
    Col8 = 0;
  }
    if (Col9 >= 192) {                             
    Col9 = 0;
  }
    if (Col10 >= 192) {                            
    Col10 = 0;
  }
    if (Col11 >= 192) {                            
    Col11 = 0;
  }
    if (Col12 >= 192) {                            
    Col12 = 0;
  }
    if (Col13 >= 192) {                               
    Col13 = 0;
  }
  if (Col14 >= 192) {                               
    Col14 = 0;
  }
  if (Col15 >= 192) {                               
    Col15 = 0;
  }
  if (Col16 >= 192) {                               
    Col16 = 0;
  }
  if (Col17 >= 192) {                               
    Col17 = 0;
  }
  if (Col18 >= 192) {                               
    Col18 = 0;
  }
    if (Col19 >= 192) {                             
    Col19 = 0;
  }
    if (Col20 >= 192) {                               
    Col20 = 0;
  }
  if (Col21 >= 192) {                               
    Col21 = 0;
  }
  if (Col22 >= 192) {                               
    Col22 = 0;
  }
  if (Col23 >= 192) {                               
    Col23 = 0;
  }
  if (Col24 >= 192) {                               
    Col24 = 0;
  }
  if (Col25 >= 192) {                               
    Col25 = 0;
  }
  if (Col26 >= 192) {                               
    Col26 = 0;
  }
    if (Col27 >= 192) {                             
    Col27 = 0;
  }
    if (Col28 >= 192) {                               
    Col28 = 0;
  }
    if (Col29 >= 192) {                             
    Col29 = 0;
  }
    if (Col30 >= 192) {                               
    Col30 = 0;
  }
  if (Col31 >= 192) {                               
    Col31 = 0;
  }
  if (Col32 >= 192) {                               
    Col32 = 0;
  }
  if (Col33 >= 192) {                               
    Col33 = 0;
  }
  if (Col34 >= 192) {                               
    Col34 = 0;
  }
}

void colSpectrD() {
  matrix.fillScreen(0);
  matrix.drawLine(0, 0, 0, 0, ColVar[Col1]);
  matrix.drawLine(0, 1, 1, 0, ColVar[Col2]);
  matrix.drawLine(0, 2, 2, 0, ColVar[Col3]);
  matrix.drawLine(0, 3, 3, 0, ColVar[Col4]);
  matrix.drawLine(0, 4, 4, 0, ColVar[Col5]);
  matrix.drawLine(0, 5, 5, 0, ColVar[Col6]);
  matrix.drawLine(0, 6, 6, 0, ColVar[Col7]);
  matrix.drawLine(0, 7, 7, 0, ColVar[Col8]);
  matrix.drawLine(0, 8, 8, 0, ColVar[Col9]);
  matrix.drawLine(0, 9, 9, 0, ColVar[Col10]);
  matrix.drawLine(0, 10, 10, 0, ColVar[Col11]);
  matrix.drawLine(0, 11, 11, 0, ColVar[Col12]);
  matrix.drawLine(0, 12, 12, 0, ColVar[Col13]);
  matrix.drawLine(0, 13, 13, 0, ColVar[Col14]);
  matrix.drawLine(0, 14, 14, 0, ColVar[Col15]);
  matrix.drawLine(0, 15, 15, 0, ColVar[Col16]);
  matrix.drawLine(0, 16, 16, 0, ColVar[Col17]);
  matrix.drawLine(0, 17, 17, 0, ColVar[Col18]);
  matrix.drawLine(0, 18, 18, 0, ColVar[Col19]);
  matrix.drawLine(0, 19, 19, 0, ColVar[Col20]);
  matrix.drawLine(0, 20, 20, 0, ColVar[Col21]);
  matrix.drawLine(0, 21, 21, 0, ColVar[Col22]);
  matrix.drawLine(0, 22, 22, 0, ColVar[Col23]);
  matrix.drawLine(0, 23, 23, 0, ColVar[Col24]);
  matrix.drawLine(0, 24, 24, 0, ColVar[Col25]);
  matrix.drawLine(0, 25, 25, 0, ColVar[Col26]);
  matrix.drawLine(0, 26, 26, 0, ColVar[Col27]);
  matrix.drawLine(0, 27, 27, 0, ColVar[Col28]);
  matrix.show();
}

45degreeColorMatrix.ino (14.4 KB)

Hello

Those are RGB565 colors, for example the first number 63488, represented in binary, is 0b‭1111100000000000‬ which is red

This code is really bad, you shouldn't learn anything from it

How did he pick out only number values of RGB565? Because of my limited knowledge of Arduino code, I would like to replace the color entries.

You'll have to ask him.

It is easy to calculate 565 color values from typical RGB values (e.g. 0-255 for each R, G, B). Let us know what you want to do.

My goal is to rotate green/white/red/white/repeat around my matrix like a barber-shop pole. But on a 23 column x 5 row matrix. A barber-shop pole has a twist to it and that is why I was leading towards this code. and it fades to another color.

Here is the same array but in different formats

Binary

const uint16_t ColVar[] =
{
	0b1111100000000000, 0b1111100001000000, 0b1111100010000000, 0b1111100011000000,
	0b1111100100000000, 0b1111100101000000, 0b1111100110000000, 0b1111100111000000,
	0b1111101000000000, 0b1111101001000000, 0b1111101010000000, 0b1111101011000000,
	0b1111101100000000, 0b1111101101000000, 0b1111101110000000, 0b1111101111000000,
	0b1111110000000000, 0b1111110001000000, 0b1111110010000000, 0b1111110011000000,
	0b1111110100000000, 0b1111110101000000, 0b1111110110000000, 0b1111110111000000,
	0b1111111000000000, 0b1111111001000000, 0b1111111010000000, 0b1111111011000000,
	0b1111111100000000, 0b1111111101000000, 0b1111111110000000, 0b1111111111000000,
	0b1111111111100000, 0b1111011111100000, 0b1110111111100000, 0b1110011111100000,
	0b1101111111100000, 0b1101011111100000, 0b1100111111100000, 0b1100011111100000,
	0b1011111111100000, 0b1011011111100000, 0b1010111111100000, 0b1010011111100000,
	0b1001111111100000, 0b1001011111100000, 0b1000111111100000, 0b1000011111100000,
	0b0111111111100000, 0b0111011111100000, 0b0110111111100000, 0b0110011111100000,
	0b0101111111100000, 0b0101011111100000, 0b0100111111100000, 0b0100011111100000,
	0b0011111111100000, 0b0011011111100000, 0b0010111111100000, 0b0010011111100000,
	0b0001111111100000, 0b0001011111100000, 0b0000111111100000, 0b0000011111100000,
	0b0000011111100000, 0b0000011111100001, 0b0000011111100010, 0b0000011111100011,
	0b0000011111100100, 0b0000011111100101, 0b0000011111100110, 0b0000011111100111,
	0b0000011111101000, 0b0000011111101001, 0b0000011111101010, 0b0000011111101011,
	0b0000011111101100, 0b0000011111101101, 0b0000011111101110, 0b0000011111101111,
	0b0000011111110000, 0b0000011111110001, 0b0000011111110010, 0b0000011111110011,
	0b0000011111110100, 0b0000011111110101, 0b0000011111110110, 0b0000011111110111,
	0b0000011111111000, 0b0000011111111001, 0b0000011111111010, 0b0000011111111011,
	0b0000011111111100, 0b0000011111111101, 0b0000011111111110, 0b0000011111111111,
	0b0000011111011111, 0b0000011110011111, 0b0000011101011111, 0b0000011100011111,
	0b0000011011011111, 0b0000011010011111, 0b0000011001011111, 0b0000011000011111,
	0b0000010111011111, 0b0000010110011111, 0b0000010101011111, 0b0000010100011111,
	0b0000010011011111, 0b0000010010011111, 0b0000010001011111, 0b0000010000011111,
	0b0000001111011111, 0b0000001110011111, 0b0000001101011111, 0b0000001100011111,
	0b0000001011011111, 0b0000001010011111, 0b0000001001011111, 0b0000001000011111,
	0b0000000111011111, 0b0000000110011111, 0b0000000101011111, 0b0000000100011111,
	0b0000000011011111, 0b0000000010011111, 0b0000000001011111, 0b0000000000011111,
	0b0000000000011111, 0b0000100000011111, 0b0001000000011111, 0b0001100000011111,
	0b0010000000011111, 0b0010100000011111, 0b0011000000011111, 0b0011100000011111,
	0b0100000000011111, 0b0100100000011111, 0b0101000000011111, 0b0101100000011111,
	0b0110000000011111, 0b0110100000011111, 0b0111000000011111, 0b0111100000011111,
	0b1000000000011111, 0b1000100000011111, 0b1001000000011111, 0b1001100000011111,
	0b1010000000011111, 0b1010100000011111, 0b1011000000011111, 0b1011100000011111,
	0b1100000000011111, 0b1100100000011111, 0b1101000000011111, 0b1101100000011111,
	0b1110000000011111, 0b1110100000011111, 0b1111000000011111, 0b1111100000011111,
	0b1111100000011111, 0b1111100000011110, 0b1111100000011101, 0b1111100000011100,
	0b1111100000011011, 0b1111100000011010, 0b1111100000011001, 0b1111100000011000,
	0b1111100000010111, 0b1111100000010110, 0b1111100000010101, 0b1111100000010100,
	0b1111100000010011, 0b1111100000010010, 0b1111100000010001, 0b1111100000010000,
	0b1111100000001111, 0b1111100000001110, 0b1111100000001101, 0b1111100000001100,
	0b1111100000001011, 0b1111100000001010, 0b1111100000001001, 0b1111100000001000,
	0b1111100000000111, 0b1111100000000110, 0b1111100000000101, 0b1111100000000100,
	0b1111100000000011, 0b1111100000000010, 0b1111100000000001, 0b1111100000000000
};

Hexadecimal

const uint16_t ColVar[] =
{
	0xF800, 0xF840, 0xF880, 0xF8C0, 0xF900, 0xF940, 0xF980, 0xF9C0,
	0xFA00, 0xFA40, 0xFA80, 0xFAC0, 0xFB00, 0xFB40, 0xFB80, 0xFBC0,
	0xFC00, 0xFC40, 0xFC80, 0xFCC0, 0xFD00, 0xFD40, 0xFD80, 0xFDC0,
	0xFE00, 0xFE40, 0xFE80, 0xFEC0, 0xFF00, 0xFF40, 0xFF80, 0xFFC0,
	0xFFE0, 0xF7E0, 0xEFE0, 0xE7E0, 0xDFE0, 0xD7E0, 0xCFE0, 0xC7E0,
	0xBFE0, 0xB7E0, 0xAFE0, 0xA7E0, 0x9FE0, 0x97E0, 0x8FE0, 0x87E0,
	0x7FE0, 0x77E0, 0x6FE0, 0x67E0, 0x5FE0, 0x57E0, 0x4FE0, 0x47E0,
	0x3FE0, 0x37E0, 0x2FE0, 0x27E0, 0x1FE0, 0x17E0, 0x0FE0, 0x07E0,
	0x07E0, 0x07E1, 0x07E2, 0x07E3, 0x07E4, 0x07E5, 0x07E6, 0x07E7,
	0x07E8, 0x07E9, 0x07EA, 0x07EB, 0x07EC, 0x07ED, 0x07EE, 0x07EF,
	0x07F0, 0x07F1, 0x07F2, 0x07F3, 0x07F4, 0x07F5, 0x07F6, 0x07F7,
	0x07F8, 0x07F9, 0x07FA, 0x07FB, 0x07FC, 0x07FD, 0x07FE, 0x07FF,
	0x07DF, 0x079F, 0x075F, 0x071F, 0x06DF, 0x069F, 0x065F, 0x061F,
	0x05DF, 0x059F, 0x055F, 0x051F, 0x04DF, 0x049F, 0x045F, 0x041F,
	0x03DF, 0x039F, 0x035F, 0x031F, 0x02DF, 0x029F, 0x025F, 0x021F,
	0x01DF, 0x019F, 0x015F, 0x011F, 0x00DF, 0x009F, 0x005F, 0x001F,
	0x001F, 0x081F, 0x101F, 0x181F, 0x201F, 0x281F, 0x301F, 0x381F,
	0x401F, 0x481F, 0x501F, 0x581F, 0x601F, 0x681F, 0x701F, 0x781F,
	0x801F, 0x881F, 0x901F, 0x981F, 0xA01F, 0xA81F, 0xB01F, 0xB81F,
	0xC01F, 0xC81F, 0xD01F, 0xD81F, 0xE01F, 0xE81F, 0xF01F, 0xF81F,
	0xF81F, 0xF81E, 0xF81D, 0xF81C, 0xF81B, 0xF81A, 0xF819, 0xF818,
	0xF817, 0xF816, 0xF815, 0xF814, 0xF813, 0xF812, 0xF811, 0xF810,
	0xF80F, 0xF80E, 0xF80D, 0xF80C, 0xF80B, 0xF80A, 0xF809, 0xF808,
	0xF807, 0xF806, 0xF805, 0xF804, 0xF803, 0xF802, 0xF801, 0xF800
};

Or splitting color components

const rgb565_t ColVar[] =
{
	{ 31,  0,  0 }, { 31,  2,  0 }, { 31,  4,  0 }, { 31,  6,  0 },
	{ 31,  8,  0 }, { 31, 10,  0 }, { 31, 12,  0 }, { 31, 14,  0 },
	{ 31, 16,  0 }, { 31, 18,  0 }, { 31, 20,  0 }, { 31, 22,  0 },
	{ 31, 24,  0 }, { 31, 26,  0 }, { 31, 28,  0 }, { 31, 30,  0 },
	{ 31, 32,  0 }, { 31, 34,  0 }, { 31, 36,  0 }, { 31, 38,  0 },
	{ 31, 40,  0 }, { 31, 42,  0 }, { 31, 44,  0 }, { 31, 46,  0 },
	{ 31, 48,  0 }, { 31, 50,  0 }, { 31, 52,  0 }, { 31, 54,  0 },
	{ 31, 56,  0 }, { 31, 58,  0 }, { 31, 60,  0 }, { 31, 62,  0 },
	{ 31, 63,  0 }, { 30, 63,  0 }, { 29, 63,  0 }, { 28, 63,  0 },
	{ 27, 63,  0 }, { 26, 63,  0 }, { 25, 63,  0 }, { 24, 63,  0 },
	{ 23, 63,  0 }, { 22, 63,  0 }, { 21, 63,  0 }, { 20, 63,  0 },
	{ 19, 63,  0 }, { 18, 63,  0 }, { 17, 63,  0 }, { 16, 63,  0 },
	{ 15, 63,  0 }, { 14, 63,  0 }, { 13, 63,  0 }, { 12, 63,  0 },
	{ 11, 63,  0 }, { 10, 63,  0 }, {  9, 63,  0 }, {  8, 63,  0 },
	{  7, 63,  0 }, {  6, 63,  0 }, {  5, 63,  0 }, {  4, 63,  0 },
	{  3, 63,  0 }, {  2, 63,  0 }, {  1, 63,  0 }, {  0, 63,  0 },
	{  0, 63,  0 }, {  0, 63,  1 }, {  0, 63,  2 }, {  0, 63,  3 },
	{  0, 63,  4 }, {  0, 63,  5 }, {  0, 63,  6 }, {  0, 63,  7 },
	{  0, 63,  8 }, {  0, 63,  9 }, {  0, 63, 10 }, {  0, 63, 11 },
	{  0, 63, 12 }, {  0, 63, 13 }, {  0, 63, 14 }, {  0, 63, 15 },
	{  0, 63, 16 }, {  0, 63, 17 }, {  0, 63, 18 }, {  0, 63, 19 },
	{  0, 63, 20 }, {  0, 63, 21 }, {  0, 63, 22 }, {  0, 63, 23 },
	{  0, 63, 24 }, {  0, 63, 25 }, {  0, 63, 26 }, {  0, 63, 27 },
	{  0, 63, 28 }, {  0, 63, 29 }, {  0, 63, 30 }, {  0, 63, 31 },
	{  0, 62, 31 }, {  0, 60, 31 }, {  0, 58, 31 }, {  0, 56, 31 },
	{  0, 54, 31 }, {  0, 52, 31 }, {  0, 50, 31 }, {  0, 48, 31 },
	{  0, 46, 31 }, {  0, 44, 31 }, {  0, 42, 31 }, {  0, 40, 31 },
	{  0, 38, 31 }, {  0, 36, 31 }, {  0, 34, 31 }, {  0, 32, 31 },
	{  0, 30, 31 }, {  0, 28, 31 }, {  0, 26, 31 }, {  0, 24, 31 },
	{  0, 22, 31 }, {  0, 20, 31 }, {  0, 18, 31 }, {  0, 16, 31 },
	{  0, 14, 31 }, {  0, 12, 31 }, {  0, 10, 31 }, {  0,  8, 31 },
	{  0,  6, 31 }, {  0,  4, 31 }, {  0,  2, 31 }, {  0,  0, 31 },
	{  0,  0, 31 }, {  1,  0, 31 }, {  2,  0, 31 }, {  3,  0, 31 },
	{  4,  0, 31 }, {  5,  0, 31 }, {  6,  0, 31 }, {  7,  0, 31 },
	{  8,  0, 31 }, {  9,  0, 31 }, { 10,  0, 31 }, { 11,  0, 31 },
	{ 12,  0, 31 }, { 13,  0, 31 }, { 14,  0, 31 }, { 15,  0, 31 },
	{ 16,  0, 31 }, { 17,  0, 31 }, { 18,  0, 31 }, { 19,  0, 31 },
	{ 20,  0, 31 }, { 21,  0, 31 }, { 22,  0, 31 }, { 23,  0, 31 },
	{ 24,  0, 31 }, { 25,  0, 31 }, { 26,  0, 31 }, { 27,  0, 31 },
	{ 28,  0, 31 }, { 29,  0, 31 }, { 30,  0, 31 }, { 31,  0, 31 },
	{ 31,  0, 31 }, { 31,  0, 30 }, { 31,  0, 29 }, { 31,  0, 28 },
	{ 31,  0, 27 }, { 31,  0, 26 }, { 31,  0, 25 }, { 31,  0, 24 },
	{ 31,  0, 23 }, { 31,  0, 22 }, { 31,  0, 21 }, { 31,  0, 20 },
	{ 31,  0, 19 }, { 31,  0, 18 }, { 31,  0, 17 }, { 31,  0, 16 },
	{ 31,  0, 15 }, { 31,  0, 14 }, { 31,  0, 13 }, { 31,  0, 12 },
	{ 31,  0, 11 }, { 31,  0, 10 }, { 31,  0,  9 }, { 31,  0,  8 },
	{ 31,  0,  7 }, { 31,  0,  6 }, { 31,  0,  5 }, { 31,  0,  4 },
	{ 31,  0,  3 }, { 31,  0,  2 }, { 31,  0,  1 }, { 31,  0,  0 }
};

The last one is to be used with a struct like this

#pragma pack( push, 1 )
struct rgb565_t
{
	uint8_t r : 5;
	uint8_t g : 6;
	uint8_t b : 5;
	
	operator uint16_t() const
	{
		return (r << 11) | (g << 5) | b;
	}
};
#pragma pack( pop )

And, you can probably notice a pattern

  • Start with rgb = 31,0,0
  • Increase g by 2 until 63
  • Decrease r by 1 until 0
  • Increase b by 1 until 31
  • Decrease g by 2 until 0
  • etc

With such predictive values, you don't even need an array, you can do the same thing programmatically with a few counters

Here is how I generated those arrays, if you are interested : JYTVDm - Online C++ Compiler & Debugging Tool - Ideone.com

Color fading can easily be done with linear interpolation ("lerp")

1 Like

Is it terrible code. @brainfarth can learn something from it: when you see code like this, stop writing or using it!

In the world of programming, repetition is a sin. A little occasional repetition is only a minor sin and can be overlooked. Code which repeats almost everything 34 times over...

1 Like

Here is another example which adds a lerp method to that rgb565_t struct and prints a lot of intermediate colors between black and white, that should be a good starting point for your program :slight_smile: : https://ideone.com/TJw2yM