/ simple_strand_palettes / simple_strand_palettes.ino
simple_strand_palettes.ino
  1  // SPDX-FileCopyrightText: 2017 Erin St. Blaine for Adafruit Industries
  2  //
  3  // SPDX-License-Identifier: MIT
  4  
  5  
  6  #include "FastLED.h"
  7  
  8  // ColorWavesWithPalettes
  9  // Animated shifting color waves, with several cross-fading color palettes.
 10  // by Mark Kriegsman, August 2015
 11  //
 12  // Color palettes courtesy of cpt-city and its contributors:
 13  //   http://soliton.vm.bytemark.co.uk/pub/cpt-city/
 14  //
 15  // Color palettes converted for FastLED using "PaletteKnife" v1:
 16  //   http://fastled.io/tools/paletteknife/
 17  //
 18  
 19  //#if FASTLED_VERSION < 3001000
 20  //#error "Requires FastLED 3.1 or later; check github for latest code."
 21  //#endif
 22  
 23  #define DATA_PIN   6
 24  #define LED_TYPE    WS2812B
 25  #define COLOR_ORDER GRB
 26  #define NUM_LEDS    400       // Change this to reflect the number of LEDs you have
 27  #define BRIGHTNESS  80      // Set Brightness here
 28  
 29  CRGB leds[NUM_LEDS];
 30  
 31  // ten seconds per color palette makes a good demo
 32  // 20-120 is better for deployment
 33  #define SECONDS_PER_PALETTE 20
 34  
 35  
 36  void setup() {
 37    delay(3000); // 3 second delay for recovery
 38    
 39    // tell FastLED about the LED strip configuration
 40    FastLED.addLeds<LED_TYPE,DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)
 41      .setCorrection(TypicalLEDStrip) // cpt-city palettes have different color balance
 42      .setDither(BRIGHTNESS < 255);
 43  
 44    // set master brightness control
 45    FastLED.setBrightness(BRIGHTNESS);
 46  }
 47  
 48  // Forward declarations of an array of cpt-city gradient palettes, and 
 49  // a count of how many there are.  The actual color palette definitions
 50  // are at the bottom of this file.
 51  extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
 52  extern const uint8_t gGradientPaletteCount;
 53  
 54  // Current palette number from the 'playlist' of color palettes
 55  uint8_t gCurrentPaletteNumber = 0;
 56  
 57  CRGBPalette16 gCurrentPalette( CRGB::Black);
 58  CRGBPalette16 gTargetPalette( gGradientPalettes[0] );
 59  
 60  
 61  
 62  
 63  // This function draws color waves with an ever-changing,
 64  // widely-varying set of parameters, using a color palette.
 65  void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette) 
 66  {
 67    static uint16_t sPseudotime = 0;
 68    static uint16_t sLastMillis = 0;
 69    static uint16_t sHue16 = 0;
 70   
 71    uint8_t sat8 = beatsin88( 87, 220, 250);
 72    uint8_t brightdepth = beatsin88( 341, 96, 224);
 73    uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
 74    uint8_t msmultiplier = beatsin88(147, 23, 60);
 75  
 76    uint16_t hue16 = sHue16;//gHue * 256;
 77    uint16_t hueinc16 = beatsin88(113, 300, 1500);
 78    
 79    uint16_t ms = millis();
 80    uint16_t deltams = ms - sLastMillis ;
 81    sLastMillis  = ms;
 82    sPseudotime += deltams * msmultiplier;
 83    sHue16 += deltams * beatsin88( 400, 5,9);
 84    uint16_t brightnesstheta16 = sPseudotime;
 85    
 86    for( uint16_t i = 0 ; i < numleds; i++) {
 87      hue16 += hueinc16;
 88      uint8_t hue8 = hue16 / 256;
 89      uint16_t h16_128 = hue16 >> 7;
 90      if( h16_128 & 0x100) {
 91        hue8 = 255 - (h16_128 >> 1);
 92      } else {
 93        hue8 = h16_128 >> 1;
 94      }
 95  
 96      brightnesstheta16  += brightnessthetainc16;
 97      uint16_t b16 = sin16( brightnesstheta16  ) + 32768;
 98  
 99      uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
100      uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
101      bri8 += (255 - brightdepth);
102      
103      uint8_t index = hue8;
104      //index = triwave8( index);
105      index = scale8( index, 240);
106  
107      CRGB newcolor = ColorFromPalette( palette, index, bri8);
108  
109      uint16_t pixelnumber = i;
110      pixelnumber = (numleds-1) - pixelnumber;
111      
112      nblend( ledarray[pixelnumber], newcolor, 128);
113    }
114  }
115  
116  // Alternate rendering function just scrolls the current palette 
117  // across the defined LED strip.
118  void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette)
119  {
120    static uint8_t startindex = 0;
121    startindex--;
122    fill_palette( ledarray, numleds, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND);
123  }
124  
125  
126  
127  
128  
129  // Gradient Color Palette definitions for 33 different cpt-city color palettes.
130  //    956 bytes of PROGMEM for all of the palettes together,
131  //   +618 bytes of PROGMEM for gradient palette code (AVR).
132  //  1,494 bytes total for all 34 color palettes and associated code.
133  
134  // Gradient palette "ib_jul01_gp", originally from
135  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/xmas/tn/ib_jul01.png.index.html
136  // converted for FastLED with gammas (2.6, 2.2, 2.5)
137  // Size: 16 bytes of program space.
138  
139  DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
140      0, 194,  1,  1,
141     94,   1, 29, 18,
142    132,  57,131, 28,
143    255, 113,  1,  1};
144  
145  // Gradient palette "es_vintage_57_gp", originally from
146  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html
147  // converted for FastLED with gammas (2.6, 2.2, 2.5)
148  // Size: 20 bytes of program space.
149  
150  DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
151      0,   2,  1,  1,
152     53,  18,  1,  0,
153    104,  69, 29,  1,
154    153, 167,135, 10,
155    255,  46, 56,  4};
156  
157  // Gradient palette "es_vintage_01_gp", originally from
158  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
159  // converted for FastLED with gammas (2.6, 2.2, 2.5)
160  // Size: 32 bytes of program space.
161  
162  DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
163      0,   4,  1,  1,
164     51,  16,  0,  1,
165     76,  97,104,  3,
166    101, 255,131, 19,
167    127,  67,  9,  4,
168    153,  16,  0,  1,
169    229,   4,  1,  1,
170    255,   4,  1,  1};
171  
172  // Gradient palette "es_rivendell_15_gp", originally from
173  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html
174  // converted for FastLED with gammas (2.6, 2.2, 2.5)
175  // Size: 20 bytes of program space.
176  
177  DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
178      0,   1, 14,  5,
179    101,  16, 36, 14,
180    165,  56, 68, 30,
181    242, 150,156, 99,
182    255, 150,156, 99};
183  
184  // Gradient palette "rgi_15_gp", originally from
185  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
186  // converted for FastLED with gammas (2.6, 2.2, 2.5)
187  // Size: 36 bytes of program space.
188  
189  DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
190      0,   4,  1, 31,
191     31,  55,  1, 16,
192     63, 197,  3,  7,
193     95,  59,  2, 17,
194    127,   6,  2, 34,
195    159,  39,  6, 33,
196    191, 112, 13, 32,
197    223,  56,  9, 35,
198    255,  22,  6, 38};
199  
200  // Gradient palette "retro2_16_gp", originally from
201  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
202  // converted for FastLED with gammas (2.6, 2.2, 2.5)
203  // Size: 8 bytes of program space.
204  
205  DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
206      0, 188,135,  1,
207    255,  46,  7,  1};
208  
209  // Gradient palette "Analogous_1_gp", originally from
210  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
211  // converted for FastLED with gammas (2.6, 2.2, 2.5)
212  // Size: 20 bytes of program space.
213  
214  DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
215      0,   3,  0,255,
216     63,  23,  0,255,
217    127,  67,  0,255,
218    191, 142,  0, 45,
219    255, 255,  0,  0};
220  
221  // Gradient palette "es_pinksplash_08_gp", originally from
222  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
223  // converted for FastLED with gammas (2.6, 2.2, 2.5)
224  // Size: 20 bytes of program space.
225  
226  DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
227      0, 126, 11,255,
228    127, 197,  1, 22,
229    175, 210,157,172,
230    221, 157,  3,112,
231    255, 157,  3,112};
232  
233  // Gradient palette "es_pinksplash_07_gp", originally from
234  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html
235  // converted for FastLED with gammas (2.6, 2.2, 2.5)
236  // Size: 28 bytes of program space.
237  
238  DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
239      0, 229,  1,  1,
240     61, 242,  4, 63,
241    101, 255, 12,255,
242    127, 249, 81,252,
243    153, 255, 11,235,
244    193, 244,  5, 68,
245    255, 232,  1,  5};
246  
247  // Gradient palette "Coral_reef_gp", originally from
248  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html
249  // converted for FastLED with gammas (2.6, 2.2, 2.5)
250  // Size: 24 bytes of program space.
251  
252  DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
253      0,  40,199,197,
254     50,  10,152,155,
255     96,   1,111,120,
256     96,  43,127,162,
257    139,  10, 73,111,
258    255,   1, 34, 71};
259  
260  // Gradient palette "es_ocean_breeze_068_gp", originally from
261  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html
262  // converted for FastLED with gammas (2.6, 2.2, 2.5)
263  // Size: 24 bytes of program space.
264  
265  DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
266      0, 100,156,153,
267     51,   1, 99,137,
268    101,   1, 68, 84,
269    104,  35,142,168,
270    178,   0, 63,117,
271    255,   1, 10, 10};
272  
273  // Gradient palette "es_ocean_breeze_036_gp", originally from
274  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
275  // converted for FastLED with gammas (2.6, 2.2, 2.5)
276  // Size: 16 bytes of program space.
277  
278  DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
279      0,   1,  6,  7,
280     89,   1, 99,111,
281    153, 144,209,255,
282    255,   0, 73, 82};
283  
284  // Gradient palette "departure_gp", originally from
285  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
286  // converted for FastLED with gammas (2.6, 2.2, 2.5)
287  // Size: 88 bytes of program space.
288  
289  DEFINE_GRADIENT_PALETTE( departure_gp ) {
290      0,   8,  3,  0,
291     42,  23,  7,  0,
292     63,  75, 38,  6,
293     84, 169, 99, 38,
294    106, 213,169,119,
295    116, 255,255,255,
296    138, 135,255,138,
297    148,  22,255, 24,
298    170,   0,255,  0,
299    191,   0,136,  0,
300    212,   0, 55,  0,
301    255,   0, 55,  0};
302  
303  // Gradient palette "es_landscape_64_gp", originally from
304  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
305  // converted for FastLED with gammas (2.6, 2.2, 2.5)
306  // Size: 36 bytes of program space.
307  
308  DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
309      0,   0,  0,  0,
310     37,   2, 25,  1,
311     76,  15,115,  5,
312    127,  79,213,  1,
313    128, 126,211, 47,
314    130, 188,209,247,
315    153, 144,182,205,
316    204,  59,117,250,
317    255,   1, 37,192};
318  
319  // Gradient palette "es_landscape_33_gp", originally from
320  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
321  // converted for FastLED with gammas (2.6, 2.2, 2.5)
322  // Size: 24 bytes of program space.
323  
324  DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
325      0,   1,  5,  0,
326     19,  32, 23,  1,
327     38, 161, 55,  1,
328     63, 229,144,  1,
329     66,  39,142, 74,
330    255,   1,  4,  1};
331  
332  // Gradient palette "rainbowsherbet_gp", originally from
333  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
334  // converted for FastLED with gammas (2.6, 2.2, 2.5)
335  // Size: 28 bytes of program space.
336  
337  DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
338      0, 255, 33,  4,
339     43, 255, 68, 25,
340     86, 255,  7, 25,
341    127, 255, 82,103,
342    170, 255,255,242,
343    209,  42,255, 22,
344    255,  87,255, 65};
345  
346  // Gradient palette "gr65_hult_gp", originally from
347  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
348  // converted for FastLED with gammas (2.6, 2.2, 2.5)
349  // Size: 24 bytes of program space.
350  
351  DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
352      0, 247,176,247,
353     48, 255,136,255,
354     89, 220, 29,226,
355    160,   7, 82,178,
356    216,   1,124,109,
357    255,   1,124,109};
358  
359  // Gradient palette "gr64_hult_gp", originally from
360  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
361  // converted for FastLED with gammas (2.6, 2.2, 2.5)
362  // Size: 32 bytes of program space.
363  
364  DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
365      0,   1,124,109,
366     66,   1, 93, 79,
367    104,  52, 65,  1,
368    130, 115,127,  1,
369    150,  52, 65,  1,
370    201,   1, 86, 72,
371    239,   0, 55, 45,
372    255,   0, 55, 45};
373  
374  // Gradient palette "GMT_drywet_gp", originally from
375  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
376  // converted for FastLED with gammas (2.6, 2.2, 2.5)
377  // Size: 28 bytes of program space.
378  
379  DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
380      0,  47, 30,  2,
381     42, 213,147, 24,
382     84, 103,219, 52,
383    127,   3,219,207,
384    170,   1, 48,214,
385    212,   1,  1,111,
386    255,   1,  7, 33};
387  
388  // Gradient palette "ib15_gp", originally from
389  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
390  // converted for FastLED with gammas (2.6, 2.2, 2.5)
391  // Size: 24 bytes of program space.
392  
393  DEFINE_GRADIENT_PALETTE( ib15_gp ) {
394      0, 113, 91,147,
395     72, 157, 88, 78,
396     89, 208, 85, 33,
397    107, 255, 29, 11,
398    141, 137, 31, 39,
399    255,  59, 33, 89};
400  
401  // Gradient palette "Fuschia_7_gp", originally from
402  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html
403  // converted for FastLED with gammas (2.6, 2.2, 2.5)
404  // Size: 20 bytes of program space.
405  
406  DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
407      0,  43,  3,153,
408     63, 100,  4,103,
409    127, 188,  5, 66,
410    191, 161, 11,115,
411    255, 135, 20,182};
412  
413  // Gradient palette "es_emerald_dragon_08_gp", originally from
414  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html
415  // converted for FastLED with gammas (2.6, 2.2, 2.5)
416  // Size: 16 bytes of program space.
417  
418  DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
419      0,  97,255,  1,
420    101,  47,133,  1,
421    178,  13, 43,  1,
422    255,   2, 10,  1};
423  
424  // Gradient palette "lava_gp", originally from
425  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
426  // converted for FastLED with gammas (2.6, 2.2, 2.5)
427  // Size: 52 bytes of program space.
428  
429  DEFINE_GRADIENT_PALETTE( lava_gp ) {
430      0,   0,  0,  0,
431     46,  18,  0,  0,
432     96, 113,  0,  0,
433    108, 142,  3,  1,
434    119, 175, 17,  1,
435    146, 213, 44,  2,
436    174, 255, 82,  4,
437    188, 255,115,  4,
438    202, 255,156,  4,
439    218, 255,203,  4,
440    234, 255,255,  4,
441    244, 255,255, 71,
442    255, 255,255,255};
443  
444  // Gradient palette "fire_gp", originally from
445  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html
446  // converted for FastLED with gammas (2.6, 2.2, 2.5)
447  // Size: 28 bytes of program space.
448  
449  DEFINE_GRADIENT_PALETTE( fire_gp ) {
450      0,   1,  1,  0,
451     76,  32,  5,  0,
452    146, 192, 24,  0,
453    197, 220,105,  5,
454    240, 252,255, 31,
455    250, 252,255,111,
456    255, 255,255,255};
457  
458  // Gradient palette "Colorfull_gp", originally from
459  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
460  // converted for FastLED with gammas (2.6, 2.2, 2.5)
461  // Size: 44 bytes of program space.
462  
463  DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
464      0,  10, 85,  5,
465     25,  29,109, 18,
466     60,  59,138, 42,
467     93,  83, 99, 52,
468    106, 110, 66, 64,
469    109, 123, 49, 65,
470    113, 139, 35, 66,
471    116, 192,117, 98,
472    124, 255,255,137,
473    168, 100,180,155,
474    255,  22,121,174};
475  
476  // Gradient palette "Magenta_Evening_gp", originally from
477  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html
478  // converted for FastLED with gammas (2.6, 2.2, 2.5)
479  // Size: 28 bytes of program space.
480  
481  DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
482      0,  71, 27, 39,
483     31, 130, 11, 51,
484     63, 213,  2, 64,
485     70, 232,  1, 66,
486     76, 252,  1, 69,
487    108, 123,  2, 51,
488    255,  46,  9, 35};
489  
490  // Gradient palette "Pink_Purple_gp", originally from
491  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
492  // converted for FastLED with gammas (2.6, 2.2, 2.5)
493  // Size: 44 bytes of program space.
494  
495  DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
496      0,  19,  2, 39,
497     25,  26,  4, 45,
498     51,  33,  6, 52,
499     76,  68, 62,125,
500    102, 118,187,240,
501    109, 163,215,247,
502    114, 217,244,255,
503    122, 159,149,221,
504    149, 113, 78,188,
505    183, 128, 57,155,
506    255, 146, 40,123};
507  
508  // Gradient palette "Sunset_Real_gp", originally from
509  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
510  // converted for FastLED with gammas (2.6, 2.2, 2.5)
511  // Size: 28 bytes of program space.
512  
513  DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
514      0, 120,  0,  0,
515     22, 179, 22,  0,
516     51, 255,104,  0,
517     85, 167, 22, 18,
518    135, 100,  0,103,
519    198,  16,  0,130,
520    255,   0,  0,160};
521  
522  // Gradient palette "es_autumn_19_gp", originally from
523  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
524  // converted for FastLED with gammas (2.6, 2.2, 2.5)
525  // Size: 52 bytes of program space.
526  
527  DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
528      0,  26,  1,  1,
529     51,  67,  4,  1,
530     84, 118, 14,  1,
531    104, 137,152, 52,
532    112, 113, 65,  1,
533    122, 133,149, 59,
534    124, 137,152, 52,
535    135, 113, 65,  1,
536    142, 139,154, 46,
537    163, 113, 13,  1,
538    204,  55,  3,  1,
539    249,  17,  1,  1,
540    255,  17,  1,  1};
541  
542  // Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
543  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
544  // converted for FastLED with gammas (2.6, 2.2, 2.5)
545  // Size: 28 bytes of program space.
546  
547  DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
548      0,   0,  0,  0,
549     42,   0,  0, 45,
550     84,   0,  0,255,
551    127,  42,  0,255,
552    170, 255,  0,255,
553    212, 255, 55,255,
554    255, 255,255,255};
555  
556  // Gradient palette "BlacK_Magenta_Red_gp", originally from
557  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
558  // converted for FastLED with gammas (2.6, 2.2, 2.5)
559  // Size: 20 bytes of program space.
560  
561  DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
562      0,   0,  0,  0,
563     63,  42,  0, 45,
564    127, 255,  0,255,
565    191, 255,  0, 45,
566    255, 255,  0,  0};
567  
568  // Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
569  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
570  // converted for FastLED with gammas (2.6, 2.2, 2.5)
571  // Size: 28 bytes of program space.
572  
573  DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
574      0,   0,  0,  0,
575     42,  42,  0,  0,
576     84, 255,  0,  0,
577    127, 255,  0, 45,
578    170, 255,  0,255,
579    212, 255, 55, 45,
580    255, 255,255,  0};
581  
582  // Gradient palette "Blue_Cyan_Yellow_gp", originally from
583  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
584  // converted for FastLED with gammas (2.6, 2.2, 2.5)
585  // Size: 20 bytes of program space.
586  
587  DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
588      0,   0,  0,255,
589     63,   0, 55,255,
590    127,   0,255,255,
591    191,  42,255, 45,
592    255, 255,255,  0};
593  
594    // Gradient palette "bhw1_28_gp", originally from
595  // http://soliton.vm.bytemark.co.uk/pub/cpt-city/bhw/bhw1/tn/bhw1_28.png.index.html
596  // converted for FastLED with gammas (2.6, 2.2, 2.5)
597  // Size: 32 bytes of program space.
598  
599  DEFINE_GRADIENT_PALETTE( bhw1_28_gp ) {
600      0,  75,  1,221,
601     30, 252, 73,255,
602     48, 169,  0,242,
603    119,   0,149,242,
604    170,  43,  0,242,
605    206, 252, 73,255,
606    232,  78, 12,214,
607    255,   0,149,242};
608  
609  
610  
611  // Single array of defined cpt-city color palettes.
612  // This will let us programmatically choose one based on
613  // a number, rather than having to activate each explicitly 
614  // by name every time.
615  // Since it is const, this array could also be moved 
616  // into PROGMEM to save SRAM, but for simplicity of illustration
617  // we'll keep it in a regular SRAM array.
618  //
619  // This list of color palettes acts as a "playlist"; you can
620  // add or delete, or re-arrange as you wish.
621  const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
622    bhw1_28_gp,
623    Sunset_Real_gp,
624    es_rivendell_15_gp,
625    es_ocean_breeze_036_gp,
626    rgi_15_gp,
627    retro2_16_gp,
628    Analogous_1_gp,
629    es_pinksplash_08_gp,
630    Coral_reef_gp,
631    es_ocean_breeze_068_gp,
632    es_pinksplash_07_gp,
633    es_vintage_01_gp,
634    departure_gp,
635    es_landscape_64_gp,
636    es_landscape_33_gp,
637    rainbowsherbet_gp,
638    gr65_hult_gp,
639    gr64_hult_gp,
640    GMT_drywet_gp,
641    ib_jul01_gp,
642    es_vintage_57_gp,
643    ib15_gp,
644    Fuschia_7_gp,
645    es_emerald_dragon_08_gp,
646    lava_gp,
647    fire_gp,
648    Colorfull_gp,
649    Magenta_Evening_gp,
650    Pink_Purple_gp,
651    es_autumn_19_gp,
652    BlacK_Blue_Magenta_White_gp,
653    BlacK_Magenta_Red_gp,
654    BlacK_Red_Magenta_Yellow_gp,
655    Blue_Cyan_Yellow_gp };
656  
657  
658  // Count of how many cpt-city gradients are defined:
659  const uint8_t gGradientPaletteCount = 
660    sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
661  
662  
663  
664    void loop()
665  {
666    EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {
667      gCurrentPaletteNumber = addmod8( gCurrentPaletteNumber, 1, gGradientPaletteCount);
668      gTargetPalette = gGradientPalettes[ gCurrentPaletteNumber ];
669    }
670  
671    EVERY_N_MILLISECONDS(40) {
672      nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
673    }
674    
675    colorwaves( leds, NUM_LEDS, gCurrentPalette);
676  
677    FastLED.show();
678    FastLED.delay(20);
679  }
680