#ifndef PALETTES_H_
#define PALETTES_H_

CRGBPalette16 currentPalette;
TBlendType    currentBlending;
CRGBPalette16 flowersPalette;
CRGBPalette16 leavesPalette;

int flowerLeds[] = {2,3,4,5,6,7,10,11,12,13,14,15,18,19,20,21,22,23};
int leaveLeds[] = {0,1,8,9,16,17};

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
  uint8_t brightness = 255;

  int flowerLedSize = sizeof flowerLeds / sizeof *flowerLeds;
  for( int i = 0; i < flowerLedSize; i++) {
    leds[flowerLeds[i]] = ColorFromPalette( flowersPalette, colorIndex, brightness, currentBlending);
    colorIndex += 3;
  }
  int leaveLedSize = sizeof leaveLeds / sizeof *leaveLeds;
  for( int i = 0; i < leaveLedSize; i++) {
    leds[leaveLeds[i]] = ColorFromPalette( leavesPalette, colorIndex, brightness, currentBlending);
	  colorIndex += 3;
  }
}

// Gradient palette "Analogous_1_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
    0,   3,  0,255,
   63,  23,  0,255,
  127,  67,  0,255,
  191, 142,  0, 45,
  255, 255,  0,  0};

// Gradient palette "bhw2_greenman_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/bhw/bhw2/tn/bhw2_greenman.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 12 bytes of program space.

DEFINE_GRADIENT_PALETTE( bhw2_greenman_gp ) {
    0,   1, 22,  1,
  130,   1,168,  2,
  255,   1, 22,  1};

// Gradient palette "cw2_050_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/cw/2/tn/cw2-050.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 12 bytes of program space.

DEFINE_GRADIENT_PALETTE( cw2_050_gp ) {
    0, 175, 21, 11,
  127,   5, 28, 79,
  255,  94,173,219};

// Gradient palette "cw2_046_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/cw/2/tn/cw2-046.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 12 bytes of program space.

DEFINE_GRADIENT_PALETTE( cw2_046_gp ) {
    0,   4, 12,  7,
  127,   9, 40,  6,
  255,  45, 67,  5};

// Gradient palette "Ribbon_Colors_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/icons/tn/Ribbon-Colors.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.

DEFINE_GRADIENT_PALETTE( Ribbon_Colors_gp ) {
    0, 227,  2,  9,
   31, 194, 51,  9,
   63, 167,175,  8,
   95,  27,209, 78,
  127,   1,248,247,
  159,   1, 78,166,
  191,   1,  5,102,
  223,  42, 79, 18,
  255, 255,255,  0};

// Gradient palette "es_emerald_dragon_08_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
    0,  97,255,  1,
  101,  47,133,  1,
  178,  13, 43,  1,
  255,   2, 10,  1};


// Gradient palette "gr65_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
    0, 247,176,247,
   48, 255,136,255,
   89, 220, 29,226,
  160,   7, 82,178,
  216,   1,124,109,
  255,   1,124,109};

// Gradient palette "bhw2_21_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/bhw/bhw2/tn/bhw2_21.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 12 bytes of program space.

DEFINE_GRADIENT_PALETTE( bhw2_21_gp ) {
    0, 109,252,125,
  119,   7,255,  8,
  255,   1, 23,  1};

// Gradient palette "es_rosa_70_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rosa/tn/es_rosa_70.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_rosa_70_gp ) {
    0, 113,  1,  1,
   76, 113,  1, 12,
  140, 113,  1, 37,
  204, 137,  1, 87,
  255, 142,  4,137};

// Gradient palette "GPS_Nature_Pure_Greens_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/gps/tn/GPS-Nature-Pure-Greens.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( GPS_Nature_Pure_Greens_gp ) {
    0,  24, 86, 10,
   48,  18, 63,  4,
   82,  13, 45,  1,
  121,   6, 22,  1,
  161,   1,  8,  1,
  208,   1,  2,  1,
  255,   0,  1,  0};

// Gradient palette "ryb_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/grass/tn/ryb.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 12 bytes of program space.

DEFINE_GRADIENT_PALETTE( ryb_gp ) {
    0, 255,  0,  0,
  127, 255,255,  0,
  255,   0,  0,255};

// Gradient palette "apple_green_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ocal/tn/apple-green.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 8 bytes of program space.

DEFINE_GRADIENT_PALETTE( apple_green_gp ) {
    0,   0, 55,  0,
  255, 117,161,  1};



void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;

    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  {
        	flowersPalette = Analogous_1_gp;
        	leavesPalette = bhw2_greenman_gp;
        	currentBlending = LINEARBLEND;
        }
        if( secondHand == 10)  {
        	flowersPalette = cw2_050_gp;
        	leavesPalette = cw2_046_gp;
        	currentBlending = LINEARBLEND;
        }
        if( secondHand == 20)  {
        	flowersPalette = Ribbon_Colors_gp;
        	leavesPalette = es_emerald_dragon_08_gp ;
        	currentBlending = LINEARBLEND;
        	 }
        if( secondHand == 30)  {
        	flowersPalette = gr65_hult_gp;
        	leavesPalette = bhw2_21_gp;
        	currentBlending = LINEARBLEND;

        }
        if( secondHand == 40)  {
        	flowersPalette =  es_rosa_70_gp;
        	leavesPalette = GPS_Nature_Pure_Greens_gp;
        	currentBlending = LINEARBLEND;
        }
        if( secondHand == 50)  {
        	flowersPalette =  ryb_gp;
        	leavesPalette = apple_green_gp;
        	currentBlending = LINEARBLEND;
        }
    }
}

#endif /* PALETTES_H_ */

