//
// ESP32 NeoPixel 32x32 Logo Demo - this demo uses four 8x32 panels
// to create a single 32x32 maxtrix.
//

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

#define PIN 2
int Delay = 100;

// Four matrix matrix
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 1, 4, PIN,
  NEO_MATRIX_TOP   + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE +
  NEO_TILE_TOP     + NEO_TILE_LEFT   + NEO_TILE_ROWS   + NEO_TILE_PROGRESSIVE,
  NEO_GRB          + NEO_KHZ800);

//
// Setup function
//

void setup() {
  matrix.begin();
  matrix.setBrightness(255);

  buildLogo();
}

//
// Loop function
//

//
// Define colors
//
uint16_t logoColors[1024];

long rawHexColors[1024] = {
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x0c0c0c, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000001, 0x000003, 0x06060e, 
0x0a0c14, 0x000105, 0x000001, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x010105, 0x0f1331, 0x0e1d51, 0x071e55, 0x091d57, 0x0a1d58, 
0x0a1e57, 0x0b1c57, 0x091d57, 0x0b1d52, 0x0c183c, 0x0a0c14, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000001, 0x0e1d46, 0x081d57, 0x091e57, 0x091d57, 0x061c56, 0x081c56, 0x081d57, 
0x091d57, 0x081d57, 0x081d57, 0x091d56, 0x081d57, 0x091d56, 0x0d1e52, 0x0c101a, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x0d1430, 
0x0a1d5a, 0x081d57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x0d1e4e, 0x0a1d58, 
0x091e57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x081e57, 0x091d56, 0x071d57, 
0x0f1c43, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x102045, 0x081d57, 
0x081e57, 0x091e55, 0x091d57, 0x091e57, 0x091e57, 0x0b2257, 0xfdfbfc, 0x0a1c55, 
0x081d57, 0x061e57, 0x091d58, 0x091e57, 0x091d57, 0x081e55, 0x091e57, 0x081e57, 
0x091d58, 0x0c1b53, 0x06080a, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000001, 0x0c1b45, 0x091d58, 0x081e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091d58, 0xfdfdfd, 0xf8fbfe, 
0x031c51, 0x071e55, 0x1f2955, 0xeff5fb, 0x071a55, 0x091e58, 0x091e57, 0x091e57, 
0x091e57, 0x091d57, 0x0b1d51, 0x030405, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x0b1337, 0x051e52, 0x091d56, 0x091e57, 
0x091e57, 0x081d57, 0x071e57, 0x091d57, 0x091d57, 0x071c53, 0xfdfefe, 0xfdfdfb, 
0xfbfefe, 0xfcfdfd, 0xfdfcfa, 0x0d1d50, 0x0a2158, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091d58, 0x0c1e4e, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x080c15, 0x071c56, 0x081d57, 0x091e57, 0x091e57, 
0x091e57, 0x091d57, 0x081e56, 0x0a1d57, 0x14214c, 0xf2fafd, 0xfdfefe, 0xfefefe, 
0xffffff, 0xfdfefc, 0x717b94, 0x071e55, 0x091d57, 0x091e56, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x0b1730, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x091d50, 0x091d57, 0x091d57, 0x091e57, 0x091e57, 
0x091e57, 0x091d58, 0xbac5dc, 0xfbfcfe, 0xfcfafc, 0xfefdfd, 0xfefefe, 0xfefffe, 
0xffffff, 0xfefefd, 0x0b1d56, 0x091d57, 0x081d56, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091d54, 0x0d0d0e, 0x000000, 0x000000, 
0x000000, 0x000000, 0x0d0d15, 0x081d55, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091d57, 0x091e57, 0x0c1f5a, 0x0b1c55, 0x3e4d68, 0xfefefe, 0xfdfefe, 
0xffffff, 0xfdfefe, 0xfaf9fd, 0x091f55, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091d58, 0x091d57, 0x111639, 0x000000, 0x000000, 
0x000000, 0x000000, 0x0f1d48, 0x091d57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x081d56, 0x071d56, 0xfefefc, 0xfcfcfd, 
0x353e5b, 0xeef4fb, 0xfefefe, 0xf3f7fb, 0x051c53, 0x091d57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091d57, 0x091d5f, 0x010102, 0x000000, 
0x000000, 0x000000, 0x081c57, 0x091d58, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x081e57, 0xfcfdf8, 0xcdd8e7, 
0x041b52, 0x0a1c55, 0x061a53, 0x081c4d, 0x3d4a7d, 0x081e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e56, 0x081c57, 0x121216, 0x000000, 
0x000000, 0x09090a, 0x081d55, 0x091e56, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e5a, 0xfcfcfc, 0x081d55, 
0x091e56, 0x091e57, 0x081d56, 0x091d57, 0x071d56, 0x091d57, 0x091e57, 0x091e57, 
0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091e57, 0x091c58, 0x0a1429, 0x000000, 
0x000000, 0x0c101a, 0x081c57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 
0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x091e5a, 0x0f1e55, 0x091e58, 
0x091d57, 0x091e55, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 0x091d57, 
0x091d57, 0x091d57, 0x091d57, 0x091e57, 0x091d57, 0x091d56, 0x0f1a41, 0x000000, 
0x000000, 0x0a1225, 0x081d56, 0x091d56, 0x091d55, 0x091d56, 0x091d57, 0x091d57, 
0x091d57, 0x091d57, 0x091d57, 0x0a1d57, 0x091d57, 0x0a1d57, 0x0a1d57, 0x071e55, 
0x091d58, 0x0a1d58, 0x0b1c57, 0x0b1c57, 0x0a1c56, 0x0b1c57, 0x0b1c57, 0x0a1c56, 
0x0a1c56, 0x0b1c57, 0x0b1c57, 0x0a1d56, 0x0b1b58, 0x071c5a, 0x0d1e4b, 0x000000, 
0x000000, 0x35343c, 0xd9e1ee, 0xdadfee, 0xdbdfee, 0xdadfee, 0xdadfed, 0xdadfee, 
0xdadfee, 0xdadfed, 0xdadfee, 0xdbdfee, 0xdadfee, 0xd9e0ed, 0xdadfee, 0xdadeef, 
0x812f54, 0x842d53, 0x832f53, 0x832f53, 0x832f52, 0x832f53, 0x832f53, 0x832f52, 
0x832f52, 0x832f53, 0x832f53, 0x832f52, 0x843055, 0x872b58, 0x793353, 0x000000, 
0x000000, 0x1d1d1d, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfefefc, 
0xaf2640, 0xad2640, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xac2742, 0xb02642, 0x882b3d, 0x000000, 
0x000000, 0x0a0a0a, 0xfefefe, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xaf2541, 0x4a131b, 0x000000, 
0x000000, 0x000000, 0xfefefe, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xae2642, 0xaa2a40, 0x0e0f0b, 0x000000, 
0x000000, 0x000000, 0xfefefe, 0xfdfdfd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xac2641, 0xac2544, 0x050505, 0x000000, 
0x000000, 0x000000, 0x131313, 0xfdfdfd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xae2542, 0x822839, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0xfdfdfd, 0xfdfdfd, 0xffffff, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xad2742, 0xad2740, 0xac2641, 0x100e0e, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x171717, 0xfefefe, 0xfefefe, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xae2642, 0xac2742, 0xad2440, 0x712535, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0xe5e5e5, 0xfdfdfd, 0xffffff, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2742, 0xad2742, 0xae2642, 0xa22b41, 0x020203, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xfefefe, 0xfefefe, 0xffffff, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 
0xad2643, 0xae2641, 0xaa2642, 0x100c0c, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xfdfdfd, 0xfdfdfd, 
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2742, 0xad2642, 
0xad2743, 0xa92942, 0x150c0c, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xc5c5c5, 
0xfdfdfd, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xae2640, 0xad2740, 0xad2742, 0xad2642, 0xad2642, 0xad2642, 0xad2742, 0xad2741, 
0xa23047, 0x0e0808, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x0d0d0d, 0xfafafa, 0xfefefe, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xfdfdfc, 
0xaf2640, 0xad2740, 0xad2843, 0xaf2744, 0xad2642, 0xaf2843, 0xaa2743, 0x340410, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x090909, 0xededed, 0xfbfbfb, 0xfefefe, 0xfefefe, 0xfdfdfc, 
0xae2640, 0xac2840, 0xac2744, 0xab2740, 0x9c3045, 0x30090f, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x070707, 0x141414, 
0x2b080b, 0x1c0306, 0x0d0405, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000001, 0x000000, 0x000000, 0x000000, 
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};

//
// Loop function
//

void loop() {

  for (int loop=0; loop<=31; loop++) {
    for (int y=0; y<=31; y++) {
      for (int x=0; x<=31; x++) {
        int colorIndex = (((y*32) + x) + (loop*32)) % 1024;
        matrix.drawPixel(x,y,logoColors[colorIndex]); 
      } 
    }
    matrix.show();
    delay(Delay);
  }
}


void buildLogo() {

  int index=0;
  long colors;
  int colorR;
  int colorG;
  int colorB;

  for (int i=0; i<=1023; i++) {
    colors = rawHexColors[index];  
    colorR = colors / 0x10000;
    colors = colors % 0x10000;
    colorG = colors / 0x100;
    colorB = colors % 0x100;

    logoColors[index] = matrix.Color(colorR, colorG, colorB);
    index++;
  }

}
X Coordinate -->
Y Coordinate -->