infinitron

FastLED Camelbak

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