Advertisement
Guest User

Untitled

a guest
May 18th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.63 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
  4. #warning "Requires FastLED 3.1 or later; check github for latest code."
  5. #endif
  6.  
  7.  
  8. #define NUM_LEDS 280
  9. #define LED_TYPE WS2812B
  10. #define COLOR_ORDER GRB
  11. #define DATA_PIN 53
  12.  
  13. //#define CLK_PIN 4
  14. #define VOLTS 5
  15. #define MAX_MA 50000
  16.  
  17. #define FRAMES_PER_SECOND 15
  18. #define LEAD_COUNT 10
  19. #define TRAIL_LENGTH 200
  20. #define TRAIL_DIM_BY 60
  21. #define MIN_DELAY 1500
  22. #define MAX_DELAY 3000
  23. #define DRIP_HUE1 233
  24. #define DRIP_HUE_SKEW 0
  25. #define DRIP_SAT 127
  26. #define MIRROR true
  27. #define MIRROR_INV_COLOR true
  28. #define STOP_SEGMENT 280
  29. #define MAX_BRIGHTNESS 255
  30.  
  31. static float pulseSpeed = 0.4; // Larger value gives faster pulse.
  32.  
  33. uint8_t hueA = 30; // Start hue at valueMin.
  34. uint8_t satA = 100; // Start saturation at valueMin.
  35. float valueMin = 60.0; // Pulse minimum value (Should be less then valueMax).
  36.  
  37. uint8_t hueB = 35; // End hue at valueMax.
  38. uint8_t satB = 200; // End saturation at valueMax.
  39. float valueMax = 200.0; // Pulse maximum value (Should be larger then valueMin).
  40.  
  41. uint8_t hue = hueA; // Do Not Edit
  42. uint8_t sat = satA; // Do Not Edit
  43. float val = valueMin; // Do Not Edit
  44. uint8_t hueDelta = hueA - hueB; // Do Not Edit
  45. static float delta = (valueMax - valueMin) / 2.35040238; // Do Not Edit
  46. uint8_t hueChase = 0;
  47.  
  48. byte led_pos = 0;
  49. byte inv_led_pos = NUM_LEDS-1;
  50.  
  51. // TwinkleFOX: Twinkling 'holiday' lights that fade in and out.
  52. // Colors are chosen from a palette; a few palettes are provided.
  53. //
  54. // This December 2015 implementation improves on the December 2014 version
  55. // in several ways:
  56. // - smoother fading, compatible with any colors and any palettes
  57. // - easier control of twinkle speed and twinkle density
  58. // - supports an optional 'background color'
  59. // - takes even less RAM: zero RAM overhead per pixel
  60. // - illustrates a couple of interesting techniques (uh oh...)
  61. //
  62. // The idea behind this (new) implementation is that there's one
  63. // basic, repeating pattern that each pixel follows like a waveform:
  64. // The brightness rises from 0..255 and then falls back down to 0.
  65. // The brightness at any given point in time can be determined as
  66. // as a function of time, for example:
  67. // brightness = sine( time ); // a sine wave of brightness over time
  68. //
  69. // So the way this implementation works is that every pixel follows
  70. // the exact same wave function over time. In this particular case,
  71. // I chose a sawtooth triangle wave (triwave8) rather than a sine wave,
  72. // but the idea is the same: brightness = triwave8( time ).
  73. //
  74. // Of course, if all the pixels used the exact same wave form, and
  75. // if they all used the exact same 'clock' for their 'time base', all
  76. // the pixels would brighten and dim at once -- which does not look
  77. // like twinkling at all.
  78. //
  79. // So to achieve random-looking twinkling, each pixel is given a
  80. // slightly different 'clock' signal. Some of the clocks run faster,
  81. // some run slower, and each 'clock' also has a random offset from zero.
  82. // The net result is that the 'clocks' for all the pixels are always out
  83. // of sync from each other, producing a nice random distribution
  84. // of twinkles.
  85. //
  86. // The 'clock speed adjustment' and 'time offset' for each pixel
  87. // are generated randomly. One (normal) approach to implementing that
  88. // would be to randomly generate the clock parameters for each pixel
  89. // at startup, and store them in some arrays. However, that consumes
  90. // a great deal of precious RAM, and it turns out to be totally
  91. // unnessary! If the random number generate is 'seeded' with the
  92. // same starting value every time, it will generate the same sequence
  93. // of values every time. So the clock adjustment parameters for each
  94. // pixel are 'stored' in a pseudo-random number generator! The PRNG
  95. // is reset, and then the first numbers out of it are the clock
  96. // adjustment parameters for the first pixel, the second numbers out
  97. // of it are the parameters for the second pixel, and so on.
  98. // In this way, we can 'store' a stable sequence of thousands of
  99. // random clock adjustment parameters in literally two bytes of RAM.
  100. //
  101. // There's a little bit of fixed-point math involved in applying the
  102. // clock speed adjustments, which are expressed in eighths. Each pixel's
  103. // clock speed ranges from 8/8ths of the system clock (i.e. 1x) to
  104. // 23/8ths of the system clock (i.e. nearly 3x).
  105. //
  106. // On a basic Arduino Uno or Leonardo, this code can twinkle 300+ pixels
  107. // smoothly at over 50 updates per seond.
  108. //
  109. // -Mark Kriegsman, December 2015
  110.  
  111. CRGBArray<NUM_LEDS> leds;
  112.  
  113. // Overall twinkle speed.
  114. // 0 (VERY slow) to 8 (VERY fast).
  115. // 4, 5, and 6 are recommended, default is 4.
  116. #define TWINKLE_SPEED 4
  117.  
  118. // Overall twinkle density.
  119. // 0 (NONE lit) to 8 (ALL lit at once).
  120. // Default is 5.
  121. #define TWINKLE_DENSITY 2
  122.  
  123. // How often to change color palettes.
  124. #define SECONDS_PER_PALETTE 30
  125. // Also: toward the bottom of the file is an array
  126. // called "ActivePaletteList" which controls which color
  127. // palettes are used; you can add or remove color palettes
  128. // from there freely.
  129.  
  130. // Background color for 'unlit' pixels
  131. // Can be set to CRGB::Black if desired.
  132. CRGB gBackgroundColor = CRGB::Black;
  133. // Example of dim incandescent fairy light background color
  134. // CRGB gBackgroundColor = CRGB(CRGB::FairyLight).nscale8_video(16);
  135.  
  136. // If AUTO_SELECT_BACKGROUND_COLOR is set to 1,
  137. // then for any palette where the first two entries
  138. // are the same, a dimmed version of that color will
  139. // automatically be used as the background color.
  140. #define AUTO_SELECT_BACKGROUND_COLOR 0
  141.  
  142. // If COOL_LIKE_INCANDESCENT is set to 1, colors will
  143. // fade out slighted 'reddened', similar to how
  144. // incandescent bulbs change color as they get dim down.
  145. #define COOL_LIKE_INCANDESCENT 1
  146.  
  147. #define BRIGHTNESS 10
  148. CRGBPalette16 gCurrentPalette;
  149. CRGBPalette16 gTargetPalette;
  150.  
  151. void setup() {
  152. delay( 3000 ); //safety startup delay
  153. FastLED.setMaxPowerInVoltsAndMilliamps( VOLTS, MAX_MA);
  154. FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
  155. .setCorrection(TypicalLEDStrip);
  156.  
  157. chooseNextColorPalette(gTargetPalette);
  158. randomSeed(analogRead(0));
  159. FastLED.setBrightness(MAX_BRIGHTNESS);
  160.  
  161.  
  162.  
  163.  
  164. }
  165.  
  166. extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
  167. extern const uint8_t gGradientPaletteCount;
  168.  
  169. // Current palette number from the 'playlist' of color palettes
  170. uint8_t gCurrentPaletteNumber = 0;
  171. byte trail_pos = 0;
  172. byte lead_pos = 0;
  173. CHSV color;
  174. CHSV alt_color;
  175.  
  176. void loop()
  177. {
  178. for(int i = 0; i < 100; i++) {
  179. EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {
  180. chooseNextColorPalette( gTargetPalette );
  181. }
  182.  
  183. EVERY_N_MILLISECONDS( 10 ) {
  184. nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 12);
  185. }
  186.  
  187. drawTwinkles( leds);
  188.  
  189. FastLED.show();
  190. }
  191.  
  192. // meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay
  193. meteorRain(0xff,0xff,0xff,10, 64, true, 30);
  194. meteorRain(0xB7,0x00,0xFE,10, 64, true, 30);
  195.  
  196. // theatherChase - Color (red, green, blue), speed delay
  197. //theaterChase(0xff,0,0,150);
  198. //theaterChase(0xff,0,0,150);
  199.  
  200.  
  201. for(int b = 0; b < 500; b++) {
  202. FastLED.show();
  203.  
  204. // insert a delay to keep the framerate modest
  205. FastLED.delay(1000/FRAMES_PER_SECOND);
  206.  
  207. fadeToBlackBy(leds, NUM_LEDS, TRAIL_DIM_BY);
  208.  
  209. if (trail_pos == 0) {
  210. lead_pos++;
  211. if (lead_pos >= LEAD_COUNT) {
  212. color = CHSV(DRIP_HUE1+(DRIP_HUE_SKEW*led_pos),DRIP_SAT,255);
  213. alt_color = CHSV(DRIP_HUE1+(DRIP_HUE_SKEW*led_pos)+127,DRIP_SAT,255);
  214. leds[led_pos] = color;
  215. if (MIRROR) {
  216. if (MIRROR_INV_COLOR) leds[inv_led_pos] = alt_color;
  217. else leds[inv_led_pos] = color;
  218. }
  219. inv_led_pos--;
  220. led_pos++;
  221. } else {
  222. CHSV color_1 = CHSV(DRIP_HUE1+LEAD_COUNT-lead_pos,DRIP_SAT,map(lead_pos, 1, LEAD_COUNT, 1, 255));
  223. CHSV color_2 = CHSV(DRIP_HUE1+LEAD_COUNT-lead_pos,DRIP_SAT,map(lead_pos, 1, LEAD_COUNT, 1, 64));
  224. CHSV alt_color_1 = CHSV(DRIP_HUE1+LEAD_COUNT-lead_pos+127,DRIP_SAT,map(lead_pos, 1, LEAD_COUNT, 1, 255));
  225. CHSV alt_color_2 = CHSV(DRIP_HUE1+LEAD_COUNT-lead_pos+127,DRIP_SAT,map(lead_pos, 1, LEAD_COUNT, 1, 64));
  226.  
  227. if (MIRROR) {
  228. leds[inv_led_pos-1] = color_2;
  229. leds[inv_led_pos] = color_1;
  230. if (MIRROR_INV_COLOR) {
  231. leds[inv_led_pos-1] = alt_color_2;
  232. leds[inv_led_pos] = alt_color_1;
  233. }
  234. }
  235. leds[led_pos] = color_1;
  236. leds[led_pos+1] = color_2;
  237. }
  238. }
  239.  
  240. if (led_pos >= STOP_SEGMENT-1) {
  241. trail_pos++;
  242. if (trail_pos <= TRAIL_LENGTH*0.50) {
  243. leds[led_pos] = color;
  244. if (MIRROR) {
  245. leds[inv_led_pos] = color;
  246. if (MIRROR_INV_COLOR) {
  247. leds[inv_led_pos] = alt_color;
  248. }
  249. }
  250. }
  251. if (trail_pos >= TRAIL_LENGTH) {
  252. leds[led_pos] = CHSV(0,0,0);
  253. if (MIRROR) leds[inv_led_pos] = CHSV(0,0,0);
  254. FastLED.delay(random(MIN_DELAY, MAX_DELAY));
  255. trail_pos = 0;
  256. led_pos = 0;
  257. lead_pos = 0;
  258. inv_led_pos = NUM_LEDS-1;
  259. }
  260. }
  261.  
  262. }
  263.  
  264. for(int c = 0; c < 1000; c++) {
  265.  
  266. EVERY_N_SECONDS( 7 ) {
  267. gCurrentPaletteNumber = addmod8( gCurrentPaletteNumber, 1, gGradientPaletteCount);
  268. gTargetPalette = gGradientPalettes[ gCurrentPaletteNumber ];
  269. }
  270.  
  271. EVERY_N_MILLISECONDS(40) {
  272. nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
  273. }
  274.  
  275. colorwaves( leds, NUM_LEDS, gCurrentPalette);
  276.  
  277. FastLED.show();
  278. FastLED.delay(20);
  279. }
  280.  
  281. }
  282.  
  283.  
  284. // This function loops over each pixel, calculates the
  285. // adjusted 'clock' that this pixel should use, and calls
  286. // "CalculateOneTwinkle" on each pixel. It then displays
  287. // either the twinkle color of the background color,
  288. // whichever is brighter.
  289. void drawTwinkles( CRGBSet& L)
  290. {
  291. // "PRNG16" is the pseudorandom number generator
  292. // It MUST be reset to the same starting value each time
  293. // this function is called, so that the sequence of 'random'
  294. // numbers that it generates is (paradoxically) stable.
  295. uint16_t PRNG16 = 11337;
  296.  
  297. uint32_t clock32 = millis();
  298.  
  299. // Set up the background color, "bg".
  300. // if AUTO_SELECT_BACKGROUND_COLOR == 1, and the first two colors of
  301. // the current palette are identical, then a deeply faded version of
  302. // that color is used for the background color
  303. CRGB bg;
  304. if( (AUTO_SELECT_BACKGROUND_COLOR == 1) &&
  305. (gCurrentPalette[0] == gCurrentPalette[1] )) {
  306. bg = gCurrentPalette[0];
  307. uint8_t bglight = bg.getAverageLight();
  308. if( bglight > 64) {
  309. bg.nscale8_video( 16); // very bright, so scale to 1/16th
  310. } else if( bglight > 16) {
  311. bg.nscale8_video( 64); // not that bright, so scale to 1/4th
  312. } else {
  313. bg.nscale8_video( 86); // dim, scale to 1/3rd.
  314. }
  315. } else {
  316. bg = gBackgroundColor; // just use the explicitly defined background color
  317. }
  318.  
  319. uint8_t backgroundBrightness = bg.getAverageLight();
  320.  
  321. for( CRGB& pixel: L) {
  322. PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
  323. uint16_t myclockoffset16= PRNG16; // use that number as clock offset
  324. PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
  325. // use that number as clock speed adjustment factor (in 8ths, from 8/8ths to 23/8ths)
  326. uint8_t myspeedmultiplierQ5_3 = ((((PRNG16 & 0xFF)>>4) + (PRNG16 & 0x0F)) & 0x0F) + 0x08;
  327. uint32_t myclock30 = (uint32_t)((clock32 * myspeedmultiplierQ5_3) >> 3) + myclockoffset16;
  328. uint8_t myunique8 = PRNG16 >> 8; // get 'salt' value for this pixel
  329.  
  330. // We now have the adjusted 'clock' for this pixel, now we call
  331. // the function that computes what color the pixel should be based
  332. // on the "brightness = f( time )" idea.
  333. CRGB c = computeOneTwinkle( myclock30, myunique8);
  334.  
  335. uint8_t cbright = c.getAverageLight();
  336. int16_t deltabright = cbright - backgroundBrightness;
  337. if( deltabright >= 32 || (!bg)) {
  338. // If the new pixel is significantly brighter than the background color,
  339. // use the new color.
  340. pixel = c;
  341. } else if( deltabright > 0 ) {
  342. // If the new pixel is just slightly brighter than the background color,
  343. // mix a blend of the new color and the background color
  344. pixel = blend( bg, c, deltabright * 8);
  345. } else {
  346. // if the new pixel is not at all brighter than the background color,
  347. // just use the background color.
  348. pixel = bg;
  349. }
  350. }
  351. }
  352.  
  353.  
  354. // This function takes a time in pseudo-milliseconds,
  355. // figures out brightness = f( time ), and also hue = f( time )
  356. // The 'low digits' of the millisecond time are used as
  357. // input to the brightness wave function.
  358. // The 'high digits' are used to select a color, so that the color
  359. // does not change over the course of the fade-in, fade-out
  360. // of one cycle of the brightness wave function.
  361. // The 'high digits' are also used to determine whether this pixel
  362. // should light at all during this cycle, based on the TWINKLE_DENSITY.
  363. CRGB computeOneTwinkle( uint32_t ms, uint8_t salt)
  364. {
  365. uint16_t ticks = ms >> (8-TWINKLE_SPEED);
  366. uint8_t fastcycle8 = ticks;
  367. uint16_t slowcycle16 = (ticks >> 8) + salt;
  368. slowcycle16 += sin8( slowcycle16);
  369. slowcycle16 = (slowcycle16 * 2053) + 1384;
  370. uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
  371.  
  372. uint8_t bright = 0;
  373. if( ((slowcycle8 & 0x0E)/2) < TWINKLE_DENSITY) {
  374. bright = attackDecayWave8( fastcycle8);
  375. }
  376.  
  377. uint8_t hue = slowcycle8 - salt;
  378. CRGB c;
  379. if( bright > 0) {
  380. c = ColorFromPalette( gCurrentPalette, hue, bright, NOBLEND);
  381. if( COOL_LIKE_INCANDESCENT == 1 ) {
  382. coolLikeIncandescent( c, fastcycle8);
  383. }
  384. } else {
  385. c = CRGB::Black;
  386. }
  387. return c;
  388. }
  389.  
  390.  
  391. // This function is like 'triwave8', which produces a
  392. // symmetrical up-and-down triangle sawtooth waveform, except that this
  393. // function produces a triangle wave with a faster attack and a slower decay:
  394. //
  395. // / \
  396. // / \
  397. // / \
  398. // / \
  399. //
  400.  
  401. uint8_t attackDecayWave8( uint8_t i)
  402. {
  403. if( i < 86) {
  404. return i * 3;
  405. } else {
  406. i -= 86;
  407. return 255 - (i + (i/2));
  408. }
  409. }
  410.  
  411. // This function takes a pixel, and if its in the 'fading down'
  412. // part of the cycle, it adjusts the color a little bit like the
  413. // way that incandescent bulbs fade toward 'red' as they dim.
  414. void coolLikeIncandescent( CRGB& c, uint8_t phase)
  415. {
  416. if( phase < 128) return;
  417.  
  418. uint8_t cooling = (phase - 128) >> 4;
  419. c.g = qsub8( c.g, cooling);
  420. c.b = qsub8( c.b, cooling * 2);
  421. }
  422.  
  423. // A mostly red palette with green accents and white trim.
  424. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  425. const TProgmemRGBPalette16 RedGreenWhite_p FL_PROGMEM =
  426. { CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  427. CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  428. CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
  429. CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green };
  430.  
  431. // A mostly (dark) green palette with red berries.
  432. #define Holly_Green 0x00580c
  433. #define Holly_Red 0xB00402
  434. const TProgmemRGBPalette16 Holly_p FL_PROGMEM =
  435. { Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  436. Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  437. Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  438. Holly_Green, Holly_Green, Holly_Green, Holly_Red
  439. };
  440.  
  441. // A red and white striped palette
  442. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  443. const TProgmemRGBPalette16 RedWhite_p FL_PROGMEM =
  444. { CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  445. CRGB::Gray, CRGB::Gray, CRGB::Gray, CRGB::Gray,
  446. CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  447. CRGB::Gray, CRGB::Gray, CRGB::Gray, CRGB::Gray };
  448.  
  449. // A mostly blue palette with white accents.
  450. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  451. const TProgmemRGBPalette16 BlueWhite_p FL_PROGMEM =
  452. { CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  453. CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  454. CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  455. CRGB::Blue, CRGB::Gray, CRGB::Gray, CRGB::Gray };
  456.  
  457. // A pure "fairy light" palette with some brightness variations
  458. #define HALFFAIRY ((CRGB::FairyLight & 0xFEFEFE) / 2)
  459. #define QUARTERFAIRY ((CRGB::FairyLight & 0xFCFCFC) / 4)
  460. const TProgmemRGBPalette16 FairyLight_p FL_PROGMEM =
  461. { CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight,
  462. HALFFAIRY, HALFFAIRY, CRGB::FairyLight, CRGB::FairyLight,
  463. QUARTERFAIRY, QUARTERFAIRY, CRGB::FairyLight, CRGB::FairyLight,
  464. CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight };
  465.  
  466. // A palette of soft snowflakes with the occasional bright one
  467. const TProgmemRGBPalette16 Snow_p FL_PROGMEM =
  468. { 0x304048, 0x304048, 0x304048, 0x304048,
  469. 0x304048, 0x304048, 0x304048, 0x304048,
  470. 0x304048, 0x304048, 0x304048, 0x304048,
  471. 0x304048, 0x304048, 0x304048, 0xE0F0FF };
  472.  
  473. // A palette reminiscent of large 'old-school' C9-size tree lights
  474. // in the five classic colors: red, orange, green, blue, and white.
  475. #define C9_Red 0xB80400
  476. #define C9_Orange 0x902C02
  477. #define C9_Green 0x046002
  478. #define C9_Blue 0x070758
  479. #define C9_White 0x606820
  480. const TProgmemRGBPalette16 RetroC9_p FL_PROGMEM =
  481. { C9_Red, C9_Orange, C9_Red, C9_Orange,
  482. C9_Orange, C9_Red, C9_Orange, C9_Red,
  483. C9_Green, C9_Green, C9_Green, C9_Green,
  484. C9_Blue, C9_Blue, C9_Blue,
  485. C9_White
  486. };
  487.  
  488. // A cold, icy pale blue palette
  489. #define Ice_Blue1 0x0C1040
  490. #define Ice_Blue2 0x182080
  491. #define Ice_Blue3 0x5080C0
  492. const TProgmemRGBPalette16 Ice_p FL_PROGMEM =
  493. {
  494. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  495. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  496. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  497. Ice_Blue2, Ice_Blue2, Ice_Blue2, Ice_Blue3
  498. };
  499.  
  500.  
  501. // Add or remove palette names from this list to control which color
  502. // palettes are used, and in what order.
  503. const TProgmemRGBPalette16* ActivePaletteList[] = {
  504. //&RetroC9_p,
  505. //&BlueWhite_p,
  506. //&RainbowColors_p,
  507. &FairyLight_p,
  508. //&RedGreenWhite_p,
  509. //&PartyColors_p,
  510. //&RedWhite_p,
  511. &Snow_p,
  512. //&Holly_p,
  513. &Ice_p
  514. };
  515.  
  516.  
  517. // Advance to the next color palette in the list (above).
  518. void chooseNextColorPalette( CRGBPalette16& pal)
  519. {
  520. const uint8_t numberOfPalettes = sizeof(ActivePaletteList) / sizeof(ActivePaletteList[0]);
  521. static uint8_t whichPalette = -1;
  522. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  523.  
  524. pal = *(ActivePaletteList[whichPalette]);
  525. }
  526.  
  527. void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
  528.  
  529. for (int j=0; j<50; j++) { //do 10 cycles of chasing
  530.  
  531. for (int q=0; q < 7; q++) {
  532. for (int i=0; i < NUM_LEDS; i=i+7) {
  533. setPixel(i+q, red, green, blue); //turn every third pixel on
  534. }
  535. showStrip();
  536.  
  537. delay(SpeedDelay);
  538.  
  539. for (int i=0; i < NUM_LEDS; i=i+7) {
  540. setPixel(i+q, 0,0,0); //turn every third pixel off
  541. }
  542. }
  543. }
  544. }
  545.  
  546. void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
  547. setAll(0,0,0);
  548.  
  549. for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
  550.  
  551.  
  552. // fade brightness all LEDs one step
  553. for(int j=0; j<NUM_LEDS; j++) {
  554. if( (!meteorRandomDecay) || (random(10)>5) ) {
  555. fadeToBlack(j, meteorTrailDecay );
  556. }
  557. }
  558.  
  559. // draw meteor
  560. for(int j = 0; j < meteorSize; j++) {
  561. if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
  562. setPixel(i-j, red, green, blue);
  563. }
  564. }
  565.  
  566. showStrip();
  567. delay(SpeedDelay);
  568. }
  569. }
  570.  
  571. // used by meteorrain
  572. void fadeToBlack(int ledNo, byte fadeValue) {
  573. #ifdef ADAFRUIT_NEOPIXEL_H
  574. // NeoPixel
  575. uint32_t oldColor;
  576. uint8_t r, g, b;
  577. int value;
  578.  
  579. oldColor = strip.getPixelColor(ledNo);
  580. r = (oldColor & 0x00ff0000UL) >> 16;
  581. g = (oldColor & 0x0000ff00UL) >> 8;
  582. b = (oldColor & 0x000000ffUL);
  583.  
  584. r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
  585. g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
  586. b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
  587.  
  588. strip.setPixelColor(ledNo, r,g,b);
  589. #endif
  590. #ifndef ADAFRUIT_NEOPIXEL_H
  591. // FastLED
  592. leds[ledNo].fadeToBlackBy( fadeValue );
  593. #endif
  594. }
  595.  
  596. // Apply LED color changes
  597. void showStrip() {
  598. #ifdef ADAFRUIT_NEOPIXEL_H
  599. // NeoPixel
  600. strip.show();
  601. #endif
  602. #ifndef ADAFRUIT_NEOPIXEL_H
  603. // FastLED
  604. FastLED.show();
  605. #endif
  606. }
  607.  
  608. // Set a LED color (not yet visible)
  609. void setPixel(int Pixel, byte red, byte green, byte blue) {
  610. #ifdef ADAFRUIT_NEOPIXEL_H
  611. // NeoPixel
  612. strip.setPixelColor(Pixel, strip.Color(red, green, blue));
  613. #endif
  614. #ifndef ADAFRUIT_NEOPIXEL_H
  615. // FastLED
  616. leds[Pixel].r = red;
  617. leds[Pixel].g = green;
  618. leds[Pixel].b = blue;
  619. #endif
  620. }
  621.  
  622. // Set all LEDs to a given color and apply it (visible)
  623. void setAll(byte red, byte green, byte blue) {
  624. for(int i = 0; i < NUM_LEDS; i++ ) {
  625. setPixel(i, red, green, blue);
  626. }
  627. showStrip();
  628. }
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641. void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette)
  642. {
  643. static uint16_t sPseudotime = 0;
  644. static uint16_t sLastMillis = 0;
  645. static uint16_t sHue16 = 0;
  646.  
  647. uint8_t sat8 = beatsin88( 87, 220, 250);
  648. uint8_t brightdepth = beatsin88( 341, 96, 224);
  649. uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
  650. uint8_t msmultiplier = beatsin88(147, 23, 60);
  651.  
  652. uint16_t hue16 = sHue16;//gHue * 256;
  653. uint16_t hueinc16 = beatsin88(113, 300, 1500);
  654.  
  655. uint16_t ms = millis();
  656. uint16_t deltams = ms - sLastMillis ;
  657. sLastMillis = ms;
  658. sPseudotime += deltams * msmultiplier;
  659. sHue16 += deltams * beatsin88( 400, 5,9);
  660. uint16_t brightnesstheta16 = sPseudotime;
  661.  
  662. for( uint16_t i = 0 ; i < numleds; i++) {
  663. hue16 += hueinc16;
  664. uint8_t hue8 = hue16 / 256;
  665. uint16_t h16_128 = hue16 >> 7;
  666. if( h16_128 & 0x100) {
  667. hue8 = 255 - (h16_128 >> 1);
  668. } else {
  669. hue8 = h16_128 >> 1;
  670. }
  671.  
  672. brightnesstheta16 += brightnessthetainc16;
  673. uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
  674.  
  675. uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
  676. uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
  677. bri8 += (255 - brightdepth);
  678.  
  679. uint8_t index = hue8;
  680. //index = triwave8( index);
  681. index = scale8( index, 240);
  682.  
  683. CRGB newcolor = ColorFromPalette( palette, index, bri8);
  684.  
  685. uint16_t pixelnumber = i;
  686. pixelnumber = (numleds-1) - pixelnumber;
  687.  
  688. nblend( ledarray[pixelnumber], newcolor, 128);
  689. }
  690. }
  691.  
  692. // Alternate rendering function just scrolls the current palette
  693. // across the defined LED strip.
  694. void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette)
  695. {
  696. static uint8_t startindex = 0;
  697. startindex--;
  698. fill_palette( ledarray, numleds, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND);
  699. }
  700.  
  701.  
  702.  
  703.  
  704.  
  705. // Gradient Color Palette definitions for 33 different cpt-city color palettes.
  706. // 956 bytes of PROGMEM for all of the palettes together,
  707. // +618 bytes of PROGMEM for gradient palette code (AVR).
  708. // 1,494 bytes total for all 34 color palettes and associated code.
  709.  
  710. // Gradient palette "ib_jul01_gp", originally from
  711. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/xmas/tn/ib_jul01.png.index.html
  712. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  713. // Size: 16 bytes of program space.
  714.  
  715. DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
  716. 0, 194, 1, 1,
  717. 94, 1, 29, 18,
  718. 132, 57,131, 28,
  719. 255, 113, 1, 1};
  720.  
  721. // Gradient palette "es_vintage_57_gp", originally from
  722. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html
  723. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  724. // Size: 20 bytes of program space.
  725.  
  726. DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
  727. 0, 2, 1, 1,
  728. 53, 18, 1, 0,
  729. 104, 69, 29, 1,
  730. 153, 167,135, 10,
  731. 255, 46, 56, 4};
  732.  
  733. // Gradient palette "es_vintage_01_gp", originally from
  734. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
  735. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  736. // Size: 32 bytes of program space.
  737.  
  738. DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
  739. 0, 4, 1, 1,
  740. 51, 16, 0, 1,
  741. 76, 97,104, 3,
  742. 101, 255,131, 19,
  743. 127, 67, 9, 4,
  744. 153, 16, 0, 1,
  745. 229, 4, 1, 1,
  746. 255, 4, 1, 1};
  747.  
  748. // Gradient palette "es_rivendell_15_gp", originally from
  749. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html
  750. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  751. // Size: 20 bytes of program space.
  752.  
  753. DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
  754. 0, 1, 14, 5,
  755. 101, 16, 36, 14,
  756. 165, 56, 68, 30,
  757. 242, 150,156, 99,
  758. 255, 150,156, 99};
  759.  
  760. // Gradient palette "rgi_15_gp", originally from
  761. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
  762. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  763. // Size: 36 bytes of program space.
  764.  
  765. DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
  766. 0, 4, 1, 31,
  767. 31, 55, 1, 16,
  768. 63, 197, 3, 7,
  769. 95, 59, 2, 17,
  770. 127, 6, 2, 34,
  771. 159, 39, 6, 33,
  772. 191, 112, 13, 32,
  773. 223, 56, 9, 35,
  774. 255, 22, 6, 38};
  775.  
  776. // Gradient palette "retro2_16_gp", originally from
  777. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
  778. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  779. // Size: 8 bytes of program space.
  780.  
  781. DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
  782. 0, 188,135, 1,
  783. 255, 46, 7, 1};
  784.  
  785. // Gradient palette "Analogous_1_gp", originally from
  786. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
  787. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  788. // Size: 20 bytes of program space.
  789.  
  790. DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
  791. 0, 3, 0,255,
  792. 63, 23, 0,255,
  793. 127, 67, 0,255,
  794. 191, 142, 0, 45,
  795. 255, 255, 0, 0};
  796.  
  797. // Gradient palette "es_pinksplash_08_gp", originally from
  798. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
  799. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  800. // Size: 20 bytes of program space.
  801.  
  802. DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
  803. 0, 126, 11,255,
  804. 127, 197, 1, 22,
  805. 175, 210,157,172,
  806. 221, 157, 3,112,
  807. 255, 157, 3,112};
  808.  
  809. // Gradient palette "es_pinksplash_07_gp", originally from
  810. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html
  811. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  812. // Size: 28 bytes of program space.
  813.  
  814. DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
  815. 0, 229, 1, 1,
  816. 61, 242, 4, 63,
  817. 101, 255, 12,255,
  818. 127, 249, 81,252,
  819. 153, 255, 11,235,
  820. 193, 244, 5, 68,
  821. 255, 232, 1, 5};
  822.  
  823. // Gradient palette "Coral_reef_gp", originally from
  824. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html
  825. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  826. // Size: 24 bytes of program space.
  827.  
  828. DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
  829. 0, 40,199,197,
  830. 50, 10,152,155,
  831. 96, 1,111,120,
  832. 96, 43,127,162,
  833. 139, 10, 73,111,
  834. 255, 1, 34, 71};
  835.  
  836. // Gradient palette "es_ocean_breeze_068_gp", originally from
  837. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html
  838. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  839. // Size: 24 bytes of program space.
  840.  
  841. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
  842. 0, 100,156,153,
  843. 51, 1, 99,137,
  844. 101, 1, 68, 84,
  845. 104, 35,142,168,
  846. 178, 0, 63,117,
  847. 255, 1, 10, 10};
  848.  
  849. // Gradient palette "es_ocean_breeze_036_gp", originally from
  850. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
  851. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  852. // Size: 16 bytes of program space.
  853.  
  854. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
  855. 0, 1, 6, 7,
  856. 89, 1, 99,111,
  857. 153, 144,209,255,
  858. 255, 0, 73, 82};
  859.  
  860. // Gradient palette "departure_gp", originally from
  861. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
  862. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  863. // Size: 88 bytes of program space.
  864.  
  865. DEFINE_GRADIENT_PALETTE( departure_gp ) {
  866. 0, 8, 3, 0,
  867. 42, 23, 7, 0,
  868. 63, 75, 38, 6,
  869. 84, 169, 99, 38,
  870. 106, 213,169,119,
  871. 116, 255,255,255,
  872. 138, 135,255,138,
  873. 148, 22,255, 24,
  874. 170, 0,255, 0,
  875. 191, 0,136, 0,
  876. 212, 0, 55, 0,
  877. 255, 0, 55, 0};
  878.  
  879. // Gradient palette "es_landscape_64_gp", originally from
  880. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
  881. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  882. // Size: 36 bytes of program space.
  883.  
  884. DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
  885. 0, 0, 0, 0,
  886. 37, 2, 25, 1,
  887. 76, 15,115, 5,
  888. 127, 79,213, 1,
  889. 128, 126,211, 47,
  890. 130, 188,209,247,
  891. 153, 144,182,205,
  892. 204, 59,117,250,
  893. 255, 1, 37,192};
  894.  
  895. // Gradient palette "es_landscape_33_gp", originally from
  896. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
  897. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  898. // Size: 24 bytes of program space.
  899.  
  900. DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
  901. 0, 1, 5, 0,
  902. 19, 32, 23, 1,
  903. 38, 161, 55, 1,
  904. 63, 229,144, 1,
  905. 66, 39,142, 74,
  906. 255, 1, 4, 1};
  907.  
  908. // Gradient palette "rainbowsherbet_gp", originally from
  909. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
  910. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  911. // Size: 28 bytes of program space.
  912.  
  913. DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
  914. 0, 255, 33, 4,
  915. 43, 255, 68, 25,
  916. 86, 255, 7, 25,
  917. 127, 255, 82,103,
  918. 170, 255,255,242,
  919. 209, 42,255, 22,
  920. 255, 87,255, 65};
  921.  
  922. // Gradient palette "gr65_hult_gp", originally from
  923. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
  924. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  925. // Size: 24 bytes of program space.
  926.  
  927. DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
  928. 0, 247,176,247,
  929. 48, 255,136,255,
  930. 89, 220, 29,226,
  931. 160, 7, 82,178,
  932. 216, 1,124,109,
  933. 255, 1,124,109};
  934.  
  935. // Gradient palette "gr64_hult_gp", originally from
  936. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
  937. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  938. // Size: 32 bytes of program space.
  939.  
  940. DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
  941. 0, 1,124,109,
  942. 66, 1, 93, 79,
  943. 104, 52, 65, 1,
  944. 130, 115,127, 1,
  945. 150, 52, 65, 1,
  946. 201, 1, 86, 72,
  947. 239, 0, 55, 45,
  948. 255, 0, 55, 45};
  949.  
  950. // Gradient palette "GMT_drywet_gp", originally from
  951. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
  952. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  953. // Size: 28 bytes of program space.
  954.  
  955. DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
  956. 0, 47, 30, 2,
  957. 42, 213,147, 24,
  958. 84, 103,219, 52,
  959. 127, 3,219,207,
  960. 170, 1, 48,214,
  961. 212, 1, 1,111,
  962. 255, 1, 7, 33};
  963.  
  964. // Gradient palette "ib15_gp", originally from
  965. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
  966. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  967. // Size: 24 bytes of program space.
  968.  
  969. DEFINE_GRADIENT_PALETTE( ib15_gp ) {
  970. 0, 113, 91,147,
  971. 72, 157, 88, 78,
  972. 89, 208, 85, 33,
  973. 107, 255, 29, 11,
  974. 141, 137, 31, 39,
  975. 255, 59, 33, 89};
  976.  
  977. // Gradient palette "Fuschia_7_gp", originally from
  978. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html
  979. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  980. // Size: 20 bytes of program space.
  981.  
  982. DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
  983. 0, 43, 3,153,
  984. 63, 100, 4,103,
  985. 127, 188, 5, 66,
  986. 191, 161, 11,115,
  987. 255, 135, 20,182};
  988.  
  989. // Gradient palette "es_emerald_dragon_08_gp", originally from
  990. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html
  991. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  992. // Size: 16 bytes of program space.
  993.  
  994. DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
  995. 0, 97,255, 1,
  996. 101, 47,133, 1,
  997. 178, 13, 43, 1,
  998. 255, 2, 10, 1};
  999.  
  1000. // Gradient palette "lava_gp", originally from
  1001. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
  1002. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1003. // Size: 52 bytes of program space.
  1004.  
  1005. DEFINE_GRADIENT_PALETTE( lava_gp ) {
  1006. 0, 0, 0, 0,
  1007. 46, 18, 0, 0,
  1008. 96, 113, 0, 0,
  1009. 108, 142, 3, 1,
  1010. 119, 175, 17, 1,
  1011. 146, 213, 44, 2,
  1012. 174, 255, 82, 4,
  1013. 188, 255,115, 4,
  1014. 202, 255,156, 4,
  1015. 218, 255,203, 4,
  1016. 234, 255,255, 4,
  1017. 244, 255,255, 71,
  1018. 255, 255,255,255};
  1019.  
  1020. // Gradient palette "fire_gp", originally from
  1021. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html
  1022. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1023. // Size: 28 bytes of program space.
  1024.  
  1025. DEFINE_GRADIENT_PALETTE( fire_gp ) {
  1026. 0, 1, 1, 0,
  1027. 76, 32, 5, 0,
  1028. 146, 192, 24, 0,
  1029. 197, 220,105, 5,
  1030. 240, 252,255, 31,
  1031. 250, 252,255,111,
  1032. 255, 255,255,255};
  1033.  
  1034. // Gradient palette "Colorfull_gp", originally from
  1035. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
  1036. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1037. // Size: 44 bytes of program space.
  1038.  
  1039. DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
  1040. 0, 10, 85, 5,
  1041. 25, 29,109, 18,
  1042. 60, 59,138, 42,
  1043. 93, 83, 99, 52,
  1044. 106, 110, 66, 64,
  1045. 109, 123, 49, 65,
  1046. 113, 139, 35, 66,
  1047. 116, 192,117, 98,
  1048. 124, 255,255,137,
  1049. 168, 100,180,155,
  1050. 255, 22,121,174};
  1051.  
  1052. // Gradient palette "Magenta_Evening_gp", originally from
  1053. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html
  1054. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1055. // Size: 28 bytes of program space.
  1056.  
  1057. DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
  1058. 0, 71, 27, 39,
  1059. 31, 130, 11, 51,
  1060. 63, 213, 2, 64,
  1061. 70, 232, 1, 66,
  1062. 76, 252, 1, 69,
  1063. 108, 123, 2, 51,
  1064. 255, 46, 9, 35};
  1065.  
  1066. // Gradient palette "Pink_Purple_gp", originally from
  1067. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
  1068. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1069. // Size: 44 bytes of program space.
  1070.  
  1071. DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
  1072. 0, 19, 2, 39,
  1073. 25, 26, 4, 45,
  1074. 51, 33, 6, 52,
  1075. 76, 68, 62,125,
  1076. 102, 118,187,240,
  1077. 109, 163,215,247,
  1078. 114, 217,244,255,
  1079. 122, 159,149,221,
  1080. 149, 113, 78,188,
  1081. 183, 128, 57,155,
  1082. 255, 146, 40,123};
  1083.  
  1084. // Gradient palette "Sunset_Real_gp", originally from
  1085. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
  1086. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1087. // Size: 28 bytes of program space.
  1088.  
  1089. DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
  1090. 0, 120, 0, 0,
  1091. 22, 179, 22, 0,
  1092. 51, 255,104, 0,
  1093. 85, 167, 22, 18,
  1094. 135, 100, 0,103,
  1095. 198, 16, 0,130,
  1096. 255, 0, 0,160};
  1097.  
  1098. // Gradient palette "es_autumn_19_gp", originally from
  1099. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
  1100. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1101. // Size: 52 bytes of program space.
  1102.  
  1103. DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
  1104. 0, 26, 1, 1,
  1105. 51, 67, 4, 1,
  1106. 84, 118, 14, 1,
  1107. 104, 137,152, 52,
  1108. 112, 113, 65, 1,
  1109. 122, 133,149, 59,
  1110. 124, 137,152, 52,
  1111. 135, 113, 65, 1,
  1112. 142, 139,154, 46,
  1113. 163, 113, 13, 1,
  1114. 204, 55, 3, 1,
  1115. 249, 17, 1, 1,
  1116. 255, 17, 1, 1};
  1117.  
  1118. // Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
  1119. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
  1120. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1121. // Size: 28 bytes of program space.
  1122.  
  1123. DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
  1124. 0, 0, 0, 0,
  1125. 42, 0, 0, 45,
  1126. 84, 0, 0,255,
  1127. 127, 42, 0,255,
  1128. 170, 255, 0,255,
  1129. 212, 255, 55,255,
  1130. 255, 255,255,255};
  1131.  
  1132. // Gradient palette "BlacK_Magenta_Red_gp", originally from
  1133. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
  1134. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1135. // Size: 20 bytes of program space.
  1136.  
  1137. DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
  1138. 0, 0, 0, 0,
  1139. 63, 42, 0, 45,
  1140. 127, 255, 0,255,
  1141. 191, 255, 0, 45,
  1142. 255, 255, 0, 0};
  1143.  
  1144. // Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
  1145. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
  1146. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1147. // Size: 28 bytes of program space.
  1148.  
  1149. DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
  1150. 0, 0, 0, 0,
  1151. 42, 42, 0, 0,
  1152. 84, 255, 0, 0,
  1153. 127, 255, 0, 45,
  1154. 170, 255, 0,255,
  1155. 212, 255, 55, 45,
  1156. 255, 255,255, 0};
  1157.  
  1158. // Gradient palette "Blue_Cyan_Yellow_gp", originally from
  1159. // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
  1160. // converted for FastLED with gammas (2.6, 2.2, 2.5)
  1161. // Size: 20 bytes of program space.
  1162.  
  1163. DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
  1164. 0, 0, 0,255,
  1165. 63, 0, 55,255,
  1166. 127, 0,255,255,
  1167. 191, 42,255, 45,
  1168. 255, 255,255, 0};
  1169.  
  1170.  
  1171. // Single array of defined cpt-city color palettes.
  1172. // This will let us programmatically choose one based on
  1173. // a number, rather than having to activate each explicitly
  1174. // by name every time.
  1175. // Since it is const, this array could also be moved
  1176. // into PROGMEM to save SRAM, but for simplicity of illustration
  1177. // we'll keep it in a regular SRAM array.
  1178. //
  1179. // This list of color palettes acts as a "playlist"; you can
  1180. // add or delete, or re-arrange as you wish.
  1181. const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
  1182. Sunset_Real_gp,
  1183. es_rivendell_15_gp,
  1184. es_ocean_breeze_036_gp,
  1185. rgi_15_gp,
  1186. retro2_16_gp,
  1187. Analogous_1_gp,
  1188. es_pinksplash_08_gp,
  1189. Coral_reef_gp,
  1190. es_ocean_breeze_068_gp,
  1191. es_pinksplash_07_gp,
  1192. es_vintage_01_gp,
  1193. departure_gp,
  1194. es_landscape_64_gp,
  1195. es_landscape_33_gp,
  1196. rainbowsherbet_gp,
  1197. gr65_hult_gp,
  1198. gr64_hult_gp,
  1199. GMT_drywet_gp,
  1200. ib_jul01_gp,
  1201. es_vintage_57_gp,
  1202. ib15_gp,
  1203. Fuschia_7_gp,
  1204. es_emerald_dragon_08_gp,
  1205. lava_gp,
  1206. fire_gp,
  1207. Colorfull_gp,
  1208. Magenta_Evening_gp,
  1209. Pink_Purple_gp,
  1210. es_autumn_19_gp,
  1211. BlacK_Blue_Magenta_White_gp,
  1212. BlacK_Magenta_Red_gp,
  1213. BlacK_Red_Magenta_Yellow_gp,
  1214. Blue_Cyan_Yellow_gp };
  1215.  
  1216.  
  1217. // Count of how many cpt-city gradients are defined:
  1218. const uint8_t gGradientPaletteCount =
  1219. sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement