Advertisement
infinitron

FastLED Camelbak with Demo

May 25th, 2016
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.73 KB | None | 0 0
  1. // _ ___________ _____ _ _ _
  2. // | | | ___| _ \ / __ \ | | | | |
  3. // | | | |__ | | | | | / \/ __ _ _ __ ___ ___| | |__ __ _| | __
  4. // | | | __|| | | | | | / _` | '_ ` _ \ / _ \ | '_ \ / _` | |/ /
  5. // | |____| |___| |/ / | \__/\ (_| | | | | | | __/ | |_) | (_| | <
  6. // \_____/\____/|___/ \____/\__,_|_| |_| |_|\___|_|_.__/ \__,_|_|\_\
  7.  
  8. // Festival LED Camelbak
  9. // Big ups to Andrew Tuline, Mark Kreigsman and the FastLED community
  10.  
  11. #include <FastLED.h> // Include FastLED Library
  12. #include <Button.h> // Include Button Library. Includes press, long press, double press detection.
  13.  
  14. FASTLED_USING_NAMESPACE
  15.  
  16. //Warn me if FASTLED != 3.1 or later
  17. #if FASTLED_VERSION < 3001000
  18. #error "Requires FastLED 3.1 or later; check github for latest code."
  19. #endif
  20.  
  21. //LED Setup
  22. #define LED_PIN 11 //Data pin
  23. #define LED_TYPE WS2811 //LED Type (Note: WS2811 driver used for WS2812B)
  24. #define COLOR_ORDER GRB //LED Color Order
  25. #define NUM_LEDS 60 //Number of LEDs
  26. #define SECONDS_PER_PALETTE 10
  27. CRGBArray<NUM_LEDS> leds; //Name of LED Array, allows for mirror
  28.  
  29. //LED Color Palette & Blending
  30. CRGBPalette16 currentPalette; //Color Palette
  31. CRGBPalette16 targetPalette;
  32. TBlendType currentBlending; //Color Blending
  33. extern CRGBPalette16 warriors;
  34. extern const TProgmemPalette16 warriors_p PROGMEM;
  35. extern CRGBPalette16 usa;
  36. extern const TProgmemPalette16 usa_p PROGMEM;
  37. extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
  38. extern const uint8_t gGradientPaletteCount;
  39. uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  40.  
  41. // Button Setup
  42. const int buttonPin = 6; // Digital pin used for debounced pushbutton
  43. Button myBtn(buttonPin, true, true, 50); // Declare the button
  44. int val1;
  45. int minmap = 1;
  46. int maxmap = 100;
  47. int pot1;
  48.  
  49. // Mode Variables
  50. int ledMode = 15; // First active mode
  51. int maxMode;
  52. int animationSpeed; //Pot will adjust anywhere animationSpeed is used
  53. unsigned int dimmer = 1;
  54. uint8_t gCurrentPaletteNumber = 0; // Current palette number from the 'playlist' of color palettes
  55.  
  56. // Setup
  57. void setup() {
  58. delay(1000); // Three second power-up safety delay
  59.  
  60. //FASTLED
  61. FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  62. currentBlending = LINEARBLEND;
  63. set_max_power_in_volts_and_milliamps(5, 500);
  64. change_mode(ledMode, 1);
  65. }
  66.  
  67. // ___ ___ _ _
  68. // | \/ | (_) | |
  69. // | . . | __ _ _ _ __ | | ___ ___ _ __
  70. // | |\/| |/ _` | | '_ \ | | / _ \ / _ \| '_ \
  71. // | | | | (_| | | | | | | |___| (_) | (_) | |_) |
  72. // \_| |_/\__,_|_|_| |_| \_____/\___/ \___/| .__/
  73. // | |
  74. // |_|
  75.  
  76. void loop() {
  77. buttonRead();
  78. potRead();
  79. change_mode(ledMode, 0);
  80. show_at_max_brightness_for_power();
  81. EVERY_N_MILLISECONDS( 20 ) { gHue++; }
  82. }
  83.  
  84. // ___ _ _ _
  85. // / _ \ (_) | | (_)
  86. // / /_\ \_ __ _ _ __ ___ __ _| |_ _ ___ _ __ ___
  87. // | _ | '_ \| | '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
  88. // | | | | | | | | | | | | | (_| | |_| | (_) | | | \__ \
  89. // \_| |_/_| |_|_|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
  90.  
  91. void change_mode(int newMode, int mc){ // mc stands for 'Mode Change', where mc = 0 is strobe the routine, while mc = 1 is change the routine
  92.  
  93. maxMode = 14;
  94. if(mc) fill_solid(leds,NUM_LEDS,CRGB(0,0,0)); // Clean up the array for the first time through. Don't show display though, so you may have a smooth transition.
  95.  
  96. switch (newMode) { // First time through a new mode, so let's initialize the variables for a given display.
  97.  
  98. case 0: if(mc) {} rainbow(); break; //Rainbow Colors
  99. case 1: if(mc) {} currentBlending = LINEARBLEND; rainbowStripe(); break; //Rainbow Stripe
  100. case 2: if(mc) {} rainbowStripeMirror(); break; //Rainbow stripe mirrored
  101. case 3: if(mc) {maxmap = 500;} rainbowWithGlitter(); break; //Rainbow with Glitter
  102. case 4: if(mc) {minmap = 1; maxmap = 50;} confetti(); break; //Confetti
  103. case 5: if(mc) {minmap = 25; maxmap = 150;} sinelon(); break; //Colored dot
  104. case 6: if(mc) {} sinelonMirror(); break; //Colored dot mirrored
  105. case 7: if(mc) {minmap = 10;} bpm(); break; //BPM
  106. case 8: if(mc) {maxmap = 100;} juggle(); break; //Eight colored dots
  107. case 9: if(mc) {} juggleMirror(); break; //Eight colored dots
  108. case 10: if(mc) {} lightning(); break; //Crack bang
  109. case 11: if(mc) {minmap = 1; maxmap = 100;} partyColors(); break; //Party Colors
  110. case 12: if(mc) {} warriorsColors(); break; //GO WARRIORS
  111. case 13: if(mc) {} usaFlag(); break; //USA Flag
  112. case 14: if(mc) {} EVERY_N_SECONDS(SECONDS_PER_PALETTE) {
  113. gCurrentPaletteNumber = addmod8(gCurrentPaletteNumber, 1, gGradientPaletteCount);
  114. targetPalette = gGradientPalettes[ gCurrentPaletteNumber ];
  115. }
  116.  
  117. EVERY_N_MILLISECONDS(10) {
  118. nblendPaletteTowardPalette(currentPalette, targetPalette, 60);
  119. }
  120. paletteCycle( leds, NUM_LEDS, currentPalette);
  121. break;
  122.  
  123. // Demo mode
  124. case 15: demo_mode(); break;
  125.  
  126. } // switch newMode
  127.  
  128. ledMode = newMode;
  129.  
  130. }
  131.  
  132. void demo_mode(){
  133. uint8_t smode = 0;
  134. uint8_t secondHand = (millis() / 1000) % 220; // Change '60' to a different value to change length of the loop.
  135. static uint8_t lastSecond = 99; // Static variable, means it's only defined once. This is our 'debounce' variable.
  136. if (lastSecond != secondHand) { // Debounce to make sure we're not repeating an assignment.
  137. lastSecond = secondHand;
  138.  
  139. switch(secondHand) {
  140. case 0: smode = 0; break;
  141. case 10: smode = 1; break;
  142. case 20: smode = 2; break;
  143. case 30: smode = 3; break;
  144. case 40: smode = 4; break;
  145. case 50: smode = 5; break;
  146. case 60: smode = 6; break;
  147. case 70: smode = 7; break;
  148. case 80: smode = 8; break;
  149. case 90: smode = 9; break;
  150. case 100: smode = 10; break;
  151. case 110: smode = 11; break;
  152. case 120: smode = 12; break;
  153. case 130: smode = 13; break;
  154. }
  155. } // if lastSecond
  156.  
  157. switch(smode) {
  158. case 0: rainbow(); break; //Rainbow Colors
  159. case 1: rainbowStripe(); break; //Rainbow Stripe
  160. case 2: rainbowStripeMirror(); break; //Rainbow stripe mirrored
  161. case 3: rainbowWithGlitter(); break; //Rainbow with Glitter
  162. case 4: confetti(); break; //Confetti
  163. case 5: sinelon(); break; //Colored dot
  164. case 6: sinelonMirror(); break; //Colored dot mirrored
  165. case 7: bpm(); break; //BPM
  166. case 8: juggle(); break; //Eight colored dots
  167. case 9: juggleMirror(); break; //Eight colored dots
  168. case 10: lightning(); break; //Crack bang
  169. case 11: partyColors(); break; //Party Colors
  170. case 12: warriorsColors(); break; //GO WARRIORS
  171. case 13: usaFlag(); break; //USA Flag
  172. }
  173. } // demo_mode
  174.  
  175. void rainbow() {
  176. // FastLED's built-in rainbow generator
  177. fill_rainbow(leds, NUM_LEDS, gHue, -5);
  178. gHue = gHue + 0.8;
  179. }
  180.  
  181. void rainbowStripe() {
  182. // Rainbow Stripe effect
  183. currentPalette = RainbowStripeColors_p;
  184.  
  185. static uint8_t startIndex = 0;
  186. startIndex = startIndex + 1;
  187.  
  188. FillLEDsFromPaletteColors(startIndex);
  189.  
  190. delay_at_max_brightness_for_power(animationSpeed);
  191. }
  192.  
  193. void rainbowStripeMirror() {
  194. // Rainbow Stripe effect mirrored on both sides
  195. currentPalette = RainbowStripeColors_p;
  196.  
  197. static uint8_t startIndex = 0;
  198. startIndex = startIndex + 1;
  199.  
  200. FillLEDsFromPaletteColorsMirror(startIndex);
  201.  
  202. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  203.  
  204. delay_at_max_brightness_for_power(animationSpeed);
  205. }
  206.  
  207. void rainbowWithGlitter() {
  208. // Built-in FastLED rainbow, plus some random sparkly glitter
  209. rainbow();
  210. addGlitter(32);
  211. delay_at_max_brightness_for_power(50);
  212. }
  213.  
  214. void addGlitter(fract8 chanceOfGlitter) {
  215. if( random8(-animationSpeed) < chanceOfGlitter) {
  216. leds[ random16(NUM_LEDS) ] += CRGB::White;
  217. }
  218. }
  219.  
  220. void confetti() {
  221. // Random colored speckles that blink in and fade smoothly
  222. fadeToBlackBy(leds, NUM_LEDS, animationSpeed);
  223. int pos = random16(NUM_LEDS);
  224. leds[pos] += CHSV(gHue + random8(1), 200, 255);
  225. delay_at_max_brightness_for_power(500/animationSpeed);
  226. }
  227.  
  228. void sinelon()
  229. {
  230. // A colored dot sweeping back and forth, with fading trails
  231. fadeToBlackBy(leds, NUM_LEDS, 3);
  232. int pos = beatsin16(animationSpeed/12,0,NUM_LEDS);
  233. static int prevpos = 0;
  234. if( pos < prevpos ) {
  235. fill_solid(leds+pos, (prevpos-pos)+1, CHSV(gHue,220,255));
  236. } else {
  237. fill_solid(leds+prevpos, (pos-prevpos)+1, CHSV( gHue,220,255));
  238. }
  239. prevpos = pos;
  240. }
  241.  
  242. void sinelonMirror()
  243. {
  244. // A colored dot sweeping back and forth, with fading trails simultaneously up both sides
  245. fadeToBlackBy(leds, NUM_LEDS, 3);
  246. int pos = beatsin16(animationSpeed/8,0,NUM_LEDS/2);
  247. static int prevpos = 0;
  248. if( pos < prevpos ) {
  249. fill_solid(leds+pos, (prevpos-pos)+1, CHSV(gHue,220,255));
  250. } else {
  251. fill_solid(leds+prevpos, (pos-prevpos)+1, CHSV( gHue,220,255));
  252. }
  253. prevpos = pos;
  254. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  255. }
  256.  
  257.  
  258. void bpm() {
  259. // Colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  260. uint8_t BeatsPerMinute = 25;
  261. CRGBPalette16 palette = PartyColors_p;
  262. uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  263. for( int i = 0; i < NUM_LEDS; i++) {
  264. leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*(animationSpeed*0.35)));
  265. }
  266. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  267. }
  268.  
  269. void juggle() {
  270. // Eight colored dots, weaving in and out of sync with each other
  271. fadeToBlackBy( leds, NUM_LEDS, 20);
  272. byte dothue = 0;
  273. for( int i = 0; i < 8; i++) {
  274. leds[beatsin16(i+animationSpeed/10,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
  275. dothue += 32;
  276. }
  277. }
  278.  
  279. void juggleMirror() {
  280. // Eight colored dots, weaving in and out of sync with each other, mirrored
  281. fadeToBlackBy( leds, NUM_LEDS, 25);
  282. byte dothue = 0;
  283. for( int i = 0; i < 6; i++) {
  284. leds[beatsin16(i+animationSpeed/10,0,NUM_LEDS/2)] |= CHSV(dothue, 225, 255);
  285. dothue += 42;
  286. }
  287. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  288. }
  289.  
  290. void lightning() {
  291.  
  292. FastLED.clear();
  293.  
  294. static const uint8_t FLASHES = 8;
  295. static unsigned long flashNext;
  296. static uint8_t flashCounter = 0, flashMax = 0;
  297. static uint8_t ledlen, ledstart;
  298. static uint8_t flashchance = 10;
  299.  
  300. // (re)init data
  301. if (flashCounter == flashMax) {
  302. ledlen = random8(3, NUM_LEDS-3); // length of flash, at least 3 LEDs
  303. ledstart = 1+random8(NUM_LEDS-ledlen); // start of flash
  304. flashNext = millis()+1000*random8(flashchance); // random start of flash sequence
  305. flashCounter = 0;
  306. flashMax = random8(3, FLASHES);
  307. }
  308.  
  309. // show next flash, if it's time has come
  310. if (millis() >= flashNext) {
  311. uint8_t dimmer;
  312.  
  313. if(flashCounter == 0) {
  314. // the brightness of the leader is scaled down by a factor of 5
  315. dimmer = 5;
  316. } else {
  317. // return strokes are brighter than the leader
  318. dimmer = random8(1, 3);
  319. }
  320.  
  321. // Show a section of LED's
  322. fill_solid(leds+ledstart, ledlen, CHSV(255, 0, 255/dimmer));
  323.  
  324. // each flash only lasts 4-10 milliseconds
  325. FastLED.delay(random8(4, 10));
  326.  
  327. // Clear the section of LED's
  328. fill_solid(leds+ledstart, ledlen, CRGB::Black);
  329. FastLED.show();
  330.  
  331. flashNext = millis()+50+random8(100);
  332. if (flashCounter == 0) {
  333. flashNext += 150;
  334. }
  335. flashCounter++;
  336. }
  337. }
  338.  
  339. void partyColors() {
  340. // Party colors
  341. currentPalette = PartyColors_p;
  342.  
  343. static uint8_t startIndex = 0;
  344. startIndex = startIndex + 1;
  345.  
  346. FillLEDsFromPaletteColors( startIndex);
  347.  
  348. delay_at_max_brightness_for_power(animationSpeed);
  349. }
  350.  
  351. void warriorsColors() {
  352. //Golden State Warriors
  353. currentPalette = warriors_p;
  354. currentBlending = NOBLEND;
  355.  
  356. static uint8_t startIndex = 0;
  357. startIndex = startIndex + 2;
  358.  
  359. FillLEDsFromPaletteColorsMirror(startIndex);
  360.  
  361. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  362.  
  363. delay_at_max_brightness_for_power(animationSpeed);
  364. }
  365.  
  366. void usaFlag() {
  367. // 'murca
  368. currentPalette = usa_p;
  369. currentBlending = NOBLEND;
  370.  
  371. static uint8_t startIndex = 0;
  372. startIndex = startIndex + 2;
  373.  
  374. FillLEDsFromPaletteColorsMirror(startIndex);
  375.  
  376. leds(NUM_LEDS/2,NUM_LEDS-1) = leds(NUM_LEDS/2 - 1 ,0);
  377.  
  378. delay_at_max_brightness_for_power(animationSpeed);
  379. }
  380.  
  381. void paletteCycle( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& currentPalette)
  382. {
  383. // Cycle through the palette playlist
  384. static uint8_t startindex = 0;
  385. startindex++;
  386. fill_palette(ledarray, numleds, startindex, (256 / NUM_LEDS) + 1, currentPalette, 255, LINEARBLEND);
  387. delay_at_max_brightness_for_power(animationSpeed);
  388. }
  389.  
  390. //Fill colors from palette
  391. void FillLEDsFromPaletteColors( uint8_t colorIndex) {
  392. for( int i = 0; i < NUM_LEDS; i++) {
  393. leds[i] = ColorFromPalette( currentPalette, colorIndex, 255, currentBlending);
  394. colorIndex += 3;
  395. }
  396. }
  397.  
  398. //Fill colors from palette for mirrored animations
  399. void FillLEDsFromPaletteColorsMirror( uint8_t colorIndex) {
  400. for( int i = 0; i < NUM_LEDS/2; i++) {
  401. leds(NUM_LEDS/2 - 1 ,0)[i] = ColorFromPalette( currentPalette, colorIndex, 255, currentBlending);
  402. colorIndex += 2;
  403. }
  404. }
  405.  
  406. // ______ _ _
  407. // | ___ \ | | | |
  408. // | |_/ /_ _| |_| |_ ___ _ __
  409. // | ___ \ | | | __| __/ _ \| '_ \
  410. // | |_/ / |_| | |_| || (_) | | | |
  411. // \____/ \__,_|\__|\__\___/|_| |_|
  412.  
  413. void buttonRead() {
  414. myBtn.read();
  415. if(myBtn.wasPressed()) {
  416. ledMode = ledMode > maxMode ? 0 : ledMode+1; // Reset to 0 only during a mode change
  417. change_mode(ledMode, 1);
  418. }
  419. if(myBtn.pressedFor(1000)) {
  420. ledMode = 15;
  421. //change_mode(ledMode, 1);
  422. }
  423. }
  424.  
  425. void potRead() {
  426. val1 = analogRead(5);
  427. pot1 = map(val1, 0, 1023, minmap, maxmap); //Remap pot value range
  428. animationSpeed = pot1;
  429. }
  430.  
  431. // ______ _ _ _
  432. // | ___ \ | | | | | |
  433. // | |_/ /_ _| | ___| |_| |_ ___ ___
  434. // | __/ _` | |/ _ \ __| __/ _ \/ __|
  435. // | | | (_| | | __/ |_| || __/\__ \
  436. // \_| \__,_|_|\___|\__|\__\___||___/
  437.  
  438. const TProgmemPalette16 warriors_p PROGMEM =
  439. {
  440. CRGB::Gold, CRGB::Blue, CRGB::Gold, CRGB::Blue,
  441. CRGB::Gold, CRGB::Gold, CRGB::Blue, CRGB::Blue,
  442. CRGB::Gold, CRGB::Blue, CRGB::Gold, CRGB::Blue,
  443. CRGB::Gold, CRGB::Gold, CRGB::Blue, CRGB::Blue};
  444.  
  445. const TProgmemPalette16 usa_p PROGMEM =
  446. {
  447. CRGB::Navy, CRGB::Navy, CRGB::Navy, CRGB::Navy,
  448. CRGB::Red, CRGB::White, CRGB::Red, CRGB::White,
  449. CRGB::Red, CRGB::White, CRGB::Red, CRGB::White,
  450. CRGB::Red, CRGB::White, CRGB::Red, CRGB::White,
  451. };
  452.  
  453. DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
  454. 0, 194, 1, 1,
  455. 94, 1, 29, 18,
  456. 132, 57,131, 28,
  457. 255, 113, 1, 1};
  458.  
  459. DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
  460. 0, 2, 1, 1,
  461. 53, 18, 1, 0,
  462. 104, 69, 29, 1,
  463. 153, 167,135, 10,
  464. 255, 46, 56, 4};
  465.  
  466. DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
  467. 0, 4, 1, 1,
  468. 51, 16, 0, 1,
  469. 76, 97,104, 3,
  470. 101, 255,131, 19,
  471. 127, 67, 9, 4,
  472. 153, 16, 0, 1,
  473. 229, 4, 1, 1,
  474. 255, 4, 1, 1};
  475.  
  476. DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
  477. 0, 1, 14, 5,
  478. 101, 16, 36, 14,
  479. 165, 56, 68, 30,
  480. 242, 150,156, 99,
  481. 255, 150,156, 99};
  482.  
  483. DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
  484. 0, 4, 1, 31,
  485. 31, 55, 1, 16,
  486. 63, 197, 3, 7,
  487. 95, 59, 2, 17,
  488. 127, 6, 2, 34,
  489. 159, 39, 6, 33,
  490. 191, 112, 13, 32,
  491. 223, 56, 9, 35,
  492. 255, 22, 6, 38};
  493.  
  494. DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
  495. 0, 188,135, 1,
  496. 255, 46, 7, 1};
  497.  
  498. DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
  499. 0, 3, 0,255,
  500. 63, 23, 0,255,
  501. 127, 67, 0,255,
  502. 191, 142, 0, 45,
  503. 255, 255, 0, 0};
  504.  
  505. DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
  506. 0, 126, 11,255,
  507. 127, 197, 1, 22,
  508. 175, 210,157,172,
  509. 221, 157, 3,112,
  510. 255, 157, 3,112};
  511.  
  512. DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
  513. 0, 229, 1, 1,
  514. 61, 242, 4, 63,
  515. 101, 255, 12,255,
  516. 127, 249, 81,252,
  517. 153, 255, 11,235,
  518. 193, 244, 5, 68,
  519. 255, 232, 1, 5};
  520.  
  521. DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
  522. 0, 40,199,197,
  523. 50, 10,152,155,
  524. 96, 1,111,120,
  525. 96, 43,127,162,
  526. 139, 10, 73,111,
  527. 255, 1, 34, 71};
  528.  
  529. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
  530. 0, 100,156,153,
  531. 51, 1, 99,137,
  532. 101, 1, 68, 84,
  533. 104, 35,142,168,
  534. 178, 0, 63,117,
  535. 255, 1, 10, 10};
  536.  
  537. DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
  538. 0, 1, 6, 7,
  539. 89, 1, 99,111,
  540. 153, 144,209,255,
  541. 255, 0, 73, 82};
  542.  
  543. DEFINE_GRADIENT_PALETTE( departure_gp ) {
  544. 0, 8, 3, 0,
  545. 42, 23, 7, 0,
  546. 63, 75, 38, 6,
  547. 84, 169, 99, 38,
  548. 106, 213,169,119,
  549. 116, 255,255,255,
  550. 138, 135,255,138,
  551. 148, 22,255, 24,
  552. 170, 0,255, 0,
  553. 191, 0,136, 0,
  554. 212, 0, 55, 0,
  555. 255, 0, 55, 0};
  556.  
  557. DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
  558. 0, 0, 0, 0,
  559. 37, 2, 25, 1,
  560. 76, 15,115, 5,
  561. 127, 79,213, 1,
  562. 128, 126,211, 47,
  563. 130, 188,209,247,
  564. 153, 144,182,205,
  565. 204, 59,117,250,
  566. 255, 1, 37,192};
  567.  
  568. DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
  569. 0, 1, 5, 0,
  570. 19, 32, 23, 1,
  571. 38, 161, 55, 1,
  572. 63, 229,144, 1,
  573. 66, 39,142, 74,
  574. 255, 1, 4, 1};
  575.  
  576. DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
  577. 0, 255, 33, 4,
  578. 43, 255, 68, 25,
  579. 86, 255, 7, 25,
  580. 127, 255, 82,103,
  581. 170, 255,255,242,
  582. 209, 42,255, 22,
  583. 255, 87,255, 65};
  584.  
  585. DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
  586. 0, 247,176,247,
  587. 48, 255,136,255,
  588. 89, 220, 29,226,
  589. 160, 7, 82,178,
  590. 216, 1,124,109,
  591. 255, 1,124,109};
  592.  
  593. DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
  594. 0, 1,124,109,
  595. 66, 1, 93, 79,
  596. 104, 52, 65, 1,
  597. 130, 115,127, 1,
  598. 150, 52, 65, 1,
  599. 201, 1, 86, 72,
  600. 239, 0, 55, 45,
  601. 255, 0, 55, 45};
  602.  
  603. DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
  604. 0, 47, 30, 2,
  605. 42, 213,147, 24,
  606. 84, 103,219, 52,
  607. 127, 3,219,207,
  608. 170, 1, 48,214,
  609. 212, 1, 1,111,
  610. 255, 1, 7, 33};
  611.  
  612. DEFINE_GRADIENT_PALETTE( ib15_gp ) {
  613. 0, 113, 91,147,
  614. 72, 157, 88, 78,
  615. 89, 208, 85, 33,
  616. 107, 255, 29, 11,
  617. 141, 137, 31, 39,
  618. 255, 59, 33, 89};
  619.  
  620. DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
  621. 0, 43, 3,153,
  622. 63, 100, 4,103,
  623. 127, 188, 5, 66,
  624. 191, 161, 11,115,
  625. 255, 135, 20,182};
  626.  
  627. DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
  628. 0, 97,255, 1,
  629. 101, 47,133, 1,
  630. 178, 13, 43, 1,
  631. 255, 2, 10, 1};
  632.  
  633. DEFINE_GRADIENT_PALETTE( lava_gp ) {
  634. 0, 0, 0, 0,
  635. 46, 18, 0, 0,
  636. 96, 113, 0, 0,
  637. 108, 142, 3, 1,
  638. 119, 175, 17, 1,
  639. 146, 213, 44, 2,
  640. 174, 255, 82, 4,
  641. 188, 255,115, 4,
  642. 202, 255,156, 4,
  643. 218, 255,203, 4,
  644. 234, 255,255, 4,
  645. 244, 255,255, 71,
  646. 255, 255,255,255};
  647.  
  648. DEFINE_GRADIENT_PALETTE( fire_gp ) {
  649. 0, 1, 1, 0,
  650. 76, 32, 5, 0,
  651. 146, 192, 24, 0,
  652. 197, 220,105, 5,
  653. 240, 252,255, 31,
  654. 250, 252,255,111,
  655. 255, 255,255,255};
  656.  
  657. DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
  658. 0, 10, 85, 5,
  659. 25, 29,109, 18,
  660. 60, 59,138, 42,
  661. 93, 83, 99, 52,
  662. 106, 110, 66, 64,
  663. 109, 123, 49, 65,
  664. 113, 139, 35, 66,
  665. 116, 192,117, 98,
  666. 124, 255,255,137,
  667. 168, 100,180,155,
  668. 255, 22,121,174};
  669.  
  670. DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
  671. 0, 71, 27, 39,
  672. 31, 130, 11, 51,
  673. 63, 213, 2, 64,
  674. 70, 232, 1, 66,
  675. 76, 252, 1, 69,
  676. 108, 123, 2, 51,
  677. 255, 46, 9, 35};
  678.  
  679. DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
  680. 0, 19, 2, 39,
  681. 25, 26, 4, 45,
  682. 51, 33, 6, 52,
  683. 76, 68, 62,125,
  684. 102, 118,187,240,
  685. 109, 163,215,247,
  686. 114, 217,244,255,
  687. 122, 159,149,221,
  688. 149, 113, 78,188,
  689. 183, 128, 57,155,
  690. 255, 146, 40,123};
  691.  
  692. DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
  693. 0, 120, 0, 0,
  694. 22, 179, 22, 0,
  695. 51, 255,104, 0,
  696. 85, 167, 22, 18,
  697. 135, 100, 0,103,
  698. 198, 16, 0,130,
  699. 255, 0, 0,160};
  700.  
  701. DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
  702. 0, 26, 1, 1,
  703. 51, 67, 4, 1,
  704. 84, 118, 14, 1,
  705. 104, 137,152, 52,
  706. 112, 113, 65, 1,
  707. 122, 133,149, 59,
  708. 124, 137,152, 52,
  709. 135, 113, 65, 1,
  710. 142, 139,154, 46,
  711. 163, 113, 13, 1,
  712. 204, 55, 3, 1,
  713. 249, 17, 1, 1,
  714. 255, 17, 1, 1};
  715.  
  716. DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
  717. 0, 0, 0, 0,
  718. 42, 0, 0, 45,
  719. 84, 0, 0,255,
  720. 127, 42, 0,255,
  721. 170, 255, 0,255,
  722. 212, 255, 55,255,
  723. 255, 255,255,255};
  724.  
  725. DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
  726. 0, 0, 0, 0,
  727. 63, 42, 0, 45,
  728. 127, 255, 0,255,
  729. 191, 255, 0, 45,
  730. 255, 255, 0, 0};
  731.  
  732. DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
  733. 0, 0, 0, 0,
  734. 42, 42, 0, 0,
  735. 84, 255, 0, 0,
  736. 127, 255, 0, 45,
  737. 170, 255, 0,255,
  738. 212, 255, 55, 45,
  739. 255, 255,255, 0};
  740.  
  741. DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
  742. 0, 0, 0,255,
  743. 63, 0, 55,255,
  744. 127, 0,255,255,
  745. 191, 42,255, 45,
  746. 255, 255,255, 0};
  747.  
  748. DEFINE_GRADIENT_PALETTE( Miami_gp ) {
  749. 0, 1,221, 53,
  750. 255, 73, 3,178};
  751.  
  752. // Single array of defined cpt-city color palettes.
  753. // This will let us programmatically choose one based on
  754. // a number, rather than having to activate each explicitly
  755. // by name every time.
  756. // Since it is const, this array could also be moved
  757. // into PROGMEM to save SRAM, but for simplicity of illustration
  758. // we'll keep it in a regular SRAM array.
  759. //
  760. // This list of color palettes acts as a "playlist"; you can
  761. // add or delete, or re-arrange as you wish.
  762.  
  763. const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
  764. Miami_gp,
  765. Sunset_Real_gp,
  766. es_rivendell_15_gp,
  767. es_ocean_breeze_036_gp,
  768. rgi_15_gp,
  769. retro2_16_gp,
  770. Analogous_1_gp,
  771. es_pinksplash_08_gp,
  772. Coral_reef_gp,
  773. es_ocean_breeze_068_gp,
  774. es_pinksplash_07_gp,
  775. es_vintage_01_gp,
  776. departure_gp,
  777. es_landscape_64_gp,
  778. es_landscape_33_gp,
  779. rainbowsherbet_gp,
  780. gr65_hult_gp,
  781. gr64_hult_gp,
  782. GMT_drywet_gp,
  783. ib_jul01_gp,
  784. es_vintage_57_gp,
  785. ib15_gp,
  786. Fuschia_7_gp,
  787. es_emerald_dragon_08_gp,
  788. lava_gp,
  789. fire_gp,
  790. Colorfull_gp,
  791. Magenta_Evening_gp,
  792. Pink_Purple_gp,
  793. es_autumn_19_gp,
  794. BlacK_Blue_Magenta_White_gp,
  795. BlacK_Magenta_Red_gp,
  796. BlacK_Red_Magenta_Yellow_gp,
  797. Blue_Cyan_Yellow_gp };
  798.  
  799. // Count of how many cpt-city gradients are defined:
  800. const uint8_t gGradientPaletteCount =
  801. sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
  802.  
  803. // End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement