//
// NeoPixel light decoration or call it what you want.
//
// Jan5412
//
// Dit programma is een combinatie van diverse NeoPixel effecten die te vinden
// zijn op internet samengevoegd in een kleur pallet met infrarood afstandsbediening.
//
// arduino-1.8.2

#include "FastLED.h"                         // Bibliotheek FastLED op versie 3.3.3
#include <EEPROM.h>                          // Bibliotheek EEPROM-master op versie 2.0
#include <IRremote.h>                        // Bibliotheek Arduino-IRremote-master op versie 2.0.1

#define FASTLED_USE_PROGMEM 1
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 200
CRGB leds[NUM_LEDS];

#define DATA_PIN 4                           // data pin for NeoPixels

#define IR_INTERRUPT  0                      // interrupt number associated with pin 2
//#define IR_Pin 2                           // pin D2 or D3 on standard arduinos mini pro.
#define Radar_INTERRUPT  1                   // interrupt number associated with pin 3 -- RCWL-0516 Radar Microwave Motion Sensor
#define MosFet_PIN  9                        // output pin to mosfet power for NeoPixels
#define IR_LED  10                           // led die aangaat bij ontvangen van interrupt signaal en uitgaat als IR bediening mogelijk is
#define TipToets_Pin  12                     // tiptoets I/O pin 12

unsigned long startTime_leds_on = millis();  // start tijd radar
byte radar_control = 1;                      // te nemen actie 1 = beweging dus start timer opnieuw, 2 = controlle tijd tussen beweging en uitzetten, 3 = uit dus niets doen

const int buzzer = 11;                       // buzzer I/O pin 11


const byte HSTM[75][16] PROGMEM = {
    {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {2,1,2,3,1,2,3,2,0,1,0,3,1,0,3,0},
    {1,1,2,2,1,1,2,2,0,0,3,3,0,0,3,3},
    {2,1,2,3,1,1,2,2,0,0,3,3,1,0,3,0},
    {3,3,0,0,3,0,1,0,2,3,2,1,2,2,1,1},
    {0,0,2,1,1,0,1,1,3,3,2,3,3,0,2,2},
    {3,1,2,0,1,1,2,2,0,0,3,3,2,0,3,1},
    {2,0,3,3,2,2,3,1,3,1,0,0,1,1,2,0},
    {1,2,2,2,1,1,2,3,1,0,3,3,0,0,0,3},
    {2,2,3,3,2,3,0,3,1,2,1,0,1,1,0,0},
    {3,3,1,0,0,3,0,0,2,2,1,2,2,3,1,1},
    {2,3,3,3,2,2,3,0,2,1,0,0,1,1,1,0},
    {1,0,1,2,0,0,1,1,3,3,2,2,0,3,2,3},
    {2,2,2,3,1,1,2,3,1,0,3,3,1,0,0,0},
    {3,3,1,0,0,0,1,0,2,3,2,2,2,3,1,1},
    {3,2,2,0,1,1,2,3,1,0,3,3,2,0,0,1},
    {2,0,3,3,2,3,0,1,3,2,1,0,1,1,2,0},
    {3,3,0,0,3,1,2,0,2,0,3,1,2,2,1,1},
    {3,3,1,0,0,1,2,3,2,0,3,2,2,3,1,1},
    {1,0,3,2,2,0,1,1,3,3,2,0,0,1,2,3},
    {0,2,2,1,1,1,2,3,1,0,3,3,3,0,0,2},
    {2,1,3,3,2,3,0,2,0,2,1,0,1,1,3,0},
    {3,0,3,0,2,3,0,1,3,2,1,0,2,1,2,1},
    {1,0,0,2,3,0,1,1,3,3,2,1,0,2,2,3},
    {1,3,2,2,1,1,2,0,2,0,3,3,0,0,1,3},
    {2,2,3,3,2,0,1,3,1,3,2,0,1,1,0,0},
    {2,0,1,3,0,0,1,1,3,3,2,2,1,3,2,0},
    {2,3,2,3,1,1,2,0,2,0,3,3,1,0,1,0},
    {2,3,3,3,2,0,1,0,2,3,2,0,1,1,1,3},
    {3,3,2,0,1,0,1,0,2,3,2,3,2,0,1,1},
    {2,0,2,3,1,0,1,1,3,3,2,3,1,0,2,0},
    {3,3,2,0,1,1,2,3,2,0,3,3,2,0,1,1},
    {2,0,3,3,2,0,1,1,3,3,2,0,1,1,2,0},
    {0,3,2,1,1,1,2,3,2,0,3,3,3,0,1,2},
    {2,1,3,3,2,0,1,2,0,3,2,0,1,1,3,0},
    {3,3,2,0,1,2,3,0,2,1,0,3,2,0,1,1},
    {2,2,3,3,2,2,3,3,1,1,0,0,1,1,0,0},
    {2,0,0,3,3,0,1,1,3,3,2,1,1,2,2,0},
    {2,0,2,3,1,1,2,1,3,0,3,3,1,0,2,0},
    {2,3,3,3,2,1,2,0,2,0,3,0,1,1,1,3},
    {3,3,3,0,2,0,1,0,2,3,2,3,2,1,1,1},
    {3,0,2,0,1,0,1,1,3,3,2,3,2,0,2,1},
    {3,0,2,0,1,1,2,1,3,0,3,3,2,0,2,1},
    {2,0,3,3,2,1,2,1,3,0,3,0,1,1,2,0},
    {3,3,3,0,2,1,2,0,2,0,3,0,2,1,1,1},
    {3,0,3,0,2,0,1,1,3,3,2,0,2,1,2,1},
    {0,0,2,1,1,1,2,1,3,0,3,3,3,0,2,2},
    {3,3,3,0,2,2,3,0,2,1,0,0,2,1,1,1},
    {1,3,3,2,2,0,1,0,2,3,2,0,0,1,1,3},
    {3,1,2,0,1,2,3,2,0,1,0,3,2,0,3,1},
    {2,0,0,3,3,2,3,1,3,1,0,1,1,2,2,0},
    {0,3,0,1,3,1,2,0,2,0,3,1,3,2,1,2},
    {0,1,3,1,2,0,1,2,0,3,2,0,3,1,3,2},
    {0,1,2,1,1,2,3,2,0,1,0,3,3,0,3,2},
    {2,1,0,3,3,2,3,2,0,1,0,1,1,2,3,0},
    {0,3,0,1,3,2,3,0,2,1,0,1,3,2,1,2},
    {0,1,0,1,3,0,1,2,0,3,2,1,3,2,3,2},
    {0,3,2,1,1,2,3,0,2,1,0,3,3,0,1,2},
    {3,0,2,0,1,2,3,1,3,1,0,3,2,0,2,1},
    {2,0,0,3,3,1,2,1,3,0,3,1,1,2,2,0},
    {3,1,2,0,1,3,0,2,0,2,1,3,2,0,3,1},
    {2,0,1,3,0,2,3,1,3,1,0,2,1,3,2,0},
    {3,2,2,0,1,3,0,3,1,2,1,3,2,0,0,1},
    {2,0,1,3,0,3,0,1,3,2,1,2,1,3,2,0},
    {1,3,1,2,0,1,2,0,2,0,3,2,0,3,1,3},
    {1,2,3,2,2,0,1,3,1,3,2,0,0,1,0,3},
    {2,0,2,3,1,3,0,1,3,2,1,3,1,0,2,0},
    {3,3,1,0,0,2,3,0,2,1,0,2,2,3,1,1},
    {2,3,2,3,1,0,1,0,2,3,2,3,1,0,1,0},
    {1,2,3,2,2,1,2,3,1,0,3,0,0,1,0,3},
    {3,2,3,0,2,1,2,3,1,0,3,0,2,1,0,1},
    {1,0,3,2,2,1,2,1,3,0,3,0,0,1,2,3},
    {3,0,3,0,2,1,2,1,3,0,3,0,2,1,2,1},
    {1,0,3,2,2,3,0,1,3,2,1,0,0,1,2,3}
};

static const byte m_leds[9][NUM_LEDS] PROGMEM {

// array row 0 is elke rij van links naar rechts horizontaal dit o.a. voor triangles
{   0,1,2,3,4,5,6,7,8,9,19,18,17,16,15,14,13,12,11,10,
    20,21,22,23,24,25,26,27,28,29,39,38,37,36,35,34,33,32,31,30,
    40,41,42,43,44,45,46,47,48,49,59,58,57,56,55,54,53,52,51,50,
    60,61,62,63,64,65,66,67,68,69,79,78,77,76,75,74,73,72,71,70,
    80,81,82,83,84,85,86,87,88,89,99,98,97,96,95,94,93,92,91,90,
    100,101,102,103,104,105,106,107,108,109,119,118,117,116,115,114,113,112,111,110,
    120,121,122,123,124,125,126,127,128,129,139,138,137,136,135,134,133,132,131,130,
    140,141,142,143,144,145,146,147,148,149,159,158,157,156,155,154,153,152,151,150,
    160,161,162,163,164,165,166,167,168,169,179,178,177,176,175,174,173,172,171,170,
    180,181,182,183,184,185,186,187,188,189,199,198,197,196,195,194,193,192,191,190 }, 

// array row 1 is rij van links naar rechts naar links enz. horizontaal zoals de leds hardware matig verbonden zijn dus hetzelfde al leds[NUM_LEDS]
{   0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
    20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,
    40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,
    60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
    80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
    100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,
    120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,
    140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
    160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,
    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194, 195,196,197,198,199 },

// array row 2 is elke kolom vertikaal van boven naar beneden
{   0,    19,    20,    39,    40,    59,    60,    79,    80,    99,   100,   119,   120,   139,   140,   159,   160,   179,   180,   199,
    1,    18,    21,    38,    41,    58,    61,    78,    81,    98,   101,   118,   121,   138,   141,   158,   161,   178,   181,   198,
    2,    17,    22,    37,    42,    57,    62,    77,    82,    97,   102,   117,   122,   137,   142,   157,   162,   177,   182,   197,
    3,    16,    23,    36,    43,    56,    63,    76,    83,    96,   103,   116,   123,   136,   143,   156,   163,   176,   183,   196,
    4,    15,    24,    35,    44,    55,    64,    75,    84,    95,   104,   115,   124,   135,   144,   155,   164,   175,   184,   195,
    5,    14,    25,    34,    45,    54,    65,    74,    85,    94,   105,   114,   125,   134,   145,   154,   165,   174,   185,   194,
    6,    13,    26,    33,    46,    53,    66,    73,    86,    93,   106,   113,   126,   133,   146,   153,   166,   173,   186,   193,
    7,    12,    27,    32,    47,    52,    67,    72,    87,    92,   107,   112,   127,   132,   147,   152,   167,   172,   187,   192,
    8,    11,    28,    31,    48,    51,    68,    71,    88,    91,   108,   111,   128,   131,   148,   151,   168,   171,   188,   191,
    9,    10,    29,    30,    49,    50,    69,    70,    89,    90,   109,   110,   129,   130,   149,   150,   169,   170,   189,   190 },

// array row 3 is vertikaal van links boven naar beneden en weer naar boven  -- op en neer
{   0,19,20,39,40,59,60,79,80,99,100,119,120,139,140,159,160,179,180,199,
    198,181,178,161,158,141,138,121,118,101,98,81,78,61,58,41,38,21,18,1,
    2,17,22,37,42,57,62,77,82,97,102,117,122,137,142,157,162,177,182,197,
    196,183,176,163,156,143,136,123,116,103,96,83,76,63,56,43,36,23,16,3, 
    4,15,24,35,44,55,64,75,84,95,104,115,124,135,144,155,164,175,184,195,
    194,185,174,165,154,145,134,125,114,105,94,85,74,65,54,45,34,25,14,5,
    6,13,26,33,46,53,66,73,86,93,106,113,126,133,146,153,166,173,186,193,
    192,187,172,167,152,147,132,127,112,107,92,87,72,67,52,47,32,27,12,7,
    8,11,28,31,48,51,68,71,88,91,108,111,128,131,148,151,168,171,188,191,
    190,189,170,169,150,149,130,129,110,109,90,89,70,69,50,49,30,29,10,9 },

// array row 4 is vertikaal van links boven naar beneden en weer naar boven per halve rij  -- op en neer
{   19,20,59,60,99,100,139,140,179,180,199,160,159,120,119,80,79,40,39,0,
    1,38,41,78,81,118,121,158,161,198,181,178,141,138,101,98,61,58,21,18,
    17,22,57,62,97,102,137,142,177,182,197,162,157,122,117,82,77,42,37,2,
    3,36,43,76,83,116,123,156,163,196,183,176,143,136,103,96,63,56,23,16,
    15,24,55,64,95,104,135,144,175,184,195,164,155,124,115,84,75,44,35,4,
    5,34,45,74,85,114,125,154,165,194,185,174,145,134,105,94,65,54,25,14,
    13,26,53,66,93,106,133,146,173,186,193,166,153,126,113,86,73,46,33,6,
    7,32,47,72,87,112,127,152,167,192,187,172,147,132,107,92,67,52,27,12,
    11,28,51,68,91,108,131,148,171,188,191,168,151,128,111,88,71,48,31,8,
    9,30,49,70,89,110,129,150,169,190,189,170,149,130,109,90,69,50,29,10 },

// array row 5 is vanuit het midden clock wijs rond -- CW
{   85,94,105,114,115,104,95,84,75,74,65,66,73,86,93,106,113,126,133,134,
    125,124,135,136,123,116,103,96,83,76,63,64,56,55,44,45,54,53,46,47,52,
    67,72,87,92,107,112,127,132,147,152,153,146,145,154,155,144,143,156,
    157,142,137,122,117,102,97,82,77,62,57,42,43,37,36,23,24,35,34,25,26,
    33,32,27,28,31,48,51,68,71,88,91,108,111,128,131,148,151,168,171,172,
    167,166,173,174,165,164,175,176,163,162,177,178,161,158,141,138,121,
    118,101,98,81,78,61,58,41,38,21,22,18,17,2,3,16,15,4,5,14,13,6,7,12,11,
    8,9,10,29,30,49,50,69,70,89,90,109,110,129,130,149,150,169,170,189,190,
    191,188,187,192,193,186,185,194,195,184,183,196,197,182,181,198,199,
    180,179,160,159,140,139,120,119,100,99,80,79,60,59,40,39,20,19,0,1 },

// array row 6 is vanuit het midden clock tegen rond -- CC
{   84,95,104,115,114,105,94,85,74,75,96,103,124,125,106,93,65,64,83,116,
    135,134,113,86,73,66,54,55,63,76,82,117,123,136,144,145,133,126,112,
    87,72,53,45,44,56,77,97,102,122,143,155,154,146,127,107,92,67,46,34,
    35,43,62,98,101,137,156,164,165,153,132,108,91,88,71,68,52,47,33,26,25,
    24,23,36,42,57,61,78,81,118,121,138,142,157,163,176,175,174,173,166,
    152,147,131,128,111,89,70,51,32,13,14,15,16,37,58,79,80,119,120,141,
    162,183,184,185,186,167,148,129,110,109,90,69,48,27,6,5,4,3,22,41,60,
    99,100,139,158,177,196,195,194,193,172,151,130,50,49,31,28,12,7,2,17,
    21,38,40,59,140,159,161,178,182,197,192,187,171,168,150,149,30,11,18,
    39,160,181,188,169,29,8,1,20,179,198,191,170,10,9,0,19,180,199,190,189 },

// array row 7 is vanlinks onder schuin naar rechts boven
{   180,199,198,179,160,181,197,182,178,161,159,140,139,158,177,196,183,
    162,141,120,100,119,121,138,142,157,163,176,184,195,194,175,156,137,
    118,99,80,101,122,143,164,185,193,186,174,165,155,144,136,123,117,
    102,98,81,79,60,59,78,97,116,135,154,173,192,187,166,145,124,103,82,
    61,40,20,39,41,58,62,77,83,96,104,115,125,134,146,153,167,172,188,191,
    190,171,152,133,114,95,76,57,38,19,0,21,42,63,84,105,126,147,168,189,
    170,169,151,148,132,127,113,106,94,85,75,64,56,43,37,22,18,1,17,36,55,
    74,93,112,131,150,149,128,107,86,65,44,23,2,3,16,24,35,45,54,66,73,87,
    92,108,111,129,130,110,91,72,53,34,15,4,25,46,67,88,109,90,89,71,68,52,
    47,33,26,14,5,13,32,51,70,69,48,27,6,7,12,28,31,49,50,30,11,8,29,10,9 },

// array row 8 is vanrechts onder schuin naar links boven
{   189,190,191,170,169,188,192,187,171,168,150,149,130,151,172,193,186,
    167,148,129,109,110,128,131,147,152,166,173,185,194,195,174,153,132,
    111,90,89,108,127,146,165,184,196,183,175,164,154,145,133,126,112,107,
    91,88,70,69,50,71,92,113,134,155,176,197,182,163,144,125,106,87,68,49,
    29,30,48,51,67,72,86,93,105,114,124,135,143,156,162,177,181,198,199,
    178,157,136,115,94,73,52,31,10,9,28,47,66,85,104,123,142,161,180,179,
    160,158,141,137,122,116,103,95,84,74,65,53,46,32,27,11,8,12,33,54,75,
    96,117,138,159,140,121,102,83,64,45,26,7,6,13,25,34,44,55,63,76,82,97,
    101,118,120,139,119,98,77,56,35,14,5,24,43,62,81,100,99,80,78,61,57,
    42,36,23,15,4,16,37,58,79,60,41,22,3,2,17,21,38,40,59,39,18,1,20,19,0 }

};

// array smiley
static const byte s_leds[48] PROGMEM {  
    19,0,9,10,189,190,199,180,20,1,8,29,170,191,198,179,39,
    18,11,30, 42,43,56,63,76,77,62,57, 46,47,52,67,72,73,66,
    53,127,146,154,155,143,122,123,136,144,145,133,126 };


static const byte hst_cell_offset[] PROGMEM = {21, 22, 32, 42, 52, 51, 41, 31, 21, 22, 32, 42, 52, 51, 41, 31};
static const byte hst_cell_origin[] PROGMEM = {0, 2, 4, 6, 40, 42, 44, 46, 80, 82, 84, 86, 120, 122, 124, 126};

byte hst_cell_position[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //array for intermediary hst positions
byte animation_steps[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //how many animation steps between start and end position
byte orig;

CHSV colorStart;                                  // starting color
CHSV colorTarget;                                 // target color
CHSV colorCurrent1 = colorStart;
CHSV colorCurrent2 = colorTarget;

byte modelNumber = 0;
byte last_animations[10];                         // array van de laatste 10 waarden
byte k = 0;
byte selectedEffect = 1;                          // case   nummer van effect in main loop 1 t/m 9


// ***** case 0 ***** algemene instellingen **************************************************************************************************
bool color_soft = false;                          // kleur aanpassing
byte BRIGHTNESS = 160;
byte multiplier_interval_leds_on = 9;             // in stappen van 1 t/m 20 maal 100.000 milliseconde ( 100 sec ) dus van 100 tot 2000 sec is 1,66 min tot 33 min

// ***** case 1 ***** triangles **************************************************************************************************************
byte number_of_animation = 4;                     // aantal waarna er een nieuwe kleur komt
byte animation_time = 5;                          // 1 t/m 20 maal 30 sec dus 30 sec tot 10 min instelbaar
byte speedup = 0;                                 // init speed
bool boarder = false;                             // true;
bool color_update_triangles_start  = false;       // true or false triangles kleurupdate 
bool color_update_triangles_target = false;       // true or false triangles kleurupdate 
bool update_in_triangles = false;                 // aanpassing gedaan in triangles via remote control
#define blendRate 25                              // How fast to blend.  Higher is slower.  [milliseconds]

// ***** case 2 ***** ColorWavesWithPalettes ************************************************************************************************
byte SECONDS_PER_PALETTE = 10;                    // ten seconds per color palette makes a good demo 20-120 is better for deployment
byte selected_raster_colorwaves = 5;              // welk raster
bool colorwaves_pride = true;                     // colorwaves or pride

// ***** case 3 ***** Smiley_Smill **********************************************************************************************************
bool smiley_true = true;                          // true = sliley false = random snelle chaos

// ***** case 4 ***** ChangePalettePeriodically *********************************************************************************************
byte interval_change_palette = 10;                // tijd instelling 1 t/m 20 is 10 tot 200 seconde
bool multiplier_flag = true;                      // random of vaste tijd instelling

// ***** case 5 ***** full_rainbow_color ****************************************************************************************************
byte time_full_rainbow_color = 20;                // time random kleur instelling 1 = 16 sec met max van 20 = 250 sec
bool color_fix = false;                           // full color palette fixed or random collor
byte color_Fix_number = 1;                        // kleur instelling full collor zie kleur spectrum
byte nr_rainbow_colors = 0;                       // bij nr_rainbow_colors = 1 verkleurd het gehele vlak langzaam

// ***** case 6 ***** chaos *****************************************************************************************************************
bool quickly_fill_chaos = true ;                  // snel opvullen 
byte chaos_speed = 1;                             // nr 1 of 3 of 5 werken en geven verkleuring snelheid

// ***** case 7 ***** Fire2012WithPalette ***************************************************************************************************
bool fire_fire = true;                            // true = fire and false = random pallet color

// ***** case 8 ***** FixBeeld **************************************************************************************************************
byte selected_beeld_effect = 1;                   // random van min tot max beeld effect
byte SECONDS_PER_beeld = 1;                       // tijd instelling 1 t/m 20 is 10 tot 200 seconde

// ***** case 9 ***** juggle ****************************************************************************************************************
byte selected_juggle_effect = 1;                  // instelling
byte dothue =  0; 

//-------------------------------------------------
//    Define your own buttons here for SAMSUNG code
//-------------------------------------------------

#define button_r    0x898943BC        // button >  => 
#define button_fw   0x898941BE        // button /\ => 
#define button_l    0x898944BB        // button <  => 
#define button_rv   0x898942BD        // button \/ => 
#define button_ok   0x898940BF        // button ok => 

#define button_1    0x898951AE        // button 1 => Triangles
#define button_2    0x898952AD        // button 2 => ColorWavesWithPalettes
#define button_3    0x898953AC        // button 3 => smiley
#define button_4    0x898954AB        // button 4 => ChangePalettePeriodically
#define button_5    0x898955AA        // button 5 => full_rainbow_color
#define button_6    0x898956A9        // button 6 => chaos
#define button_7    0x898957A8        // button 7 => Fire2012WithPalette
#define button_8    0x898958A7        // button 8 => FixBeeld
#define button_9    0x898959A6        // button 9 => juggle
#define button_0    0x898950AF        // button 0 => algemeen instellingen
//#define button_11   0x898941BE      // button 11 => 

//#define herhaal_c   0xFFFFFFFF      // geen buttom maar herhaal code
  
//--------------------------------------------
//    End define your own buttons
//--------------------------------------------


volatile bool IRcontrol = false;   // for switch

const int IR_Pin = 2;
const int Radar_Pin = 3;

/*-----( Declare objects )-----*/
IRrecv irrecv(IR_Pin);             // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'
unsigned long lastCode;            // stores last code received


// Forward declarations of an array of cpt-city gradient palettes, and 
// a count of how many there are.  The actual color palette definitions
// are at the bottom of this file.
extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
extern const uint8_t gGradientPaletteCount;                              // Count of how many cpt-city gradients are defined

// Current palette number from the 'playlist' of color palettes
uint8_t gCurrentPaletteNumber = 0;

CRGBPalette16 gCurrentPalette( CRGB::Black);                            // CRGB::Black = CRGB(0,0,0)
CRGBPalette16 gTargetPalette( gGradientPalettes[0] );

TBlendType    currentBlending;

uint8_t gHue = 0;                                                      // rotating "base color" used by many of the patterns

//--------------------------------
//  *** begin void setup ***
//--------------------------------

void setup()
{
  Serial.begin(9600);
  
  delay(3000); // 3 second delay for recovery

//  tell FastLED about the LED strip configuration -- een output voor alle leds
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050); //.setCorrection(TypicalLEDStrip); 

  FastLED.setBrightness(BRIGHTNESS);
//  set_max_power_in_volts_and_milliamps(5, 800); // FastLED Power management set at 5V, 800 mA.  
  FastLED.setMaxPowerInVoltsAndMilliamps(5,3500); // FastLED Power management set at 5V, 3500 mA.  

  pinMode(2,INPUT_PULLUP);                        // internal pull-up resistor
  pinMode(Radar_INTERRUPT, INPUT_PULLUP);         // configure Radar_INTERRUPT as an input and enable the internal pull-up resistor.
  pinMode(TipToets_Pin,INPUT_PULLUP);             // internal pull-up resistor
  
  pinMode(buzzer, OUTPUT);                        // Set buzzer - pin 11 as an output
  pinMode(IR_LED, OUTPUT);                        // Set IR_LED - pin 10 as an output
  pinMode(MosFet_PIN, OUTPUT);                    // configure MosFet_PIN as an output.

  digitalWrite(IR_LED, LOW);                      // turn IR_LED off
  digitalWrite(MosFet_PIN, HIGH);                 // turn MosFet on what set the power to the NeoPixels on.


//  detachInterrupt(digitalPinToInterrupt(IR_Pin));                                      //stop interrupts & capture until finshed here
      EIFR = 0b00000011;
  attachInterrupt (digitalPinToInterrupt (IR_Pin), Interrupt_Handler, LOW);              //set up ISR for receiving IR signal  CHANGE - LOW - RISING
  attachInterrupt (digitalPinToInterrupt (Radar_Pin), Interrupt_RadarSensor, RISING);    //set up ISR for receiving RadarSensor signal  CHANGE - LOW - RISING
  irrecv.enableIRIn();                                                                   // Start the receiver


  gCurrentPalette = RainbowColors_p;
  currentBlending = LINEARBLEND;

     // Configere EEPROM.

////   om waarden de eerste keer de EEPROM te vullen dus eenmalig uitvoeren
//  EEPROM.put(00, selectedEffect);
//
//  EEPROM.put(03, boarder);
//  EEPROM.put(04, number_of_animation);
//  EEPROM.put(05, animation_time);
//  EEPROM.put(06, color_update_triangles_start);
//  EEPROM.put(07, color_update_triangles_target);
//  
//  EEPROM.put(10, color_Fix_number);
//  EEPROM.put(11, time_full_rainbow_color);
//  EEPROM.put(12, nr_rainbow_colors);
//  EEPROM.put(13, color_fix);
//  
//  EEPROM.put(16, chaos_speed);
//  EEPROM.put(17, quickly_fill_chaos);
//  
//  EEPROM.put(19, color_soft);
//  EEPROM.put(20, BRIGHTNESS);
//  EEPROM.put(21, multiplier_interval_leds_on );
//
//  EEPROM.put(23, interval_change_palette);
//  EEPROM.put(27, multiplier_flag);
//
//  EEPROM.put(30, selected_juggle_effect);
//
//  EEPROM.put(33, fire_fire);
//
//  EEPROM.put(37, selected_beeld_effect);
//  EEPROM.put(38, SECONDS_PER_beeld);
//
//  EEPROM.put(42, SECONDS_PER_PALETTE);
//  EEPROM.put(43, selected_raster_colorwaves);
//  EEPROM.put(44, colorwaves_pride);
//
//  EEPROM.put(48, smiley_true);
//    
//  delay(500);


//  Serial.println("Read from EEPROM");

  EEPROM.get(00, selectedEffect);
  
  EEPROM.get(03, boarder);
  EEPROM.get(04, number_of_animation);
  EEPROM.get(05, animation_time);
  EEPROM.get(06, color_update_triangles_start);
  EEPROM.get(07, color_update_triangles_target);
  
  EEPROM.get(10, color_Fix_number);
  EEPROM.get(11, time_full_rainbow_color);
  EEPROM.get(12, nr_rainbow_colors);
  EEPROM.get(13, color_fix);
  
  EEPROM.get(16, chaos_speed);
  EEPROM.get(17, quickly_fill_chaos);
  
  EEPROM.get(19, color_soft);
  EEPROM.get(20, BRIGHTNESS);
  EEPROM.get(21, multiplier_interval_leds_on );  

  EEPROM.get(23, interval_change_palette);
  EEPROM.get(27, multiplier_flag);

  EEPROM.get(30, selected_juggle_effect);

  EEPROM.get(33, fire_fire);

  EEPROM.get(37, selected_beeld_effect);
  EEPROM.get(38, SECONDS_PER_beeld);

  EEPROM.get(42, SECONDS_PER_PALETTE);
  EEPROM.get(43, selected_raster_colorwaves);
  EEPROM.get(44, colorwaves_pride);

  EEPROM.get(48, smiley_true);

     // End of configere EEPROM.

//****************************************************************************

//   selectedEffect=9; // X om een effect te testen vul het nummer in 0 t/m 9

//****************************************************************************

  randomSeed (analogRead(0));
  delay(50);
  random16_add_entropy(random());           // om random8 van FastLED meer random te maken

  new_color();                              // geeft nieuwe kleur voor colorTarget en colorStart

  digitalWrite(MosFet_PIN, LOW);            // turn MosFet on what set the power to the NeoPixels on.

  FastLED.clear();                          // fill_solid( leds, NUM_LEDS, CRGB::Black);

  smiley();

  delay(1000);

  Serial.println(F("Setup done.  "));

}

//--------------------------------------------
//  *** einde void setup ***
//--------------------------------------------

//  Serial.print("xxxxx  =   ");
//  Serial.println(yyyyy, DEC);

//---------------------------------------------------------------



//--------------------------
//  *** begin void loop ***
//--------------------------

void loop() {

//    selectedEffect = x ; // nr invullen om een effect te testen vul het nummer in 0 t/m 9

   if(selectedEffect>9) { 
    selectedEffect=1;
 }


//Serial.print(F(" selectedEffect  =  ")); Serial.println(selectedEffect);
     
  switch(selectedEffect) {


//    case 0  : { //Serial.println(F(" 0  go to general settings "));
//                general_settings();
//                break;
//              }



    case 1  : { //Serial.println(F(" 1  naar Triangles"));
                triangles();
                break;
              }



    case 2  : { //Serial.println(F(" 2  naar ColorWavesWithPalettes"));
                ColorWavesWithPalettes();
                break;
             }



    case 3  : { //Serial.println(F(" 3  naar pride"));
                Smiley_Smill();               //ColorWavesWithPalettes();  //  was pride();
                break;
             }



    case 4  : { //Serial.println(F(" 4  naar ChangePalettePeriodically()")); 
                ChangePalettePeriodically();
                break;
              }



    case 5  : { //Serial.println(F(" 5  naar full_rainbow_color"));
                full_rainbow_color();
                break;
              }



    case 6  : { //Serial.println(F(" 6  naar chaos"));
                chaos();
                break;
              }



    case 7  : { //Serial.println(F(" 7  naar Fire2012WithPalette"));
                Fire2012WithPalette(); // run simulation frame, using palette colors
                break;
              }



    case 8  : { //  Serial.println("8  naar FixBeeld");
                FixBeeld();
                break;
              }



    case 9  : { //  Serial.println("9  naar juggle");
                juggle();
                break;
              }
  }  
}

//--------------------------
//  *** einde void loop ***
//--------------------------



//---------------------------------
//  *** begin Triangles effect ***
//---------------------------------

void triangles() {  // case 1

byte selectedEffect_prev = selectedEffect; 

  FastLED.clear();  // fill_solid( leds, NUM_LEDS, CRGB::Black);

init_last_animations();

// int x = 0;       // om te testen

opnieuw:

  update_in_triangles =false;
  
  new_color();      // T bij opstarten
  
  fill_solid( & (leds[ 21]), 6 , colorTarget);
  fill_solid( & (leds[ 33]), 6 , colorTarget);
  fill_solid( & (leds[ 42]), 4 , colorTarget);
  fill_solid( & (leds[ 55]), 2 , colorTarget);  
  fill_solid( & (leds[ 63]), 2 , colorTarget);
  fill_solid( & (leds[ 75]), 2 , colorTarget); 
  fill_solid( & (leds[ 83]), 2 , colorTarget);
  fill_solid( & (leds[ 95]), 2 , colorTarget);
  fill_solid( & (leds[103]), 2 , colorTarget);
  fill_solid( & (leds[115]), 2 , colorTarget);      

  showStrip(5);

  make_random(0,75,10);                                           // random nummer voor modelNumber

  do {                                                            // zolang selectedEffect_prev == selectedEffect

  new_color();

  FastLED.clear();                                                // fill_solid( leds, NUM_LEDS, CRGB::Black);

  if (boarder){ fill_solid( & (leds[0]), 200, colorTarget); }

  init_triangles();    


     for (int m = 0; m < number_of_animation; m++) {              // number_of_animation geeft aantal waarna er een nieuwe kleur komt

       make_random(0,75,10);                                      // random nummer voor modelNumber
  
//modelNumber = x++;                                              // om te testen

Serial.println(modelNumber);
       make_triangles(true);   

       for (int t = 0; t < (animation_time * 30 ); t++) {         // 1 t/m 20 maal 30 sec dus 30 sec tot 10 min instelbaar
  
          delay (1000);                                           // tijd per animatie is 1 seconde maal animation_time * x

          control_IR_signal();
          
          if (selectedEffect != selectedEffect_prev) { return; }  // have we chanche the pattren? ga uit de loop
          if (update_in_triangles) { goto opnieuw; }              // is er een update dan maak nieuw patroon
       }
     }
  }  while ( true );
     
  Serial.println(F(" einde van de triangles "));  

}

//---------------------------------
//  *** einde Triangles effect ***
//---------------------------------



//-------------------------------
//  *** begin Init_Triangles ***
//-------------------------------

void init_triangles() {

byte temp_modelNumber = modelNumber;    

     for (int m = 0; m < 16; m++) {

        hst_cell_position[m] = 0;       // reset positions
        animation_steps[m] = 0;         // reset steps
     }

     modelNumber = 0;                   // turn for correcting the position
     make_triangles(false);

     modelNumber = 1;                   // turn for correcting the position
     make_triangles(false);

     modelNumber = temp_modelNumber;    // gif back the last animation with the new color
     
     make_triangles(false);

     showStrip(50);

     delay (5000);                      // sho the last display for x seconde  
  
}   

//-------------------------------
//  *** einde Init_Triangles ***
//-------------------------------



//-------------------------------
//  *** begin Make_Triangles ***
//-------------------------------

void make_triangles(bool color_update) {

    for (int m = 0; m < 16; m++) {
        int step = pgm_read_byte(&HSTM[modelNumber][m]) - hst_cell_position[m];         // how many steps from start to end position
    
        if (step >= 0 ) {
          animation_steps[m] = 2 * step;                                                // 0-1, 0-2, 0-3, 1-2, 1-3, 2-3 positions
         }
        else {
          animation_steps[m] = 2 * (4 + step);                                          // 3-0, 3-1, 3-2, 2-1, 2-0, 1-0
         }
    }

    for (int i = 0; i < 8; i++) { //8 steps of animation one 360 degrees rotation
      while (colorCurrent1.h != colorTarget.h) {

         EVERY_N_MILLISECONDS_I(speedup , 1) {

            if (color_update) { 
                speedup.setPeriod( blendRate );                                         // langzaam draaien
            }
            else {
                speedup.setPeriod(1);                                                   // versneld draaien bij initialsatie of kleurwissel      
            }

        colorCurrent1 = blend(colorStart, colorTarget, k, SHORTEST_HUES);              //color of one end of the triangle 
        colorCurrent2 = blend(colorTarget, colorStart, k, SHORTEST_HUES);              //other end of the triangle  


        for ( int j = 0; j < 16; j++) {    //animate all hst
          
          if (animation_steps[j] > 0) {                                               // but only if there are any remaining steps for a hst
            
             orig = pgm_read_byte(&hst_cell_origin[j]);
    
             leds[pgm_read_byte(&m_leds[0][orig + pgm_read_byte(&hst_cell_offset[i + (hst_cell_position[j] * 2 )])])] = colorCurrent1; //color of one end of the triangle
             leds[pgm_read_byte(&m_leds[0][orig + pgm_read_byte(&hst_cell_offset[i + 4 + (hst_cell_position[j] * 2 )])])] = colorCurrent2; //other end of the triangle
   
          }
        }
        
        k+=1; //animation speed, is working only with 1 3 and 5

        if (color_update) {
        
             showStrip(1);
         }
      }
    }

    for (int n = 0; n < 16; n++)  {   //one step less after an iteration

      if (animation_steps[n] > 0) {
         animation_steps[n]--;
      }
    }

        k = 0;

      if (color_update_triangles_start) {
      
         colorStart  = CHSV(random8(), 255 ,255);                       // new start   CHSV(random8(),255,255) voor FastLed random     
      }
      
      if (color_update_triangles_target) {
      
         colorTarget  = CHSV(random8(), 255 ,255);                      // new start   CHSV(random8(),255,255) voor FastLed random     
      }

      colorCurrent1 = colorStart;
      colorCurrent2 = colorTarget;
    }

      for (int n = 0; n < 16; n++) {

          hst_cell_position[n] = pgm_read_byte(&HSTM[modelNumber][n]);  // save the actual model positions
      }
}

//-------------------------------
//  *** einde Make_Triangles ***
//-------------------------------



//---------------------------------------------
//  *** begin init_last_animations nummers ***
//---------------------------------------------

void init_last_animations(){

   for (int x = 0; x < 10; x++) {   //init het array

         last_animations[x] = 255;
   }
}

//---------------------------------------------
//  *** einde init_last_animations nummers ***
//---------------------------------------------



//-----------------------------------
//  *** begin make_random nummer ***
//-----------------------------------

void make_random(byte minimum,byte maximum,byte aantal){      // random(min, max) met array van een max van 10 laatste random waarden zodat er niet te snel hetzelfde komt

bool new_nr = false;

          do {
                    new_nr = false;
                     
                    modelNumber = random(minimum,maximum);    
            
// Serial.print (F("    model number =  ")); Serial.println(modelNumber);
            
               for (int x = 0; x < aantal; x++) {             // stap door het array
            
                     if (last_animations[x] == modelNumber ) {
              
// Serial.print (F("    gelijk model number =  ")); Serial.println(modelNumber);
                     
                         new_nr = true;
                     }
               }
        
          } while (new_nr);                                   // minimaal x verschillende na elkaar


          for (int x = (aantal-1); x >= 0; x--) {             //one step door het array
      
               if (x == 0 ) {
                
                  last_animations[x] = modelNumber;
               }
               else {
                  
                  last_animations[x] = last_animations[x-1];  // schuif een plaats op
               }
          }
}

//-----------------------------------
//  *** einde make_random nummer ***
//-----------------------------------



//--------------------------
//  *** begin new_color ***
//--------------------------

void new_color() {

byte xy = 255;
byte yx = 255;

  if (color_soft) {
      xy = random8(96)+159;
      yx = random8(96)+159;
  }

  do {

      colorStart  = CHSV(random8(), xy, 255);         // new start   -, -, 255 random maken om iets donkerder kleur te krijgen, maar is niet echt mooier
      colorTarget = CHSV(random8(), yx, 255);         // new target   CHSV(random8(),255,255) voor FastLed random of CHSV(random8(),random8(64)+192,255);
          
  }   while (((abs (colorStart.h - colorTarget.h)) < 32) || ((abs (colorStart.h - colorTarget.h)) > 223));  // kleur verschil minimaal 32
}      

//--------------------------
//  *** einde new_color ***
//--------------------------



//---------------------------------------
//  *** begin ColorWavesWithPalettes ***
//---------------------------------------

void ColorWavesWithPalettes(){  // case 2

byte selectedEffect_prev = selectedEffect;
byte k = 0;
byte nr_array;

init_last_animations();

  do {
                EVERY_N_SECONDS_I( timingObj, 0) {
                   timingObj.setPeriod( SECONDS_PER_PALETTE * 10 );       // tijd instelling 1 t/m 20 is 10 tot 200 seconde
 
                   make_random(0,gGradientPaletteCount+1,10);             // random van 0 t/m gGradientPaletteCount en minimaal 10 waarden verschillend voordat herhaling is
                
                   gTargetPalette = gGradientPalettes[ modelNumber ];

                  if (selected_raster_colorwaves == 10) {
                   
                      k++;
    
                      if (k == 4) {
    
                          nr_array = random8 (0 , 9 );                    // random van 0 t/m 8
    
                          k = 0;
                      }
    
                  }
                      else {
                          nr_array = selected_raster_colorwaves - 1;
                      }
                }
                
                EVERY_N_MILLISECONDS(50) {
                nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
               }

//  gCurrentPalette = gGradientPalettes[x]; // om te testen

                colorwaves( gCurrentPalette, nr_array, colorwaves_pride);

                showStrip(2);                                             // update the display

     }  while ( selectedEffect_prev == selectedEffect);
}

//---------------------------------------
//  *** einde ColorWavesWithPalettes ***
//---------------------------------------



//----------------------------------
//  *** begin colorwaves effect ***
//----------------------------------

// This function draws color waves with an ever-changing,
// widely-varying set of parameters, using a color palette.
//void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette, byte k)
void colorwaves( CRGBPalette16& palette, byte raster, bool waves_pride)  
{

CRGB newcolor;

  static uint16_t sPseudotime = 0;
  static uint16_t sLastMillis = 0;
  static uint16_t sHue16 = 0;
 
  uint8_t sat8 = beatsin88( 87, 220, 250);
  uint8_t brightdepth = beatsin88( 341, 96, 224);
  uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
  uint8_t msmultiplier = beatsin88(147, 23, 60);

  uint16_t hue16 = sHue16;//gHue * 256;
  uint16_t hueinc16 = beatsin88(113, 300, 1500);         // colorwaves
//  uint16_t hueinc16 = beatsin88(113, 1, 3000);         // pride
  
  uint16_t ms = millis();
  uint16_t deltams = ms - sLastMillis ;
  sLastMillis  = ms;
  sPseudotime += deltams * msmultiplier;
  sHue16 += deltams * beatsin88( 400, 5,9);
  uint16_t brightnesstheta16 = sPseudotime;
  
  for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
    hue16 += hueinc16;
    uint8_t hue8 = hue16 / 256;

    brightnesstheta16  += brightnessthetainc16;
    uint16_t b16 = sin16( brightnesstheta16  ) + 32768;

    uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
    uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
    bri8 += (255 - brightdepth);


   if (waves_pride) {  // dit suk voor colorwaves

    uint16_t h16_128 = hue16 >> 7;
    if( h16_128 & 0x100) {
      hue8 = 255 - (h16_128 >> 1);
    } else {
      hue8 = h16_128 >> 1;
    }

    uint8_t index = hue8;
    //index = triwave8( index);
    index = scale8( index, 240);

    newcolor = ColorFromPalette( palette, index, bri8);

   }
   else {           // dit suk voor pride

    newcolor = CHSV( hue8, sat8, bri8);

   }

    uint16_t pixelnumber = i;
    pixelnumber = (NUM_LEDS-1) - pixelnumber;
   
    nblend( leds[pgm_read_byte_near( &(m_leds[raster][pixelnumber]) )], newcolor, 128);  // colorwaves
//    nblend( leds[pgm_read_byte_near( &(m_leds[raster][pixelnumber]) )], newcolor, 64); // pride
    
  }

        control_IR_signal();
}

//----------------------------------
//  *** eind colorwaves effect ***
//----------------------------------



//-----------------------------
//  *** begin Smiley Smill ***
//-----------------------------

void Smiley_Smill(){  // case 3

byte selectedEffect_prev = selectedEffect;
byte raster = 0;
byte eye = 0;
byte nr_array;
byte colorwaves_pride_smiley;

byte time_aantal = 0;
byte fase1 = 30;
byte fase2 = 30;
byte fase3 =  0;
byte fase4 =  0;

init_last_animations();

  do {
                EVERY_N_MILLISECONDS(50) {
                nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);

                time_aantal++;
                
                    if (time_aantal == 10) {
                         fase1 = random8 (0 , 255 );
                         fase2 = 255 - random8 (0 , 255 );
                         fase3 = random8 (0 , 9 );
                         fase4 = beatsin16(fase1, 0, 15, 0, 0);
                         time_aantal = 0;
                    }
                }                
                

                if (smiley_true) {             
                
                    EVERY_N_SECONDS_I( timingObj, 0) {
                       
                       timingObj.setPeriod( random8 (0 , 30 ));                // tijd instelling 1 t/m 30 seconde
     
                       make_random(0,gGradientPaletteCount+1,10);              // random van 0 t/m gGradientPaletteCount en minimaal 10 waarden verschillend voordat herhaling is
                    
                       gTargetPalette = gGradientPalettes[ modelNumber ];
    
                          raster++;
                          eye++;
    
                          if (eye == 10) {
    
                               smiley_eye(0,1,0);
                               smiley_eye(255,1,0);
                               eye = random8 (0 , 9 );                          
    
                             for (int t = 0; t < (eye * 10 ); t++) {           // tijd die smiley stil staat
                        
                                delay (1000);                                  // tijd 1 seconde maal eye * 10
                        
                                control_IR_signal();
                                
                                if (selectedEffect != selectedEffect_prev) { return; }  // have we chanche the pattren? ga uit de loop
                             }
                               smiley_eye(0,1,8);
                               smiley_eye(255,1,8);
                               eye = 0;
                          }
        
                          if (raster == 5) {
        
                               nr_array = random8 (0 , 9 );                    // random 0 t/m 8
    
                               colorwaves_pride_smiley = random8 (0 , 2 );     // random 0 = pride of 1 = colorwaves                          
        
                               raster = 0;
            
                          }
                    }

                      colorwaves( gCurrentPalette, nr_array, colorwaves_pride_smiley);
      
                    for (byte w = 0; w < 28; w++) {
                      
                         leds[pgm_read_byte_near( &(s_leds[w]) )] = CRGB::Black ;
                    }
                    for (byte w = 20; w < 36; w++) {
                
                         leds[pgm_read_byte_near( &(s_leds[w]) )] = CRGB::White;
                    }
                         fase4 = 2;
                }
                else {
                
                        // Waves for LED position
                        uint8_t posBeat  = beatsin8(fase1,      0, NUM_LEDS - 1, 0,   0);
                        uint8_t posBeat2 = beatsin8(fase1 * 2,  0, NUM_LEDS - 1, 0,   0);
                        uint8_t posBeat3 = beatsin16(fase1,     0, NUM_LEDS - 1, 0, 127);
                        uint8_t posBeat4 = beatsin16(fase1 * 2, 0, NUM_LEDS - 1, 0, 127);
                      
                        // Wave for LED color
                        uint8_t colBeat  = beatsin8(fase2, 0, 255, 0, 0);
                      
                        byte alter_led_1 = pgm_read_byte_near( &(m_leds[fase3][(posBeat  + posBeat2) / 2]) ); 
                        byte alter_led_2 = pgm_read_byte_near( &(m_leds[fase3][(posBeat3 + posBeat4) / 2]) ); 
                      
                        leds[alter_led_1]  = CHSV(colBeat, 255, 255);
                        leds[alter_led_2]  = CHSV(colBeat, 255, 255);
                      
                        fadeToBlackBy(leds, NUM_LEDS, 10);
                }

                showStrip(fase4);
        
                control_IR_signal();

     }  while ( selectedEffect_prev == selectedEffect);
}

//-----------------------------
//  *** einde Smiley Smill ***
//-----------------------------




//------------------------------------------
//  *** begin ChangePalettePeriodically ***
//------------------------------------------

// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly.  All are shown here.

void ChangePalettePeriodically() {  // case 4

byte alter_led;
byte new_interval;
byte selectedEffect_prev = selectedEffect;

init_last_animations();

byte nr_act;      // = random8(1,18);   // welk patroon
byte nr_pallet;   // = random8(1,gGradientPaletteCount);   // welke kleur van Color Palette definitions

  do {

                EVERY_N_SECONDS_I( timingObj, 0) {

                    if (multiplier_flag) {

                        new_interval = random8(1, 21);                         // variabele tijd van 10 tot 200 sec                 
                        timingObj.setPeriod( new_interval * 10 );              // tijd instelling random 10 tot 200 seconde
                    }

                    else{

                        timingObj.setPeriod( interval_change_palette * 10 );   // tijd instelling 1 t/m 20 is 10 tot 200 seconde
                    }

                        nr_act    = random8(1,18);                             // welk patroon

                        make_random(0,18,8);                                   // random van 0 t/m 17 en minimaal 8 waarden verschillend voordat herhaling is

                        nr_pallet = random8(0,gGradientPaletteCount);          // welke kleur van Color Palette definitions
                }

    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    uint8_t colorIndex = startIndex;
    uint8_t brightness = 255;
   

        if( nr_act == 1)   { setupBlackAndWhiteStripedPalette();        currentBlending = NOBLEND; }
        if( nr_act == 2)   { setupBlackAndWhiteStripedPalette();        currentBlending = LINEARBLEND; }
        if( nr_act == 4)   { gCurrentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( nr_act == 5)   { gCurrentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }

        if( nr_act == 14)  { gCurrentPalette[12]  = CRGB::Green;        currentBlending = NOBLEND; }
        if( nr_act == 16)  { gCurrentPalette[8]   = CRGB::Blue;         currentBlending = NOBLEND; }
        if( nr_act == 7)   { gCurrentPalette[0]   = CRGB::Red;          currentBlending = NOBLEND; }
        if( nr_act == 17)  { colorStripedPalette();                     currentBlending = NOBLEND; }
        if( nr_act == 8)   { gCurrentPalette = CloudColors_p;           currentBlending = NOBLEND; }  //= LINEARBLEND; }
        if( nr_act == 11)  { gCurrentPalette = PartyColors_p;           currentBlending = NOBLEND; }  //= LINEARBLEND; }

        if( nr_act == 3)   { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 6)   { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 9)   { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 10)  { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 12)  { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 13)  { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }
        if( nr_act == 15)  { gCurrentPalette = gGradientPalettes[nr_pallet]; currentBlending = NOBLEND; }

        for( int i = 0; i < NUM_LEDS; ++i) {

             if( modelNumber <= 8)  { alter_led = pgm_read_byte_near( &(m_leds[modelNumber][i]) ); }
             if( modelNumber >  8)  { alter_led = pgm_read_byte_near( &(m_leds[modelNumber-9][199-i]) ); }

             leds[alter_led] = ColorFromPalette( gCurrentPalette, colorIndex, brightness, currentBlending);

             colorIndex += 3;
    }
             showStrip(5);

                 control_IR_signal();

     }  while ( selectedEffect_prev == selectedEffect);
}

//------------------------------------------
//  *** einde ChangePalettePeriodically ***
//------------------------------------------



//-------------------------------------------------
//  *** begin SetupBlackAndWhiteStripedPalette ***
//-------------------------------------------------

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void setupBlackAndWhiteStripedPalette() {

    // 'black out' all 16 palette entries...
    fill_solid( gCurrentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    gCurrentPalette[0]  = CRGB::White;
    gCurrentPalette[4]  = CRGB::White;
    gCurrentPalette[8]  = CRGB::White;
    gCurrentPalette[12] = CRGB::White;
}

//-------------------------------------------------
//  *** einde SetupBlackAndWhiteStripedPalette ***
//-------------------------------------------------



//------------------------------------
//  *** begin ColorStripedPalette ***
//------------------------------------

// This function sets up a palette of color stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void colorStripedPalette() {

    // 'black out' all 16 palette entries...
    fill_solid( gCurrentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    gCurrentPalette[0]  = CRGB::Red;
    gCurrentPalette[4]  = CRGB::Green;
    gCurrentPalette[8]  = CRGB::Blue;
    gCurrentPalette[12] = CRGB::Yellow;
}

//------------------------------------
//  *** einde ColorStripedPalette ***
//------------------------------------



//----------------------------------------
//  *** begin void full_rainbow_color ***
//----------------------------------------

void full_rainbow_color(){  // case 5

     if (color_fix) {

     fill_solid( leds, NUM_LEDS, CHSV (color_Fix_number, 255,255) );

     }
     else {

     fill_rainbow( leds, NUM_LEDS, gHue++, nr_rainbow_colors);           // bij nr_rainbow_colors = 1 verkleurd het gehele vlak langzaam

     }

     showStrip(time_full_rainbow_color * 5);                             // *5 omdat showStrip van 50 naar 10 id gegaan

     control_IR_signal();
}

//----------------------------------------
//  *** einde void full_rainbow_color ***
//----------------------------------------



//---------------------------
//  *** begin void chaos ***
//---------------------------

void chaos() {  // case 6

byte selectedEffect_prev = selectedEffect;
byte w = 0;   
byte leds_color[NUM_LEDS];
bool first_time_again = true;


  do {                                                 // infinite loop

         if (quickly_fill_chaos && first_time_again) {  

              for ( w = 0; w < NUM_LEDS; w++) {        // vul het display met random kleuren
            
                  new_color();
              
                  leds[w] = colorStart;                // set pixel to start color
               
                  leds_color[w] = colorStart.h;        // save de kleur in een nieuw array
              
                  showStrip(1);                        // update the display
              }
              first_time_again = !first_time_again;
         }

//   for ( w = 0; w < NUM_LEDS; w++) {                 // keuze is volgorde of
     w = random8(0,NUM_LEDS);                          // random aanpassen -- for loop kan dan weg --

     colorCurrent1 = CHSV(leds_color[w],255,255);      // new target to transition toward
     colorCurrent2 = CHSV(0,0,0);
     new_color();

     k = 0;
      
      while (colorCurrent2.h != colorTarget.h)  {                               // kleur verschil  oude kleur colorCurrent1, en nieuwe kleur colorTarget

        colorCurrent2 = blend( colorCurrent1,  colorTarget,   k, LONGEST_HUES); // SHORTEST_HUES of LONGEST_HUES
        fill_solid( & (leds[w]), 1, colorCurrent2 );

//      k++;                          // meest gelijkmatige overgang --  update in 255 stappen 2 en 4 werken niet omdat er dan over 255 wordt heengestapt
        k = k + chaos_speed;          // +1 update in 255 stappen +3 update in 85 stappen en +5 update in 51 stappen -- nog via afstandsbediening instellen ??


     showStrip(5);                    // update the display
    
    }

         if (IRcontrol) {             // have we received an IR signal?            

           first_time_again = true;   // aanpssen om opnieuw te beginnen nadat in IR geweest

        }

        control_IR_signal();
        
        if (selectedEffect != selectedEffect_prev) { return; }                 // have we chanche the pattren? ga uit de loop

     }  while ( true );              // infinite loop

  Serial.println(F(" einde van de chaos "));  
} 

//---------------------------
//  *** einde void chaos ***
//---------------------------



//------------------------------------
//  *** begin Fire2012WithPalette ***
//------------------------------------

void Fire2012WithPalette() { // case 7

CRGBPalette16 gPal;

byte heat[NUM_LEDS];

byte selectedEffect_prev = selectedEffect;

bool gReverseDirection = false; // vuur richtig omdraaien

// Array of temperature readings at each simulation cell
//  static byte heat[NUM_LEDS]; // kost 200 geheugen plaatsen

// Fire2012 with programmable Color Palette
//
// This code is the same fire simulation as the original "Fire2012",
// but each heat cell's temperature is translated to color through a FastLED
// programmable color palette, instead of through the "HeatColor(...)" function.
//
// Four different static color palettes are provided here, plus one dynamic one.
// 
// The three static ones are: 
//   1. the FastLED built-in HeatColors_p -- this is the default, and it looks
//      pretty much exactly like the original Fire2012.
//
//  To use any of the other palettes below, just "uncomment" the corresponding code.
//
//   2. a gradient from black to red to yellow to white, which is
//      visually similar to the HeatColors_p, and helps to illustrate
//      what the 'heat colors' palette is actually doing,
//   3. a similar gradient, but in blue colors rather than red ones,
//      i.e. from black to blue to aqua to white, which results in
//      an "icy blue" fire effect,
//   4. a simplified three-step gradient, from black to red to white, just to show
//      that these gradients need not have four components; two or
//      three are possible, too, even if they don't look quite as nice for fire.
//
// The dynamic palette shows how you can change the basic 'hue' of the
// color palette every time through the loop, producing "rainbow fire".

// COOLING: How much does the air cool as it rises?
// Less cooling = taller flames.  More cooling = shorter flames.
// Default 55, suggested range 20-100 
#define COOLING  35

// SPARKING: What chance (out of 255) is there that a new spark will be lit?
// Higher chance = more roaring fire.  Lower chance = more flickery fire.
// Default 120, suggested range 50-200.
#define SPARKING 100

  do {                                                                       // zolang selectedEffect_prev == selectedEffect
                
                random16_add_entropy( random());                             // Add entropy to random number generator

                if (fire_fire) {                                             // terug naar 0 duurt x seconde omdat EVERY_N_SECONDS_I eerst afgemaakt wordt
                  
                     gPal = HeatColors_p;
                }
                else {

                  EVERY_N_SECONDS_I( timingObj, 0) {
                     
                     timingObj.setPeriod( random8 (30 , 180 ));              // tijd instelling 30 t/m 180 seconde
   
                     make_random(0,gGradientPaletteCount+1,10);              // random van 0 t/m gGradientPaletteCount en minimaal 10 waarden verschillend voordat herhaling is
                  
                     gPal = gGradientPalettes[ modelNumber ];
                  }
                }

          // Step 1.  Cool down every cell a little
          for( int i = 0; i < NUM_LEDS; i++) {
            heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
          }
        
          // Step 2.  Heat from each cell drifts 'up' and diffuses a little
          for( int k= NUM_LEDS - 1; k >= 2; k--) {
            heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
          }
          
          // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
          if( random8() < SPARKING ) {
            int y = random8(7);
            heat[y] = qadd8( heat[y], random8(160,255) );
          }
      
          // Step 4.  Map from heat cells to LED colors
          for( int j = 0; j < NUM_LEDS; j++) {
            // Scale the heat value from 0-255 down to 0-240
            // for best results with color palettes.
            byte colorindex = scale8( heat[j], 240);
            CRGB color = ColorFromPalette( gPal, colorindex);
            int pixelnumber;
            if( gReverseDirection ) {
              pixelnumber = (NUM_LEDS-1) - j;
            } else {
              pixelnumber = j;
            }
            leds[pixelnumber] = color;
          }

                showStrip(15);                                               // update the display 2 - 20 lager meer beweging hoger is rustiger
      
                control_IR_signal();

     }  while ( selectedEffect_prev == selectedEffect);
}

//------------------------------------
//  *** einde Fire2012WithPalette ***
//------------------------------------



//------------------------------
//  *** begin void FixBeeld ***
//------------------------------

void FixBeeld(){  // case 8

byte selectedEffect_prev = selectedEffect;
byte alter_led;
bool colorwaves_pride = true;

init_last_animations();
 
 do {         // zolang selectedEffect_prev == selectedEffect


        EVERY_N_SECONDS_I( timingObj, 0) {
                 
                   timingObj.setPeriod( SECONDS_PER_beeld * 10 );             // tijd instelling 1 t/m 20 is 10 tot 200 seconde

              if (selected_beeld_effect == 1) {
                   make_random(0,gGradientPaletteCount+19,10);                // random van min tot max  en difference -- is  0 t/m x afhankelijk van het aantal gGradientPaletteCount
                   colorwaves_pride = random8 (0 , 2 );                       // random 0 = pride of 1 = colorwaves
              }
              else if (selected_beeld_effect == 2) {
                   make_random(0,18,10);                                      // random van min tot max  en difference -- is  0 t/m 17
              }
              else { 
                   make_random(18,gGradientPaletteCount+19,10);               // random van min tot max  en difference -- is 18 t/m x afhankelijk van het aantal gGradientPaletteCount
                  if (selected_beeld_effect == 3) {
                   colorwaves_pride = 1;                                      // random 0 = pride of 1 = colorwaves
                  }
                  if (selected_beeld_effect == 4) {
                   colorwaves_pride = 0;                                      // random 0 = pride of 1 = colorwaves
                  }              
                  if (selected_beeld_effect == 5) {
                   colorwaves_pride = random8 (0 , 2 );                       // random 0 = pride of 1 = colorwaves
                  }
              }

            if (modelNumber < 18) {                                           // max = 17  0 t/m 17 = 18
  
                       uint8_t BeatsPerMinute = 25;
                       CRGBPalette16 palette = PartyColors_p;
                       uint8_t beat = beatsin8( BeatsPerMinute, 32, 255);

                    for( int i = 0; i < NUM_LEDS; i++) {
                
                       if( modelNumber <= 8)  { alter_led = pgm_read_byte_near( &(m_leds[modelNumber][i]) ); }        // t/m 8
                       if( modelNumber >  8)  { alter_led = pgm_read_byte_near( &(m_leds[modelNumber-9][199-i]) ); }  // 9 t/m 17 en dan - 9 geeft 0 t/m 8
                
                       leds[alter_led] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
                    }
                    
            }
            else {
                        modelNumber = modelNumber - 18;                        // min 18 - 18 = 0 en max (gGradientPaletteCount + 1) - 18 = 32 dus 0 t/m 32 = 33 pallets

                       gCurrentPalette = gGradientPalettes[modelNumber]; currentBlending = NOBLEND;

  
  byte abc=random(1,201);                                                      // in plaats van alle leds NUM_LEDS een willekeurig aantal
  byte nr_array = random8 (0 , 9 );                                            // random van 0 t/m 8  
    
                  for( int i = 0; i < abc; i++) {

                    colorwaves( gCurrentPalette, nr_array, colorwaves_pride);  // 1 = true geeft colorwaves en 0 = false geeft pride weergave
                  }
            }                    
                    showStrip(5);  
         }              
                    control_IR_signal();

 } while ( selectedEffect_prev == selectedEffect);
}

//-------------------------
//  *** einde void FixBeeld ***
//-------------------------



//----------------------------
//  *** begin void juggle ***
//----------------------------

void juggle() {   // case 9                   // Several colored dots, weaving in and out of sync with each other

byte selectedEffect_prev = selectedEffect;
byte faderate = 2;                            // How long should the trails be. Very low value = longer trails.
byte nr_array   = random8(0,9);
byte juggle_time = 1;                         // Tijd waarna van kleur wordt gewisseld
bool init_effect_3 = true;                    // Bij switchen tussen 1 of 2 naar 3 deze eerst opvullen

uint8_t thishue = 0;                          // Starting hue.
uint8_t curhue = 0;                           // The current hue
uint8_t basebeat = 5;
uint8_t numdots = 4;                          // Number of dots in use.
uint8_t hueinc = 16;                          // Incremental change in hue between each dot.

    k = 0;


  do {  // zolang selectedEffect_prev == selectedEffect

      EVERY_N_SECONDS_I( timingObj, 0) {
      timingObj.setPeriod( 5 );                                     // tijd instelling 5seconde      
 
      // iedere 5 seconde
              
              if (selected_juggle_effect == 3) {

                      if (init_effect_3) {                         // even een beetje invullen
                        
                               FastLED.clear();
    
                               for( int i = 0; i < 25; i++){
    
                                   juggle_fill();
    
                                   showStrip(1);
                               }
    
                               init_effect_3 = false;                
                      }
                   fadeToBlackBy( leds, NUM_LEDS, 25);
      
                   juggle_fill();
              }


              if (selected_juggle_effect == 1) {
                      juggle_time--;
              }


              k++;

      
      // iedere 30 seconde
      
              if (k > 6 ) {

                    nr_array = random8(0,  9);

                    if (selected_juggle_effect == 2) {                         
                            dothue   = random8(0,255);     // voor sinelon
                    }
        
                        k = 0;
      
              }
      } // end EVERY_N_SECONDS

              
        if (selected_juggle_effect == 1) {

                 if (juggle_time == 0)  {
                      numdots=random8(4,11); thishue=random8(); faderate=random8(2,17);
                      juggle_time = random(1,11);
                      Serial.println(thishue);
                 }

            curhue = thishue;                                      // Reset the hue values.

          fadeToBlackBy(leds, NUM_LEDS, faderate);
      
          for( int i = 0; i < numdots; i++) {
      
               leds[pgm_read_byte_near( &(m_leds[nr_array][beatsin16(basebeat+i+numdots,0,NUM_LEDS-1)]) )] += CHSV(curhue, 255, 255);
                                                                   //beat16 is a FastLED 3.1 function  += CHSV(curhue, thissat, thisbright);          

               curhue += hueinc;
         }
              if (!init_effect_3) { init_effect_3 = true;}
        }        

        if (selected_juggle_effect == 2) {                         // sinelon
               fadeToBlackBy( leds, NUM_LEDS, 20);
               int pos = beatsin16( 10, 0, NUM_LEDS-1);
               leds[pgm_read_byte_near( &(m_leds[nr_array][pos]) )] += CHSV( dothue, 255, 192);

              if (!init_effect_3) { init_effect_3 = true;}
        }

        showStrip(10);
 
            if (IRcontrol) {                                       // have we received an IR signal?            
              if (!init_effect_3) { init_effect_3 = true;}
            }

            control_IR_signal();

  }  while ( selectedEffect_prev == selectedEffect);
  
}

//----------------------------
//  *** einde void juggle ***
//----------------------------



//---------------------------------
//  *** begin void juggle_fill ***
//---------------------------------

void juggle_fill() { 

          dothue = random8(0,255);
                       
      for( int i = 0; i < 8; i++){
        
          leds[beatsin16( i+7, 0, NUM_LEDS-1)] |= CHSV(dothue, 200, 255);
      }
}

//---------------------------------
//  *** einde void juggle_fill ***
//---------------------------------



//---------------------------------------
//  *** begin void Interrupt_Handler ***
//---------------------------------------

void Interrupt_Handler() {

           IRcontrol = true ;

           detachInterrupt(digitalPinToInterrupt(IR_Pin));  // stop interrupts

//         digitalWrite (IR_LED, !digitalRead(IR_LED));     // led aan dan wacht op uit en druk OK button voor void translateIR
           digitalWrite(IR_LED, HIGH);
   }

//---------------------------------------
//  *** einde void Interrupt_Handler ***
//---------------------------------------



//-------------------------------------------
//  *** begin void Interrupt_RadarSensor ***
//-------------------------------------------

void Interrupt_RadarSensor() {

           radar_control = 1;                                           // radar control 1 is beweging gedetecteerd

           if (digitalRead(MosFet_PIN)) {                               // If MosFet_PIN high dan MosFet_PIN low zet de leds aan
            //    digitalWrite(MosFet_PIN, !digitalRead(MosFet_PIN)); 
                  digitalWrite(MosFet_PIN, LOW);                        // turn the MosFet on
           }
}

//-------------------------------------------
//  *** einde void Interrupt_RadarSensor ***
//-------------------------------------------



//----------------------------------
//  *** begin control_IR_signal ***
//----------------------------------

void control_IR_signal()
{


// test IR afstandsbediening

          if (IRcontrol) {                                                // have we received an IR signal?            
             
             translateIR();                                               // signaal ontvangen
         }

// test radar sensor voor beweging

          
          if (radar_control == 2) {                                       // radar control 2 is bewaking tijd om uit te schakelen 

unsigned long interval = (100000 * multiplier_interval_leds_on);          // variabele tijd van 1,5 min tot 33 min

                     if ( (millis() - startTime_leds_on) > interval) {

                          digitalWrite(MosFet_PIN, HIGH);                 // turn the MosFet off
                          radar_control = 3;                              // radar control 3 omdat er maar eenmaal uitgeschakeld hoeft te worden 
                     }
          }

          if (radar_control == 1) {                                       // radar control 1 is beweging gedetecteerd 

             startTime_leds_on = millis();
             radar_control = 2; 
          }



// test tiptoets voor bevriezing

           bool tiptoets = digitalRead(TipToets_Pin);                     // read tiptoets

          if (tiptoets) {                                                // tiptoets hoog

               while (tiptoets) {

                    delay(250);

                    tiptoets = !digitalRead(TipToets_Pin);                // read tiptoets
               }
                    beep(1500);
                    delay(250);
          }
}

//----------------------------------
//  *** einde control_IR_signal ***
//----------------------------------



//--------------------------
//  *** begin void beep ***
//--------------------------

void beep(int toon) {     // toon => toonhoogte van de beep

    tone(buzzer, toon);   // 1000 Send 1KHz sound signal...
    delay(250);           // ...for x time
    noTone(buzzer);       // Stop sound...
    delay(25);            // ...for x time  
}

//--------------------------
//  *** einde void beep ***
//--------------------------



//---------------------------------
//  *** begin void translateIR ***
//---------------------------------
                 
void translateIR()     {

    irrecv.enableIRIn();                                                    // Start the receiver
    delay(200);

    results.value = 0xFFFFFFFF;

    beep(750);

//    digitalWrite (IR_LED, !digitalRead(IR_LED));                          // als led uit dan druk op de OK button   
    digitalWrite(IR_LED, LOW);  

    k = 0 ;

                    do  {

                          k = k + 1 ;  

                          irrecv.resume();                                  // receive the next value
                          delay(350);
                          if (irrecv.decode(&results))                      // have we received an IR signal?

                          delay(50);


                          if(results.value == button_ok) {                  // als OK dan door anders terug omdat het een onbedoelde code is

                          FastLED.clear();
                          fill_solid( & (leds[180]), 20, colorStart);
                          
                          showStrip(5);                                     // update the display

                          reciveIR();
                          
                          FastLED.clear();
                          
                          showStrip(5);                                     // update the display

                          EEPROM.put(00, selectedEffect);                   // store put

                          k = 20;                                           // end      

                          }

                  }  while (k < 5 );


      IRcontrol = false ;

      EIFR = 0b00000011;

      attachInterrupt (digitalPinToInterrupt (IR_Pin), Interrupt_Handler, LOW); //set up ISR for receiving IR signal

 Serial.println(F(" translateIR Done  "));
 
}

//---------------------------------
//  *** einde void translateIR ***
//---------------------------------



//------------------------------
//  *** begin void reciveIR ***
//------------------------------

void reciveIR()  {                                                // takes action based on IR code received

byte selectedEffect_tmp = selectedEffect;                         // om geen effect verandering te krijgen na keuze 0 wat de algemene instellingen is

    irrecv.enableIRIn();                                          // Start the receiver
    delay(200);
    results.value = 0xFFFFFFFF;

    beep(1000);

 Serial.println(F(" In reciveIR void gekomen  "));

bool verlaat_instel = false ;                                     // om uit de while loop te gaan

 
 while ( verlaat_instel == false) {   

                            irrecv.resume();                      // receive the next value
                            delay(350);
                            if (irrecv.decode(&results)) {        // have we received an IR signal?
                            delay(50);
                            
//  Serial.print(F("  code case button   "));   Serial.println(results.value, HEX);

  switch(results.value) {


  case button_ok: // Serial.print(" OK => return "); Serial.println(results.value, HEX);
                     IRcontrol = false ;
                     verlaat_instel = true;                   
                     beep(1500);
                     delay(100);
                     break; // einde oefening

  case button_0: // Serial.print(" Knop 0 is case 0 "); Serial.println(results.value, HEX);
                 // Serial.println(F(" 0  go to general settings "));
                    IRcontrol = false ;
                    selectedEffect = 0;
                    value_control();
                    selectedEffect = selectedEffect_tmp;
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                                    
                    break;    
  

  case button_1: // Serial.print(" Knop 1 is case 1 "); Serial.println(results.value, HEX);
                    IRcontrol = false ;
                    selectedEffect = 1;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                 
                    break;    

  case button_2: // Serial.print(" Knop 2 is case 2 ");
                    IRcontrol = false ;
                    selectedEffect = 2;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;    

  case button_3: // Serial.print(" Knop 3 is case 3 ");
                    IRcontrol = false ;
                    selectedEffect = 3;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;    

  case button_4: // Serial.print(" Knop 4 is case 4 ");
                    IRcontrol = false ;
                    selectedEffect = 4;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;    

  case button_5: // Serial.print(" Knop 5 is case 5 ");
                    IRcontrol = false ;
                    selectedEffect = 5;
                    value_control();                    
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;

  case button_6: // Serial.print(" Knop 6 is case 6 ");
                    IRcontrol = false ;
                    selectedEffect = 6;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;

  case button_7: // Serial.print(" Knop 7 is case 7 ");
                    IRcontrol = false ;
                    selectedEffect = 7;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;

  case button_8: // Serial.print(" Knop 8 is case 8 ");
                    IRcontrol = false ;
                    selectedEffect = 8;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;  
  
  case button_9: // Serial.print(" Knop 9 is case 9 ");
                    IRcontrol = false ;
                    selectedEffect = 9;
                    value_control();
                    verlaat_instel = true;
                    beep(1500);
                    delay(100);                   
                    break;
    }
   }
  }
 }

//------------------------------
//  *** einde void reciveIR ***
//------------------------------



//-----------------------------------
//  *** begin void value_control ***
//-----------------------------------

void value_control()  { 

    Serial.println(F(" In value_control void gekomen  "));
    
    irrecv.enableIRIn();                                          // Start the receiver
    delay(200);
    results.value = 0xFFFFFFFF;

    beep(1250);

    weergeven_instellingen();


bool verlaat_instel = false ;                                     // om uit de while loop te gaan
 
 while ( verlaat_instel == false) {

                            irrecv.resume();                      // receive the next value
                            delay(350);
                            if (irrecv.decode(&results)) {        // have we received an IR signal?
                            delay(50);
                           
//  Serial.print(F("  code value control   "));   Serial.println(results.value, HEX);

  if (selectedEffect == 0) {

  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));         // Serial.println(results.value, HEX);

                          verlaat_instel = true;                          

                          afhandelen_ok();
                          break; // einde oefening


           case button_l: // Serial.println(F(" button left results = "));        // Serial.println(results.value, HEX);
                          BRIGHTNESS = BRIGHTNESS - 10; 
                          BRIGHTNESS = max ( BRIGHTNESS, 10);

                          on_off_02(BRIGHTNESS/10);
                                                    
                          show_beep();

                          break; 
  

           case button_r: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          BRIGHTNESS = BRIGHTNESS + 10; 
                          BRIGHTNESS = min ( BRIGHTNESS, 160);

                          on_off_02(BRIGHTNESS/10);
                          
                          show_beep();
                          
                          break;

           case button_rv: // Serial.println(F(" button left results = "));       // Serial.println(results.value, HEX);
                          --multiplier_interval_leds_on; 
                          multiplier_interval_leds_on = max ( multiplier_interval_leds_on, 1);
                          on_off_03(multiplier_interval_leds_on);

                          show_beep();

                          break;

           case button_fw: // Serial.println(F(" button rechts results = "));     // Serial.println(results.value, HEX);
                          ++multiplier_interval_leds_on; 
                          multiplier_interval_leds_on = min ( multiplier_interval_leds_on, 20);
                          on_off_03(multiplier_interval_leds_on);

                          show_beep();

                          break;

           case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( color_soft ) {
                  
                          color_soft = false;
                          on_off_01(false);                          
                       }
                 
                       else {
                  
                          color_soft = true;
                          on_off_01(true);
                     }

                          show_beep();

                          break;
       }
     }


 
  if (selectedEffect == 1) {

  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));         // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          update_in_triangles = true;                          
                          afhandelen_ok();
                          break; // einde oefening


           case button_l: // Serial.println(F(" button left results = "));        // Serial.println(results.value, HEX);
                          --number_of_animation; 
                          number_of_animation = max ( number_of_animation, 1);

                          on_off_02(number_of_animation);
                                                    
                          show_beep();

                          break;    


           case button_r: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          ++number_of_animation; 
                          number_of_animation = min ( number_of_animation, 20);

                          on_off_02(number_of_animation);
                          
                          show_beep();

                          break;  


           case button_rv: // Serial.println(F(" button left results = "));       // Serial.println(results.value, HEX);
                          --animation_time;
                          animation_time = max ( animation_time, 1);                           
                          on_off_03(animation_time);

                          show_beep();

                          break;
   

           case button_fw: // Serial.println(F(" button rechts results = "));     // Serial.println(results.value, HEX);
                          ++animation_time;
                          animation_time = min ( animation_time, 20);                           
                          on_off_03(animation_time);
                          
                          show_beep();

                          break;


           case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( boarder ) {
                  
                          boarder = false;
                          on_off_01(false);
                       }
                       else {
                  
                          boarder = true;
                          on_off_01(true);
                     }
                          show_beep();

                          break;


           case button_3: // Serial.println(F(" button 3 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( color_update_triangles_start ) {
                  
                          color_update_triangles_start = false;

                          weergeven_instellingen();
                       }
                 
                       else {
                  
                          color_update_triangles_start = true;
//                        color_update_triangles_target = false;  // geeft koppeling tussen color_update_triangles_start en color_update_triangles_target

                          weergeven_instellingen();
                     }
                          show_beep();

                          break;


           case button_5: //Serial.println(F(" button 5 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( color_update_triangles_target ) {
                  
                          color_update_triangles_target = false;
                          weergeven_instellingen();
                       }
                 
                       else {
                  
                          color_update_triangles_target = true;
//                        color_update_triangles_start = false;  // geeft koppeling tussen color_update_triangles_start en color_update_triangles_target

                          weergeven_instellingen();
                     }
                     
                          show_beep();

                          break;       
       }
     }



  if (selectedEffect == 2) {
    
  switch(results.value) {

           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          afhandelen_ok();
                          break; // einde oefening

           case button_rv: // Serial.println(F(" button left results = "));        // Serial.println(results.value, HEX);
                          --SECONDS_PER_PALETTE; 
                          SECONDS_PER_PALETTE = max ( SECONDS_PER_PALETTE, 1);
                          weergeven_instellingen();
                          show_beep();

                          break;    

           case button_fw: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          ++SECONDS_PER_PALETTE; 
                          SECONDS_PER_PALETTE = min ( SECONDS_PER_PALETTE, 20);
                          weergeven_instellingen();
                          show_beep();

                          break;  

           case button_l: // Serial.println(F(" button left results = "));        // Serial.println(results.value, HEX);
                          --selected_raster_colorwaves; 
                          selected_raster_colorwaves = max ( selected_raster_colorwaves, 1);

                          on_off_02(selected_raster_colorwaves);
                                                    
                          show_beep();

                          break;    

           case button_r: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          ++selected_raster_colorwaves; 
                          selected_raster_colorwaves = min ( selected_raster_colorwaves, 10);

                          on_off_02(selected_raster_colorwaves);
                          
                          show_beep();

                          break;       

           case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( colorwaves_pride ) {
                  
                          colorwaves_pride = false;

                          on_off_01(false);
                       }
                 
                       else {
                  
                          colorwaves_pride = true;
                          
                          on_off_01(true);
                     }

                          show_beep();

                          break;       
       }
  }



  if (selectedEffect == 3) {
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          afhandelen_ok();
                          break; // einde oefening

            case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( smiley_true ) {
                  
                          smiley_true = false;

                          on_off_01(false);
                       }
                 
                       else {
                  
                          smiley_true = true;
                          
                          on_off_01(true);
                     }

                          show_beep();

                          break;
       }
     }



  if (selectedEffect == 4) {
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          afhandelen_ok();
                          break; // einde oefening


           case button_l: // Serial.println(F(" button rv results = "));       // Serial.println(results.value, HEX);
                          --interval_change_palette;
                          interval_change_palette = max ( interval_change_palette, 1);                           

                          on_off_02(interval_change_palette);
                          
                          show_beep();
                          break;    

           case button_r: // Serial.println(F(" button fw results = "));     // Serial.println(results.value, HEX);
                          ++interval_change_palette;
                          interval_change_palette = min ( interval_change_palette, 20);

                          on_off_02(interval_change_palette);
                                                     
                          show_beep();
                          break;


           case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                       if ( multiplier_flag ) {
                  
                          multiplier_flag = false;

                          on_off_01(false);
                       }
                 
                       else {
                  
                          multiplier_flag = true;
                          
                          on_off_01(true);
                     }

                          show_beep();

                          break;
       }
     }



  if (selectedEffect == 5) {  // full color instelling
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;                          
                          afhandelen_ok();
                          break; // einde oefening

           case button_l: // Serial.println(F(" button left results = ")); // Serial.println(results.value, HEX);
                          color_Fix_number = color_Fix_number - 3 ; 
                          
                          weergeven_instellingen();
                                           
                          showStrip(5);
                     //   beep(500);   // onderdrukken van te veel beeps bij instellen
                          delay(100); 
                          break;    

           case button_r: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          color_Fix_number = color_Fix_number + 3; 

                          weergeven_instellingen();
                          
                          showStrip(5);
                     //   beep(500);   // onderdrukken van te veel beeps bij instellen
                          delay(100); 
                          break;  




           case button_rv: // Serial.println(F(" button left results = "));       // Serial.println(results.value, HEX);
                          --time_full_rainbow_color;
                          time_full_rainbow_color = max ( time_full_rainbow_color, 1);                           

                          weergeven_instellingen();
                          
                          show_beep();
                          break;    

           case button_fw: // Serial.println(F(" button rechts results = "));     // Serial.println(results.value, HEX);
                          ++time_full_rainbow_color;
                          time_full_rainbow_color = min ( time_full_rainbow_color, 20);                           

                          weergeven_instellingen();                          
                          
                          show_beep();
                          break;


           case button_4: // Serial.println(F(" button 4 results = "));       // Serial.println(results.value, HEX);

                          if (nr_rainbow_colors > 0) {
                          --nr_rainbow_colors;
                          }

                          weergeven_instellingen();
                          show_beep();
                          break;

           case button_6: // Serial.println(F(" button 6 results = "));       // Serial.println(results.value, HEX);
                          ++nr_rainbow_colors;
                          nr_rainbow_colors = min ( nr_rainbow_colors, 19);
                          weergeven_instellingen();

                          show_beep();
                          break;

           case button_1: // Serial.println(F(" button 1 results = "));          // Serial.println(results.value, HEX);
                      
                       if ( color_fix ) {
                  
                          color_fix = false;
                          
                          on_off_01(false);
                       }
                 
                       else {
                  
                          color_fix = true;
                          
                          on_off_01(true);
                     }
                     
                          show_beep();

                          break;
       }
     }


  if (selectedEffect == 6) {  // color_speed instelling
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));        // Serial.println(results.value, HEX);
                          verlaat_instel = true;                          
                          afhandelen_ok();
                          break; // einde oefening


           case button_1: // Serial.println(F(" button 1 results = "));          // Serial.println(results.value, HEX);
                      
                       if ( quickly_fill_chaos ) {
                  
                          quickly_fill_chaos = false;
                          
                          on_off_01(false);
                       }
                 
                       else {
                  
                          quickly_fill_chaos = true;
                          
                          on_off_01(true);
                     }
                     
                          show_beep();

                          break;


           case button_l: // Serial.println(F(" button left results = "));       // Serial.println(results.value, HEX);
                          chaos_speed = chaos_speed - 2; 
                          chaos_speed = max ( chaos_speed, 1);

                          weergeven_instellingen();

                          show_beep();

                          break;    

           case button_r: // Serial.println(F(" button rechts results = "));    // Serial.println(results.value, HEX);
                          chaos_speed = chaos_speed + 2; 
                          chaos_speed = min ( chaos_speed, 5);

                          weergeven_instellingen();

                          show_beep();

                          break;
       }
      }


  if (selectedEffect == 7) {  // Fire2012WithPalette
    
  switch(results.value) {


           case button_ok: //Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;                          
                          afhandelen_ok();
                          break; // einde oefening

           case button_1: //Serial.println(F(" button 1 results = "));          // Serial.println(results.value, HEX);
                      
                       if ( fire_fire ) {
                  
                          fire_fire = false;
                          
                          on_off_01(false);
                       }
                 
                       else {
                  
                          fire_fire = true;
                          
                          on_off_01(true);
                     }
                     
                          show_beep();

                          break;
       }
     }


  if (selectedEffect == 8) { // beeld effect instelling
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          afhandelen_ok();
                          break; // einde oefening


           case button_l: // Serial.println(F(" button rv results = "));       // Serial.println(results.value, HEX);
                          --selected_beeld_effect;
                          selected_beeld_effect = max ( selected_beeld_effect, 1);                           

                          on_off_02(selected_beeld_effect);
                          
                          show_beep();
                          break;    

           case button_r: // Serial.println(F(" button fw results = "));     // Serial.println(results.value, HEX);
                          ++selected_beeld_effect;
                          selected_beeld_effect = min ( selected_beeld_effect, 5);

                          on_off_02(selected_beeld_effect);
                                                     
                          show_beep();
                          break;


           case button_rv: // Serial.println(F(" button left results = "));        // Serial.println(results.value, HEX);
                          --SECONDS_PER_beeld; 
                          SECONDS_PER_beeld = max ( SECONDS_PER_beeld, 1);

                          on_off_03(SECONDS_PER_beeld);
                                                    
                          show_beep();

                          break;    

           case button_fw: // Serial.println(F(" button rechts results = "));      // Serial.println(results.value, HEX);
                          ++SECONDS_PER_beeld; 
                          SECONDS_PER_beeld = min ( SECONDS_PER_beeld, 20);

                          on_off_03(SECONDS_PER_beeld);
                          
                          show_beep();

                          break;  
       }
     }


  if (selectedEffect == 9) { // juggle effect instelling
    
  switch(results.value) {


           case button_ok: // Serial.println(F(" button ok results = "));          // Serial.println(results.value, HEX);
                          verlaat_instel = true;
                          afhandelen_ok();
                          break; // einde oefening

           case button_1: // Serial.println(F(" button 1 results = "));           // Serial.println(results.value, HEX);
                      
                          selected_juggle_effect = 1;

                          on_off_01(false);

                          show_beep();

                          break;

           case button_2: // Serial.println(F(" button 2 results = "));           // Serial.println(results.value, HEX);
                      
                          selected_juggle_effect = 2;

                          weergeven_instellingen();

                          show_beep();

                          break;

           case button_3: // Serial.println(F(" button 3 results = "));           // Serial.println(results.value, HEX);
                      
                          selected_juggle_effect = 3;

                          on_off_01(true);

                          show_beep();

                          break;
      }
     }
    }
   }
  }

//-----------------------------------
//  *** einde void value_control ***
//-----------------------------------



////------------------------------------
////  *** begin afhandelen_button_1 ***
////------------------------------------
//
//void afhandelen_button_1() {  // actie button_1 false or true
//
//                       if ( one_false_true ) {
//                  
//                          one_false_true = false;
//                          
//                          on_off_01(false);
//                       }
//                 
//                       else {
//                  
//                          one_false_true = true;
//                          
//                          on_off_01(true);
//                     }
//                     
//                          show_beep();
//}
//
////------------------------------------
////  *** einde afhandelen_button_1 ***
////------------------------------------



//------------------------------
//  *** begin afhandelen_ok ***
//------------------------------

void afhandelen_ok() {  // actie button ok opslag van instellingen

                          IRcontrol = false ;

                          EEPROM.put(03, boarder);                  // store putdat
                          EEPROM.put(04, number_of_animation);
                          EEPROM.put(05, animation_time);
                          EEPROM.put(06, color_update_triangles_start);
                          EEPROM.put(07, color_update_triangles_target);

                          EEPROM.put(10, color_Fix_number);
                          EEPROM.put(11, time_full_rainbow_color);
                          EEPROM.put(12, nr_rainbow_colors);
                          EEPROM.put(13, color_fix);

                          EEPROM.put(16, chaos_speed);
                          EEPROM.put(17, quickly_fill_chaos);

                          EEPROM.put(19, color_soft);
                          EEPROM.put(20, BRIGHTNESS);
                          EEPROM.put(21, multiplier_interval_leds_on);

                          EEPROM.put(23, interval_change_palette);
                          EEPROM.put(27, multiplier_flag);

                          EEPROM.put(30, selected_juggle_effect);

                          EEPROM.put(33, fire_fire);

                          EEPROM.put(37, selected_beeld_effect);
                          EEPROM.put(38, SECONDS_PER_beeld);

                          EEPROM.put(42, SECONDS_PER_PALETTE);
                          EEPROM.put(43, selected_raster_colorwaves);
                          EEPROM.put(44, colorwaves_pride);

                          EEPROM.put(48, smiley_true);
                          
                          beep(750);
                          delay(100);
}

//------------------------------
//  *** einde afhandelen_ok ***
//------------------------------



//---------------------------------------
//  *** begin weergeven_instellingen ***
//---------------------------------------

void weergeven_instellingen() {


                            fill_solid( & (leds[  0]), 180, CRGB::Black);

  if (selectedEffect == 0) {

                 if ( color_soft ) {
                          on_off_01(true);
                 }
                 else {
                          on_off_01(false);
                                                                     
                 }
                          on_off_02(BRIGHTNESS/10);
                          
                          on_off_03(multiplier_interval_leds_on);
  }



  if (selectedEffect == 1) {

                 if ( boarder ) {
                          on_off_01(true); 
                  
                 }
                 else {
                          on_off_01(false);
                 }

                 if ( color_update_triangles_start ) {
                          fill_solid( & (leds[27]), 3, CRGB::Green);
                          fill_solid( & (leds[20]), 3, CRGB::Black);
                  
                 }
                 else {
                          fill_solid( & (leds[20]), 3, CRGB::Red);
                          fill_solid( & (leds[27]), 3, CRGB::Black);                  
                 }                          

                 if ( color_update_triangles_target ) {
                          fill_solid( & (leds[47]), 3, CRGB::Green);
                          fill_solid( & (leds[40]), 3, CRGB::Black);
                  
                 }
                 else {
                          fill_solid( & (leds[40]), 3, CRGB::Red);
                          fill_solid( & (leds[47]), 3, CRGB::Black);                  
                 } 

                          on_off_02(number_of_animation);
                          
                          on_off_03(animation_time);
   }


 if (selectedEffect == 2) {

                 if ( colorwaves_pride ) {
                          on_off_01(true); 
                  
                 }
                 else {
                          on_off_01(false);
                 }
                          on_off_02(selected_raster_colorwaves);
                          on_off_03(SECONDS_PER_PALETTE);
   }




  if (selectedEffect == 3) {

                 if ( smiley_true ) {
                          on_off_01(true); 

                 }
                 else {
                          on_off_01(false);

                 }
   }


  if (selectedEffect == 4) {

                 if ( multiplier_flag ) {
                          on_off_01(true); 

                 }
                 else {
                          on_off_01(false);

                 }

                          on_off_02(interval_change_palette);
  
  }


  if (selectedEffect == 5) {

                 if ( color_fix ) {
                          on_off_01(true); 

                 }
                 else {
                          on_off_01(false);

                 }

                          fill_solid( & (leds[40]), max ((color_Fix_number / 3) , 1 ) , CHSV (color_Fix_number, 255,255));
                          on_off_03(time_full_rainbow_color);
                          fill_solid( & (leds[140]), (nr_rainbow_colors + 1), CRGB(0,128,64));
  }


  if (selectedEffect == 6) {

                 if ( quickly_fill_chaos ) {

                          on_off_01(true); 
                 }
                 else {
                         on_off_01(false);

                 }


                 if ( chaos_speed == 1 ) {
                           fill_solid( & (leds[40]),  1, CRGB::Green);
                 }

                 if ( chaos_speed == 3 ) {
                           fill_solid( & (leds[42]),  3, CRGB::Green);
                 }

                 if ( chaos_speed == 5 ) {
                           fill_solid( & (leds[45]),  5, CRGB::Green);
                 }
  }


 if (selectedEffect == 7) {

                 if ( fire_fire ) {
                          on_off_01(true); 
                  
                 }
                 else {
                          on_off_01(false);
                 }
   }


  if (selectedEffect == 8) {

                          on_off_02(selected_beeld_effect);
                          on_off_03(SECONDS_PER_beeld);
  }


  if (selectedEffect == 9) {

                 if ( selected_juggle_effect == 1 ) {
                          on_off_01(false); 
                 }

                 if ( selected_juggle_effect == 2 ) {
                          fill_solid( & (leds[5]), 2,  CRGB::Yellow);
                 }

                 if ( selected_juggle_effect == 3 ) {
                          on_off_01(true); 
                 }
  }
                          FastLED.show();                                    // update the display
                          FastLED.delay(20);
}

//---------------------------------------
//  *** einde weergeven_instellingen ***
//---------------------------------------



//--------------------------
//  *** begin on_off_01 ***
//--------------------------

void on_off_01(bool aan_uit) { 

                          fill_solid( & (leds[0]), 10, CRGB::Black);

                 if (aan_uit == true ) {
                          fill_solid( & (leds[7]),  3, CRGB::Green);
                 }
                 else {
                          fill_solid( & (leds[0]),  3, CRGB::Red  );
                 }
}

//--------------------------
//  *** einde on_off_01 ***
//--------------------------



//--------------------------
//  *** begin on_off_02 ***
//--------------------------

void on_off_02(byte number_of_leds)  {
   
                fill_solid( & (leds[80]), 20, CRGB::Black);
                fill_solid( & (leds[80]), number_of_leds, CRGB::Green);
}

//--------------------------
//  *** einde on_off_02 ***
//--------------------------



//--------------------------
//  *** begin on_off_03 ***
//--------------------------

void on_off_03(byte number_of_leds)  {
   
                fill_solid( & (leds[120]), 20, CRGB::Black);
                fill_solid( & (leds[120]), number_of_leds, CRGB::Blue);
}

//--------------------------
//  *** einde on_off_03 ***
//--------------------------



//--------------------------
//  *** begin show_beep ***
//--------------------------

void show_beep()  {
   
              showStrip(5);
              beep(500);
              delay(100);
}

//--------------------------
//  *** einde show_beep ***
//--------------------------



//--------------------------
//  *** begin showStrip ***
//--------------------------

void showStrip(byte frame_time) { // FastLED

//   show_at_max_brightness_for_power();                         // Power managed display of LED's.   
   FastLED.show();
   FastLED.delay(10 * frame_time);   
}

//--------------------------
//  *** einde showStrip ***
//--------------------------



//---------------------------
//  *** begin void smiley ***
//---------------------------

void smiley() {

   FastLED.clear(); 

CHSV colorNew = CHSV(64,255,255); // yellow

  for (byte k = 0; k < NUM_LEDS; k++) {

    fill_solid( & (leds[pgm_read_byte(& (m_leds[5][k]))]), 1, colorNew);
    showStrip(1);
  } 
   delay(500);

              for (byte w = 0; w < 48; w++) {
                
                   leds[pgm_read_byte_near( &(s_leds[w]) )] = CRGB::Black ;
    showStrip(25);
              }

   delay(1000);

   smiley_eye(255,1,0);
   
          for (byte i = 0; i < 52; i++) {

              colorNew = CHSV(64-i,255,255);

              for (byte w = 0; w < NUM_LEDS; w++) {
                
                   leds[pgm_read_byte_near( &(m_leds[5][w]) )] = colorNew ;
              }
                      
              for (byte w = 0; w < 48; w++) {
            
                   leds[pgm_read_byte_near( &(s_leds[w]) )] = CRGB::Black ;
              }

            showStrip(10);
          }

   smiley_eye(255,1,8);
   smiley_eye(0,2,8);
   
   FastLED.clear(); 

}

//---------------------------
//  *** einde void smiley ***
//---------------------------


//--------------------------------
//  *** begin void smiley_eye ***
//--------------------------------

void smiley_eye( byte color, byte multi, byte offset){ 

        for (byte w = 20 + offset; w < 28 + offset; w++) {
          
             leds[pgm_read_byte_near(&(s_leds[w]))] = CRGB(color,color,color) ;
        }
        showStrip(60 * multi);
}

//--------------------------------
//  *** einde void smiley_eye ***
//--------------------------------



//------------------------------------------
//  *** begin Color Palette definitions ***        hoort oa bij colorwaves
//------------------------------------------

// Gradient Color Palette definitions for 33 different cpt-city color palettes.
//    956 bytes of PROGMEM for all of the palettes together,
//   +618 bytes of PROGMEM for gradient palette code (AVR).
//  1,494 bytes total for all 34 color palettes and associated code.

// Gradient palette "ib_jul01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/xmas/tn/ib_jul01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
    0, 194,  1,  1,
   94,   1, 29, 18,
  132,  57,131, 28,
  255, 113,  1,  1};

// Gradient palette "es_vintage_01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
    0,   4,  1,  1,
   51,  16,  0,  1,
   76,  97,104,  3,
  101, 255,131, 19,
  127,  67,  9,  4,
  153,  16,  0,  1,
  229,   4,  1,  1,
  255,   4,  1,  1};

// Gradient palette "rgi_15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.

DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
    0,   4,  1, 31,
   31,  55,  1, 16,
   63, 197,  3,  7,
   95,  59,  2, 17,
  127,   6,  2, 34,
  159,  39,  6, 33,
  191, 112, 13, 32,
  223,  56,  9, 35,
  255,  22,  6, 38};

// Gradient palette "retro2_16_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 8 bytes of program space.

DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
    0, 188,135,  1,
  255,  46,  7,  1};

// 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 "es_pinksplash_08_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
    0, 126, 11,255,
  127, 197,  1, 22,
  175, 210,157,172,
  221, 157,  3,112,
  255, 157,  3,112};

// Gradient palette "es_pinksplash_07_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
    0, 229,  1,  1,
   61, 242,  4, 63,
  101, 255, 12,255,
  127, 249, 81,252,
  153, 255, 11,235,
  193, 244,  5, 68,
  255, 232,  1,  5};

// Gradient palette "Coral_reef_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
    0,  40,199,197,
   50,  10,152,155,
   96,   1,111,120,
   96,  43,127,162,
  139,  10, 73,111,
  255,   1, 34, 71};

// Gradient palette "es_ocean_breeze_068_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
    0, 100,156,153,
   51,   1, 99,137,
  101,   1, 68, 84,
  104,  35,142,168,
  178,   0, 63,117,
  255,   1, 10, 10};

// Gradient palette "es_ocean_breeze_036_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
    0,   1,  6,  7,
   89,   1, 99,111,
  153, 144,209,255,
  255,   0, 73, 82};

// Gradient palette "departure_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 88 bytes of program space.

DEFINE_GRADIENT_PALETTE( departure_gp ) {
    0,   8,  3,  0,
   42,  23,  7,  0,
   63,  75, 38,  6,
   84, 169, 99, 38,
  106, 213,169,119,
  116, 255,255,255,
  138, 135,255,138,
  148,  22,255, 24,
  170,   0,255,  0,
  191,   0,136,  0,
  212,   0, 55,  0,
  255,   0, 55,  0};

// Gradient palette "es_landscape_64_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
    0,   0,  0,  0,
   37,   2, 25,  1,
   76,  15,115,  5,
  127,  79,213,  1,
  128, 126,211, 47,
  130, 188,209,247,
  153, 144,182,205,
  204,  59,117,250,
  255,   1, 37,192};

// Gradient palette "es_landscape_33_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
    0,   1,  5,  0,
   19,  32, 23,  1,
   38, 161, 55,  1,
   63, 229,144,  1,
   66,  39,142, 74,
  255,   1,  4,  1};

// Gradient palette "rainbowsherbet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
    0, 255, 33,  4,
   43, 255, 68, 25,
   86, 255,  7, 25,
  127, 255, 82,103,
  170, 255,255,242,
  209,  42,255, 22,
  255,  87,255, 65};

// 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 "gr64_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.

DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
    0,   1,124,109,
   66,   1, 93, 79,
  104,  52, 65,  1,
  130, 115,127,  1,
  150,  52, 65,  1,
  201,   1, 86, 72,
  239,   0, 55, 45,
  255,   0, 55, 45};

// Gradient palette "GMT_drywet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
    0,  47, 30,  2,
   42, 213,147, 24,
   84, 103,219, 52,
  127,   3,219,207,
  170,   1, 48,214,
  212,   1,  1,111,
  255,   1,  7, 33};

// Gradient palette "ib15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( ib15_gp ) {
    0, 113, 91,147,
   72, 157, 88, 78,
   89, 208, 85, 33,
  107, 255, 29, 11,
  141, 137, 31, 39,
  255,  59, 33, 89};

// Gradient palette "Fuschia_7_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
    0,  43,  3,153,
   63, 100,  4,103,
  127, 188,  5, 66,
  191, 161, 11,115,
  255, 135, 20,182};

// 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 "lava_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.

DEFINE_GRADIENT_PALETTE( lava_gp ) {
    0,   0,  0,  0,
   46,  18,  0,  0,
   96, 113,  0,  0,
  108, 142,  3,  1,
  119, 175, 17,  1,
  146, 213, 44,  2,
  174, 255, 82,  4,
  188, 255,115,  4,
  202, 255,156,  4,
  218, 255,203,  4,
  234, 255,255,  4,
  244, 255,255, 71,
  255, 255,255,255};

// Gradient palette "fire_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( fire_gp ) {
    0,   1,  1,  0,
   76,  32,  5,  0,
  146, 192, 24,  0,
  197, 220,105,  5,
  240, 252,255, 31,
  250, 252,255,111,
  255, 255,255,255};

// Gradient palette "Colorfull_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.

DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
    0,  10, 85,  5,
   25,  29,109, 18,
   60,  59,138, 42,
   93,  83, 99, 52,
  106, 110, 66, 64,
  109, 123, 49, 65,
  113, 139, 35, 66,
  116, 192,117, 98,
  124, 255,255,137,
  168, 100,180,155,
  255,  22,121,174};

// Gradient palette "Magenta_Evening_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
    0,  71, 27, 39,
   31, 130, 11, 51,
   63, 213,  2, 64,
   70, 232,  1, 66,
   76, 252,  1, 69,
  108, 123,  2, 51,
  255,  46,  9, 35};

// Gradient palette "Pink_Purple_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.

DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
    0,  19,  2, 39,
   25,  26,  4, 45,
   51,  33,  6, 52,
   76,  68, 62,125,
  102, 118,187,240,
  109, 163,215,247,
  114, 217,244,255,
  122, 159,149,221,
  149, 113, 78,188,
  183, 128, 57,155,
  255, 146, 40,123};

// Gradient palette "Sunset_Real_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
    0, 120,  0,  0,
   22, 179, 22,  0,
   51, 255,104,  0,
   85, 167, 22, 18,
  135, 100,  0,103,
  198,  16,  0,130,
  255,   0,  0,160};

// Gradient palette "es_autumn_19_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.

DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
    0,  26,  1,  1,
   51,  67,  4,  1,
   84, 118, 14,  1,
  104, 137,152, 52,
  112, 113, 65,  1,
  122, 133,149, 59,
  124, 137,152, 52,
  135, 113, 65,  1,
  142, 139,154, 46,
  163, 113, 13,  1,
  204,  55,  3,  1,
  249,  17,  1,  1,
  255,  17,  1,  1};

// Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
    0,   0,  0,  0,
   42,   0,  0, 45,
   84,   0,  0,255,
  127,  42,  0,255,
  170, 255,  0,255,
  212, 255, 55,255,
  255, 255,255,255};

// Gradient palette "BlacK_Magenta_Red_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
    0,   0,  0,  0,
   63,  42,  0, 45,
  127, 255,  0,255,
  191, 255,  0, 45,
  255, 255,  0,  0};

// Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.

DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
    0,   0,  0,  0,
   42,  42,  0,  0,
   84, 255,  0,  0,
  127, 255,  0, 45,
  170, 255,  0,255,
  212, 255, 55, 45,
  255, 255,255,  0};

// Gradient palette "Blue_Cyan_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
    0,   0,  0,255,
   63,   0, 55,255,
  127,   0,255,255,
  191,  42,255, 45,
  255, 255,255,  0};

// Gradient palette "loveslast_rose_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/pj/1/tn/loveslast-rose.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.

DEFINE_GRADIENT_PALETTE( loveslast_rose_gp ) {
    0,  10,  0,  0,
   48, 237,  1,  9,
   86,  82,  9,  5,
  104,  97,  8, 14,
  130, 121, 22, 34,
  165, 255,252,230,
  188, 255,252,230,
  204, 117,128, 62,
  226,  27,  1,  1,
  252, 113, 93,  0,
  255, 113, 93,  0};

// Gradient palette "meadow_T_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/pj/1/tn/meadow-T.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.

DEFINE_GRADIENT_PALETTE( meadow_T_gp ) {
    0,   1,239, 49,
   20,   1, 50,  1,
   56,   1,239, 49,
   76,  40,164, 69,
  101,  50,166, 19,
  127, 125,203,160,
  153,  34,141, 52,
  183,   1, 50,  1,
  201,   1,105, 21,
  216, 109,195, 10,
  234,  61,166, 16,
  252,   1,239, 49,
  255,   1,239, 49};

// Gradient palette "Set1_07_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/cb/qual/tn/Set1_07.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 56 bytes of program space.

DEFINE_GRADIENT_PALETTE( Set1_07_gp ) {
    0, 190,  1,  1,
   36, 190,  1,  1,
   36,   4, 54,112,
   72,   4, 54,112,
   72,  11,111, 11,
  109,  11,111, 11,
  109,  66, 18, 83,
  145,  66, 18, 83,
  145, 255, 55,  0,
  182, 255, 55,  0,
  182, 255,255,  4,
  218, 255,255,  4,
  218,  83, 23,  2,
  255,  83, 23,  2};

// Gradient palette "fireandice_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/fireandice.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.

DEFINE_GRADIENT_PALETTE( fireandice_gp ) {
    0,  80,  2,  1,
   51, 206, 15,  1,
  101, 242, 34,  1,
  153,  16, 67,128,
  204,   2, 21, 69,
  255,   1,  2,  4};

// Gradient palette "girlcat_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/girlcat.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( girlcat_gp ) {
    0, 173,229, 51,
   73, 139,199, 45,
  140,  46,176, 37,
  204,   7, 88,  5,
  255,   0, 24,  0};

// Gradient palette "sky_16_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rafi/tn/sky-16.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( sky_16_gp ) {
    0, 133,187,245,
   55,  32,112,221,
  153,   6, 55,186,
  255,   1, 21,135};

// Gradient palette "sky_04_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rafi/tn/sky-04.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( sky_04_gp ) {
    0, 255,189,  3,
   76, 110, 19,  1,
  151,  27,  5,  1,
  255,   1,  1,  1};

// Gradient palette "scoutie_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/scoutie.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.

DEFINE_GRADIENT_PALETTE( scoutie_gp ) {
    0, 255,156,  0,
  127,   0,195, 18,
  216,   1,  0, 39,
  255,   1,  0, 39};

// Gradient palette "snodraegon_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/snodraegon.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.

DEFINE_GRADIENT_PALETTE( snodraegon_gp ) {
    0,  25, 72,155,
   63,  35, 95,172,
  124, 255,250,250,
  191,  34, 32, 68,
  255,  27, 25, 59};

// Gradient palette "spellbound_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/spellbound.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 84 bytes of program space.

DEFINE_GRADIENT_PALETTE( spellbound_gp ) {
    0, 232,235, 40,
   12, 157,248, 46,
   25, 100,246, 51,
   45,  53,250, 33,
   63,  18,237, 53,
   81,  11,211,162,
   94,  18,147,214,
  101,  43,124,237,
  112,  49, 75,247,
  127,  49, 75,247,
  140,  92,107,247,
  150, 120,127,250,
  163, 130,138,252,
  173, 144,131,252,
  186, 148,112,252,
  196, 144, 37,176,
  211, 113, 18, 87,
  221, 163, 33, 53,
  234, 255,101, 78,
  247, 229,235, 46,
  255, 229,235, 46};

// Gradient palette "springangel_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/springangel.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.

DEFINE_GRADIENT_PALETTE( springangel_gp ) {
    0,  95,151,140,
   48,  35,101,170,
   71,  74,103,111,
   94,  77, 97,111,
  117, 165,142,132,
  140, 186,142,128,
  163, 182,124, 96,
  186, 188, 95, 57,
  209, 220, 88, 28,
  232,  92, 86, 41,
  255,  92, 86, 41};

// Gradient palette "iris_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/pd/flowers/tn/iris.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 196 bytes of program space.

DEFINE_GRADIENT_PALETTE( iris_gp ) {
    0, 244,154,  0,
    5, 244,159,  1,
   10, 244,164,  1,
   15, 227,161,  1,
   21, 210,156,  1,
   26, 186,146, 20,
   31, 163,135, 68,
   37, 150,127, 79,
   42, 137,119, 91,
   47, 130,115, 93,
   53, 123,109, 98,
   58, 120,105,100,
   63, 115,103,102,
   69, 115,104,102,
   74, 115,104,102,
   79,  95, 90, 96,
   84,  78, 75, 91,
   90,  54, 53, 75,
   95,  35, 34, 62,
  100,  34, 29, 62,
  106,  32, 24, 62,
  111,  30, 21, 59,
  116,  27, 17, 56,
  122,  26, 14, 53,
  127,  24, 12, 50,
  132,  26, 13, 52,
  138,  27, 14, 52,
  143,  21,  9, 45,
  148,  16,  5, 39,
  154,  11,  2, 31,
  159,   7,  1, 25,
  164,  10,  1, 27,
  170,  14,  2, 30,
  175,  17,  3, 33,
  180,  20,  4, 36,
  185,  20,  5, 37,
  191,  20,  6, 37,
  196,  21,  6, 38,
  201,  22,  6, 38,
  207,  23,  6, 39,
  212,  24,  5, 41,
  217,  25,  7, 42,
  223,  26,  8, 43,
  228,  26,  7, 42,
  233,  26,  6, 41,
  239,  26,  6, 42,
  244,  26,  7, 44,
  249,  17,  3, 34,
  255,  10,  1, 25};




// Single array of defined cpt-city color palettes.
// This will let us programmatically choose one based on
// a number, rather than having to activate each explicitly 
// by name every time.
// Since it is const, this array could also be moved 
// into PROGMEM to save SRAM, but for simplicity of illustration
// we'll keep it in a regular SRAM array.
//
// This list of color palettes acts as a "playlist"; you can
// add or delete, or re-arrange as you wish.
const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
  Sunset_Real_gp,
  es_ocean_breeze_036_gp,
  rgi_15_gp,
  loveslast_rose_gp,
  retro2_16_gp,
  Analogous_1_gp,
  es_pinksplash_08_gp,
  Coral_reef_gp,
  es_ocean_breeze_068_gp,
  es_pinksplash_07_gp,
  es_vintage_01_gp,
  departure_gp,
  Set1_07_gp,
  es_landscape_64_gp,
  es_landscape_33_gp,
  rainbowsherbet_gp,
  gr65_hult_gp,
  gr64_hult_gp,
  GMT_drywet_gp,
  ib_jul01_gp,
  meadow_T_gp,
  ib15_gp,
  Fuschia_7_gp,
  es_emerald_dragon_08_gp,
  lava_gp,
  fire_gp,
  Colorfull_gp,
  Magenta_Evening_gp,
  Pink_Purple_gp,
  es_autumn_19_gp,
  BlacK_Blue_Magenta_White_gp,
  BlacK_Magenta_Red_gp,
  BlacK_Red_Magenta_Yellow_gp,
  Blue_Cyan_Yellow_gp,
  fireandice_gp,
  girlcat_gp,
  sky_16_gp,
  sky_04_gp,  
  scoutie_gp,
  snodraegon_gp,
  spellbound_gp,
  springangel_gp,
  iris_gp};


// Count of how many cpt-city gradients are defined:
const uint8_t gGradientPaletteCount = 
  sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );

//------------------------------------------
//  *** einde Color Palette definitions ***
//------------------------------------------



//---------------------------------------
//  *** Puf, dit was het dan Jan5412 ***
//---------------------------------------




