Guest User

Untitled

a guest
Dec 17th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.97 KB | Source Code | 0 0
  1. #include "FastLED.h"
  2.  
  3.  
  4. #define NUM_LEDS 344
  5. #define LED_TYPE WS2812B
  6. #define COLOR_ORDER GRB
  7. #define DATA_PIN 6
  8. //#define CLK_PIN 4
  9. #define VOLTS 5
  10. #define MAX_MA 5000
  11.  
  12. // TwinkleFOX: Twinkling 'holiday' lights that fade in and out.
  13. // Colors are chosen from a palette; a few palettes are provided.
  14. //
  15. // This December 2015 implementation improves on the December 2014 version
  16. // in several ways:
  17. // - smoother fading, compatible with any colors and any palettes
  18. // - easier control of twinkle speed and twinkle density
  19. // - supports an optional 'background color'
  20. // - takes even less RAM: zero RAM overhead per pixel
  21. // - illustrates a couple of interesting techniques (uh oh...)
  22. //
  23. // The idea behind this (new) implementation is that there's one
  24. // basic, repeating pattern that each pixel follows like a waveform:
  25. // The brightness rises from 0..255 and then falls back down to 0.
  26. // The brightness at any given point in time can be determined as
  27. // as a function of time, for example:
  28. // brightness = sine( time ); // a sine wave of brightness over time
  29. //
  30. // So the way this implementation works is that every pixel follows
  31. // the exact same wave function over time. In this particular case,
  32. // I chose a sawtooth triangle wave (triwave8) rather than a sine wave,
  33. // but the idea is the same: brightness = triwave8( time ).
  34. //
  35. // Of course, if all the pixels used the exact same wave form, and
  36. // if they all used the exact same 'clock' for their 'time base', all
  37. // the pixels would brighten and dim at once -- which does not look
  38. // like twinkling at all.
  39. //
  40. // So to achieve random-looking twinkling, each pixel is given a
  41. // slightly different 'clock' signal. Some of the clocks run faster,
  42. // some run slower, and each 'clock' also has a random offset from zero.
  43. // The net result is that the 'clocks' for all the pixels are always out
  44. // of sync from each other, producing a nice random distribution
  45. // of twinkles.
  46. //
  47. // The 'clock speed adjustment' and 'time offset' for each pixel
  48. // are generated randomly. One (normal) approach to implementing that
  49. // would be to randomly generate the clock parameters for each pixel
  50. // at startup, and store them in some arrays. However, that consumes
  51. // a great deal of precious RAM, and it turns out to be totally
  52. // unnessary! If the random number generate is 'seeded' with the
  53. // same starting value every time, it will generate the same sequence
  54. // of values every time. So the clock adjustment parameters for each
  55. // pixel are 'stored' in a pseudo-random number generator! The PRNG
  56. // is reset, and then the first numbers out of it are the clock
  57. // adjustment parameters for the first pixel, the second numbers out
  58. // of it are the parameters for the second pixel, and so on.
  59. // In this way, we can 'store' a stable sequence of thousands of
  60. // random clock adjustment parameters in literally two bytes of RAM.
  61. //
  62. // There's a little bit of fixed-point math involved in applying the
  63. // clock speed adjustments, which are expressed in eighths. Each pixel's
  64. // clock speed ranges from 8/8ths of the system clock (i.e. 1x) to
  65. // 23/8ths of the system clock (i.e. nearly 3x).
  66. //
  67. // On a basic Arduino Uno or Leonardo, this code can twinkle 300+ pixels
  68. // smoothly at over 50 updates per seond.
  69. //
  70. // -Mark Kriegsman, December 2015
  71.  
  72. CRGBArray<NUM_LEDS> leds;
  73. CRGBSet strips[] = {
  74. leds(0, 149), //overhead led strip
  75. leds(150, 174), //figure 1
  76. leds(175, 198), // figure 2
  77. leds(199, 222), // figure 3
  78. leds(223, 272), // letters
  79. leds(273, 296), //figure 4
  80. leds(297, 344), // figure 5
  81. };
  82. #define NUM_STRIPS (sizeof(strips) / sizeof(*strips))
  83.  
  84.  
  85. // Overall twinkle speed.
  86. // 0 (VERY slow) to 8 (VERY fast).
  87. // 4, 5, and 6 are recommended, default is 4.
  88. #define TWINKLE_SPEED 4
  89.  
  90. // Overall twinkle density.
  91. // 0 (NONE lit) to 8 (ALL lit at once).
  92. // Default is 5.
  93. #define TWINKLE_DENSITY 7
  94.  
  95. // How often to change color palettes.
  96. #define SECONDS_PER_PALETTE 10
  97. // Also: toward the bottom of the file is an array
  98. // called "ActivePaletteList" which controls which color
  99. // palettes are used; you can add or remove color palettes
  100. // from there freely.
  101.  
  102. // Background color for 'unlit' pixels
  103. // Can be set to CRGB::Black if desired.
  104. CRGB gBackgroundColor = CRGB::Black;
  105. // Example of dim incandescent fairy light background color
  106. // CRGB gBackgroundColor = CRGB(CRGB::FairyLight).nscale8_video(16);
  107.  
  108. // If AUTO_SELECT_BACKGROUND_COLOR is set to 1,
  109. // then for any palette where the first two entries
  110. // are the same, a dimmed version of that color will
  111. // automatically be used as the background color.
  112. #define AUTO_SELECT_BACKGROUND_COLOR 1
  113.  
  114. // If COOL_LIKE_INCANDESCENT is set to 1, colors will
  115. // fade out slighted 'reddened', similar to how
  116. // incandescent bulbs change color as they get dim down.
  117. #define COOL_LIKE_INCANDESCENT 1
  118.  
  119.  
  120. CRGBPalette16 gCurrentPalette[NUM_STRIPS];
  121. CRGBPalette16 gTargetPalette[NUM_STRIPS];
  122.  
  123. void setup() {
  124. delay( 3000 ); //safety startup delay
  125. FastLED.setMaxPowerInVoltsAndMilliamps( VOLTS, MAX_MA);
  126. FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
  127. .setCorrection(TypicalLEDStrip);
  128.  
  129. /*
  130. for (auto i = 0; i < NUM_STRIPS; i++)
  131. chooseNextColorPalette( gTargetPalette[i]);
  132.  
  133. */
  134.  
  135. chooseNextColorPalette0( gTargetPalette[0]);
  136. chooseNextColorPalette1( gTargetPalette[1]);
  137. chooseNextColorPalette2( gTargetPalette[2]);
  138. chooseNextColorPalette3( gTargetPalette[3]);
  139. chooseNextColorPalette4( gTargetPalette[4]);
  140. chooseNextColorPalette5( gTargetPalette[5]);
  141. chooseNextColorPalette6( gTargetPalette[6]);
  142.  
  143. }
  144.  
  145.  
  146. void loop()
  147. {
  148. EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {
  149. for (uint8_t i = 0; i < NUM_STRIPS; i++)
  150.  
  151. switch (i){
  152.  
  153. case 0:
  154. chooseNextColorPalette0( gTargetPalette[i] );
  155. break;
  156.  
  157. case 1:
  158. chooseNextColorPalette1( gTargetPalette[i] );
  159. break;
  160.  
  161. case 2:
  162. chooseNextColorPalette2( gTargetPalette[i] );
  163. break;
  164.  
  165. case 3:
  166. chooseNextColorPalette3( gTargetPalette[i] );
  167. break;
  168.  
  169. case 4:
  170. chooseNextColorPalette4( gTargetPalette[i] );
  171. break;
  172.  
  173. case 5:
  174. chooseNextColorPalette5( gTargetPalette[i] );
  175. break;
  176.  
  177. case 6:
  178. chooseNextColorPalette6( gTargetPalette[i] );
  179. break;
  180.  
  181. default:
  182. chooseNextColorPalette0( gTargetPalette[i] );
  183. break;
  184. }
  185. }
  186.  
  187. EVERY_N_MILLISECONDS( 10 ) {
  188. for (uint8_t i = 0; i < NUM_STRIPS; i++)
  189. nblendPaletteTowardPalette( gCurrentPalette[i], gTargetPalette[i], 12);
  190. }
  191.  
  192. uint16_t offset = 0;
  193. for (auto& strip: strips) {
  194. drawTwinkles(strip, offset++);
  195. }
  196.  
  197. FastLED.show();
  198. }
  199.  
  200.  
  201. // This function loops over each pixel, calculates the
  202. // adjusted 'clock' that this pixel should use, and calls
  203. // "CalculateOneTwinkle" on each pixel. It then displays
  204. // either the twinkle color of the background color,
  205. // whichever is brighter.
  206. void drawTwinkles( CRGBSet& L, uint8_t strip)
  207. {
  208. // "PRNG16" is the pseudorandom number generator
  209. // It MUST be reset to the same starting value each time
  210. // this function is called, so that the sequence of 'random'
  211. // numbers that it generates is (paradoxically) stable.
  212. uint16_t PRNG16 = 11337 + strip;
  213.  
  214. uint32_t clock32 = millis();
  215.  
  216. // Set up the background color, "bg".
  217. // if AUTO_SELECT_BACKGROUND_COLOR == 1, and the first two colors of
  218. // the current palette are identical, then a deeply faded version of
  219. // that color is used for the background color
  220. CRGB bg;
  221. if( (AUTO_SELECT_BACKGROUND_COLOR == 1) &&
  222. (gCurrentPalette[strip][0] == gCurrentPalette[strip][1] )) {
  223. bg = gCurrentPalette[strip][0];
  224. uint8_t bglight = bg.getAverageLight();
  225. if( bglight > 64) {
  226. bg.nscale8_video( 16); // very bright, so scale to 1/16th
  227. } else if( bglight > 16) {
  228. bg.nscale8_video( 64); // not that bright, so scale to 1/4th
  229. } else {
  230. bg.nscale8_video( 86); // dim, scale to 1/3rd.
  231. }
  232. } else {
  233. bg = gBackgroundColor; // just use the explicitly defined background color
  234. }
  235.  
  236. uint8_t backgroundBrightness = bg.getAverageLight();
  237.  
  238. for( CRGB& pixel: L) {
  239. PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
  240. uint16_t myclockoffset16= PRNG16; // use that number as clock offset
  241. PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
  242. // use that number as clock speed adjustment factor (in 8ths, from 8/8ths to 23/8ths)
  243. uint8_t myspeedmultiplierQ5_3 = ((((PRNG16 & 0xFF)>>4) + (PRNG16 & 0x0F)) & 0x0F) + 0x08;
  244. uint32_t myclock30 = (uint32_t)((clock32 * myspeedmultiplierQ5_3) >> 3) + myclockoffset16;
  245. uint8_t myunique8 = PRNG16 >> 8; // get 'salt' value for this pixel
  246.  
  247. // We now have the adjusted 'clock' for this pixel, now we call
  248. // the function that computes what color the pixel should be based
  249. // on the "brightness = f( time )" idea.
  250. CRGB c = computeOneTwinkle( myclock30, myunique8, strip);
  251.  
  252. uint8_t cbright = c.getAverageLight();
  253. int16_t deltabright = cbright - backgroundBrightness;
  254. if( deltabright >= 32 || (!bg)) {
  255. // If the new pixel is significantly brighter than the background color,
  256. // use the new color.
  257. pixel = c;
  258. } else if( deltabright > 0 ) {
  259. // If the new pixel is just slightly brighter than the background color,
  260. // mix a blend of the new color and the background color
  261. pixel = blend( bg, c, deltabright * 8);
  262. } else {
  263. // if the new pixel is not at all brighter than the background color,
  264. // just use the background color.
  265. pixel = bg;
  266. }
  267. }
  268. }
  269.  
  270.  
  271. // This function takes a time in pseudo-milliseconds,
  272. // figures out brightness = f( time ), and also hue = f( time )
  273. // The 'low digits' of the millisecond time are used as
  274. // input to the brightness wave function.
  275. // The 'high digits' are used to select a color, so that the color
  276. // does not change over the course of the fade-in, fade-out
  277. // of one cycle of the brightness wave function.
  278. // The 'high digits' are also used to determine whether this pixel
  279. // should light at all during this cycle, based on the TWINKLE_DENSITY.
  280. CRGB computeOneTwinkle( uint32_t ms, uint8_t salt, uint8_t strip)
  281. {
  282. uint16_t ticks = ms >> (8-TWINKLE_SPEED);
  283. uint8_t fastcycle8 = ticks;
  284. uint16_t slowcycle16 = (ticks >> 8) + salt;
  285. slowcycle16 += sin8( slowcycle16);
  286. slowcycle16 = (slowcycle16 * 2053) + 1384;
  287. uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
  288.  
  289. uint8_t bright = 0;
  290. if( ((slowcycle8 & 0x0E)/2) < TWINKLE_DENSITY) {
  291. bright = attackDecayWave8( fastcycle8);
  292. }
  293.  
  294. uint8_t hue = slowcycle8 - salt;
  295. CRGB c;
  296. if( bright > 0) {
  297. c = ColorFromPalette( gCurrentPalette[strip], hue, bright, NOBLEND);
  298. if( COOL_LIKE_INCANDESCENT == 1 ) {
  299. coolLikeIncandescent( c, fastcycle8);
  300. }
  301. } else {
  302. c = CRGB::Black;
  303. }
  304. return c;
  305. }
  306.  
  307.  
  308. // This function is like 'triwave8', which produces a
  309. // symmetrical up-and-down triangle sawtooth waveform, except that this
  310. // function produces a triangle wave with a faster attack and a slower decay:
  311. //
  312. // / \
  313. // / \
  314. // / \
  315. // / \
  316. //
  317.  
  318. uint8_t attackDecayWave8( uint8_t i)
  319. {
  320. if( i < 86) {
  321. return i * 3;
  322. } else {
  323. i -= 86;
  324. return 255 - (i + (i/2));
  325. }
  326. }
  327.  
  328. // This function takes a pixel, and if its in the 'fading down'
  329. // part of the cycle, it adjusts the color a little bit like the
  330. // way that incandescent bulbs fade toward 'red' as they dim.
  331. void coolLikeIncandescent( CRGB& c, uint8_t phase)
  332. {
  333. if( phase < 128) return;
  334.  
  335. uint8_t cooling = (phase - 128) >> 4;
  336. c.g = qsub8( c.g, cooling);
  337. c.b = qsub8( c.b, cooling * 2);
  338. }
  339.  
  340. // A mostly red palette with green accents and white trim.
  341. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  342. const TProgmemRGBPalette16 RedGreenWhite_p FL_PROGMEM =
  343. { CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  344. CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  345. CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
  346. CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green };
  347.  
  348. // A mostly (dark) green palette with red berries.
  349. #define Holly_Green 0x00580c
  350. #define Holly_Red 0xB00402
  351. const TProgmemRGBPalette16 Holly_p FL_PROGMEM =
  352. { Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  353. Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  354. Holly_Green, Holly_Green, Holly_Green, Holly_Green,
  355. Holly_Green, Holly_Green, Holly_Green, Holly_Red
  356. };
  357.  
  358. // A red and white striped palette
  359. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  360. const TProgmemRGBPalette16 RedWhite_p FL_PROGMEM =
  361. { CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  362. CRGB::Gray, CRGB::Gray, CRGB::Gray, CRGB::Gray,
  363. CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
  364. CRGB::Gray, CRGB::Gray, CRGB::Gray, CRGB::Gray };
  365.  
  366. // A mostly blue palette with white accents.
  367. // "CRGB::Gray" is used as white to keep the brightness more uniform.
  368. const TProgmemRGBPalette16 BlueWhite_p FL_PROGMEM =
  369. { CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  370. CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  371. CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
  372. CRGB::Blue, CRGB::Gray, CRGB::Gray, CRGB::Gray };
  373.  
  374. // A pure "fairy light" palette with some brightness variations
  375. #define HALFFAIRY ((CRGB::FairyLight & 0xFEFEFE) / 2)
  376. #define QUARTERFAIRY ((CRGB::FairyLight & 0xFCFCFC) / 4)
  377. const TProgmemRGBPalette16 FairyLight_p FL_PROGMEM =
  378. { CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight,
  379. HALFFAIRY, HALFFAIRY, CRGB::FairyLight, CRGB::FairyLight,
  380. QUARTERFAIRY, QUARTERFAIRY, CRGB::FairyLight, CRGB::FairyLight,
  381. CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight };
  382.  
  383. // A palette of soft snowflakes with the occasional bright one
  384. const TProgmemRGBPalette16 Snow_p FL_PROGMEM =
  385. { 0x304048, 0x304048, 0x304048, 0x304048,
  386. 0x304048, 0x304048, 0x304048, 0x304048,
  387. 0x304048, 0x304048, 0x304048, 0x304048,
  388. 0x304048, 0x304048, 0x304048, 0xE0F0FF };
  389.  
  390. // A palette reminiscent of large 'old-school' C9-size tree lights
  391. // in the five classic colors: red, orange, green, blue, and white.
  392. #define C9_Red 0xB80400
  393. #define C9_Orange 0x902C02
  394. #define C9_Green 0x046002
  395. #define C9_Blue 0x070758
  396. #define C9_White 0x606820
  397. const TProgmemRGBPalette16 RetroC9_p FL_PROGMEM =
  398. { C9_Red, C9_Orange, C9_Red, C9_Orange,
  399. C9_Orange, C9_Red, C9_Orange, C9_Red,
  400. C9_Green, C9_Green, C9_Green, C9_Green,
  401. C9_Blue, C9_Blue, C9_Blue,
  402. C9_White
  403. };
  404.  
  405. // A cold, icy pale blue palette
  406. #define Ice_Blue1 0x0C1040
  407. #define Ice_Blue2 0x182080
  408. #define Ice_Blue3 0x5080C0
  409. const TProgmemRGBPalette16 Ice_p FL_PROGMEM =
  410. {
  411. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  412. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  413. Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
  414. Ice_Blue2, Ice_Blue2, Ice_Blue2, Ice_Blue3
  415. };
  416.  
  417.  
  418. // Add or remove palette names from this list to control which color
  419. // palettes are used, and in what order.
  420. const TProgmemRGBPalette16* ActivePaletteList0[] = {
  421.  
  422. //&PartyColors_p,
  423. &RedWhite_p,
  424. //&Snow_p,
  425. //&Holly_p,
  426. // &Ice_p
  427. //&RetroC9_p,
  428. //&BlueWhite_p,
  429. //&RainbowColors_p,
  430. //&FairyLight_p,
  431. //&RedGreenWhite_p,
  432. };
  433.  
  434. const TProgmemRGBPalette16* ActivePaletteList1[] = {
  435.  
  436. //&PartyColors_p,
  437. //&RedWhite_p,
  438. //&Snow_p,
  439. //&Holly_p,
  440. // &Ice_p
  441. &RetroC9_p,
  442. //&BlueWhite_p,
  443. //&RainbowColors_p,
  444. //&FairyLight_p,
  445. //&RedGreenWhite_p,
  446. };
  447.  
  448. const TProgmemRGBPalette16* ActivePaletteList2[] = {
  449.  
  450. //&PartyColors_p,
  451. // &RedWhite_p,
  452. &Snow_p,
  453. //&Holly_p,
  454. // &Ice_p
  455. //&RetroC9_p,
  456. //&BlueWhite_p,
  457. //&RainbowColors_p,
  458. //&FairyLight_p,
  459. //&RedGreenWhite_p,
  460. };
  461.  
  462. const TProgmemRGBPalette16* ActivePaletteList3[] = {
  463.  
  464. //&PartyColors_p,
  465. //&RedWhite_p,
  466. //&Snow_p,
  467. //&Holly_p,
  468. // &Ice_p
  469. //&RetroC9_p,
  470. //&BlueWhite_p,
  471. //&RainbowColors_p,
  472. //&FairyLight_p,
  473. &RedGreenWhite_p,
  474. };
  475.  
  476. const TProgmemRGBPalette16* ActivePaletteList4[] = {
  477.  
  478. //&PartyColors_p,
  479. // &RedWhite_p,
  480. //&Snow_p,
  481. //&Holly_p,
  482. // &Ice_p
  483. //&RetroC9_p,
  484. //&BlueWhite_p,
  485. &RainbowColors_p,
  486. //&FairyLight_p,
  487. //&RedGreenWhite_p,
  488. };
  489.  
  490. const TProgmemRGBPalette16* ActivePaletteList5[] = {
  491.  
  492. &PartyColors_p,
  493. //&RedWhite_p,
  494. //&Snow_p,
  495. //&Holly_p,
  496. // &Ice_p
  497. //&RetroC9_p,
  498. //&BlueWhite_p,
  499. //&RainbowColors_p,
  500. //&FairyLight_p,
  501. //&RedGreenWhite_p,
  502. };
  503.  
  504. const TProgmemRGBPalette16* ActivePaletteList6[] = {
  505.  
  506. //&PartyColors_p,
  507. //&RedWhite_p,
  508. //&Snow_p,
  509. //&Holly_p,
  510. // &Ice_p
  511. //&RetroC9_p,
  512. //&BlueWhite_p,
  513. //&RainbowColors_p,
  514. &FairyLight_p,
  515. //&RedGreenWhite_p,
  516. };
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523. // Advance to the next color palette in the list (above).
  524. void chooseNextColorPalette0( CRGBPalette16& pal)
  525. {
  526. const uint8_t numberOfPalettes = sizeof(ActivePaletteList0) / sizeof(ActivePaletteList0[0]);
  527. static uint8_t whichPalette = -1;
  528. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  529.  
  530. pal = *(ActivePaletteList0[whichPalette]);
  531. }
  532.  
  533. void chooseNextColorPalette1( CRGBPalette16& pal)
  534. {
  535. const uint8_t numberOfPalettes = sizeof(ActivePaletteList1) / sizeof(ActivePaletteList1[0]);
  536. static uint8_t whichPalette = -1;
  537. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  538.  
  539. pal = *(ActivePaletteList1[whichPalette]);
  540. }
  541.  
  542. void chooseNextColorPalette2( CRGBPalette16& pal)
  543. {
  544. const uint8_t numberOfPalettes = sizeof(ActivePaletteList2) / sizeof(ActivePaletteList2[0]);
  545. static uint8_t whichPalette = -1;
  546. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  547.  
  548. pal = *(ActivePaletteList2[whichPalette]);
  549. }
  550.  
  551. void chooseNextColorPalette3( CRGBPalette16& pal)
  552. {
  553. const uint8_t numberOfPalettes = sizeof(ActivePaletteList3) / sizeof(ActivePaletteList3[0]);
  554. static uint8_t whichPalette = -1;
  555. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  556.  
  557. pal = *(ActivePaletteList3[whichPalette]);
  558. }
  559.  
  560. void chooseNextColorPalette4( CRGBPalette16& pal)
  561. {
  562. const uint8_t numberOfPalettes = sizeof(ActivePaletteList4) / sizeof(ActivePaletteList4[0]);
  563. static uint8_t whichPalette = -1;
  564. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  565.  
  566. pal = *(ActivePaletteList4[whichPalette]);
  567. }
  568.  
  569. void chooseNextColorPalette5( CRGBPalette16& pal)
  570. {
  571. const uint8_t numberOfPalettes = sizeof(ActivePaletteList5) / sizeof(ActivePaletteList5[0]);
  572. static uint8_t whichPalette = -1;
  573. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  574.  
  575. pal = *(ActivePaletteList5[whichPalette]);
  576. }
  577.  
  578. void chooseNextColorPalette6( CRGBPalette16& pal)
  579. {
  580. const uint8_t numberOfPalettes = sizeof(ActivePaletteList6) / sizeof(ActivePaletteList6[0]);
  581. static uint8_t whichPalette = -1;
  582. whichPalette = addmod8( whichPalette, 1, numberOfPalettes);
  583.  
  584. pal = *(ActivePaletteList6[whichPalette]);
  585. }
Advertisement
Add Comment
Please, Sign In to add comment