#include <FastLED.h>

// How many leds in your strip?
//#define NUM_LEDS 64
enum XY_matrix_config { SERPENTINE = 1, ROWMAJOR = 2, FLIPMAJOR = 4, FLIPMINOR = 8 };

// MAX_MILLIWATTS can only be changed at compile-time. Use 0 to disable limit.
// Brightness can be changed at runtime via serial with 'b' and 'B'
#define MAX_MILLIWATTS 0
#define BRIGHTNESS     255
#define LED_PIN        15
#define COLOR_ORDER    GRB
#define CHIPSET        WS2812B
#define kMatrixWidth   16
#define kMatrixHeight  16
#define XY_MATRIX      (ROWMAJOR)
#define NUM_LEDS       ((kMatrixWidth) * (kMatrixHeight))

#define SERIAL_UI      1    // if 1, can be controlled via keypresses in PuTTY
#define FADEIN_FRAMES  32   // how long to reach full brightness when powered on
#define MS_GOAL        20   // to try maintain 1000 / 20ms == 50 frames per second

#define GIF2H_MAX_PALETTE_ENTRIES 140 // RAM is always tight on ATmega328...
#define GIF2H_NUM_PIXELS NUM_LEDS     // all images must be the same size as the matrix

CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette;

// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define DATA_PIN 2

// Define the array of leds
//CRGB leds[NUM_LEDS];
 
void setup() {
  // put your setup code here, to run once:
  //  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); 
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
 // FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS); 
 FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);

    if (SERIAL_UI == 1) {
    Serial.begin(115200);
    halp();
  }
 
}

void sondur(){

 for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Black;
    FastLED.show();
  }
   

}

void yak(uint8_t num){
 leds[num] = CRGB(0, 255, 42);
  // FastLED.show();
}

void fill_Blue(){

   for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Blue;
  }
}


void loop() {
  // put your main code here, to run repeatedly:
 //fill_solid(leds, NUM_LEDS, CHSV(0, 0, 255));
 //fill_Blue();
  for (int i = 0; i < NUM_LEDS +1; i++) {
 yak(i);
  }
 
    FastLED.show();
   
 
 
}



void halp() {
  Serial.println(F(" #\trandomise rainbow smoothie\r\n"
                   " ~\tchoose next preset for rainbow smoothie\r\n"
                   " <enter>\tprint parameters\r\n"
                   " e\tswitch to next Effect\r\n"
                   " p\tswitch to next palette\r\n"
                   " {}\tturn extended palette blending on/off\r\n"
                   " []\tturn linear palette blending on/off\r\n"
                   " ,.<>\tchange colour cycling rate\r\n"
                   " bB\tbrightness down/up\r\n"
                   " dD\tbinary dither off/on\r\n"
                   " fF\tdecrease/increase fade out rate\r\n"));
}

cd74hc4067Breakout
cd74hc4067Breakout
cd74hc4067Breakout