diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2014-09-15 07:18:19 +0400 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2014-09-15 07:18:19 +0400 |
commit | 0b27df9a2b844da20fcd67073a013e4bb2f4353e (patch) | |
tree | 8b61971f511ada8b563e69772a28b44e6dc986b5 | |
parent | 9b1388bbffc3d4ee5f644e2b139b1d177cb04250 (diff) |
Shut up warnings about progmem and color palettes. Also, move the palette definitions out of a .h file and into a .cpp file (minimize duplicate constant creation that I don't always trust gcc to collapse down)
-rw-r--r-- | colorpalettes.cpp | 164 | ||||
-rw-r--r-- | colorpalettes.h | 127 |
2 files changed, 172 insertions, 119 deletions
diff --git a/colorpalettes.cpp b/colorpalettes.cpp new file mode 100644 index 00000000..9591279a --- /dev/null +++ b/colorpalettes.cpp @@ -0,0 +1,164 @@ +#ifndef __INC_COLORPALETTES_H +#define __INC_COLORPALETTES_H + +#include "FastLED.h" +#include "colorutils.h" +#include "colorpalettes.h" + +// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 +#ifdef FASTLED_AVR +#ifdef PROGMEM +#undef PROGMEM +#define PROGMEM __attribute__((section(".progmem.data"))) +#endif +#endif + + + +// Preset color schemes, such as they are. + +// These schemes are all declared as "PROGMEM", meaning +// that they won't take up SRAM on AVR chips until used. +// Furthermore, the compiler won't even include these +// in your PROGMEM (flash) storage unless you specifically +// use each one, so you only 'pay for' those you actually use. + + +extern const TProgmemPalette16 CloudColors_p PROGMEM = +{ + CRGB::Blue, + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + CRGB::DarkBlue, + + CRGB::Blue, + CRGB::DarkBlue, + CRGB::SkyBlue, + CRGB::SkyBlue, + + CRGB::LightBlue, + CRGB::White, + CRGB::LightBlue, + CRGB::SkyBlue +}; + +extern const TProgmemPalette16 LavaColors_p PROGMEM = +{ + CRGB::Black, + CRGB::Maroon, + CRGB::Black, + CRGB::Maroon, + + CRGB::DarkRed, + CRGB::Maroon, + CRGB::DarkRed, + + CRGB::DarkRed, + CRGB::DarkRed, + CRGB::Red, + CRGB::Orange, + + CRGB::White, + CRGB::Orange, + CRGB::Red, + CRGB::DarkRed +}; + + +extern const TProgmemPalette16 OceanColors_p PROGMEM = +{ + CRGB::MidnightBlue, + CRGB::DarkBlue, + CRGB::MidnightBlue, + CRGB::Navy, + + CRGB::DarkBlue, + CRGB::MediumBlue, + CRGB::SeaGreen, + CRGB::Teal, + + CRGB::CadetBlue, + CRGB::Blue, + CRGB::DarkCyan, + CRGB::CornflowerBlue, + + CRGB::Aquamarine, + CRGB::SeaGreen, + CRGB::Aqua, + CRGB::LightSkyBlue +}; + +extern const TProgmemPalette16 ForestColors_p PROGMEM = +{ + CRGB::DarkGreen, + CRGB::DarkGreen, + CRGB::DarkOliveGreen, + CRGB::DarkGreen, + + CRGB::Green, + CRGB::ForestGreen, + CRGB::OliveDrab, + CRGB::Green, + + CRGB::SeaGreen, + CRGB::MediumAquamarine, + CRGB::LimeGreen, + CRGB::YellowGreen, + + CRGB::LightGreen, + CRGB::LawnGreen, + CRGB::MediumAquamarine, + CRGB::ForestGreen +}; + +// HSV Rainbow +extern const TProgmemPalette16 RainbowColors_p PROGMEM = +{ + 0xFF0000, 0xD52A00, 0xAB5500, 0xAB7F00, + 0xABAB00, 0x56D500, 0x00FF00, 0x00D52A, + 0x00AB55, 0x0056AA, 0x0000FF, 0x2A00D5, + 0x5500AB, 0x7F0081, 0xAB0055, 0xD5002B +}; + +// HSV Rainbow colors with alternatating stripes of black +#define RainbowStripesColors_p RainbowStripeColors_p +extern const TProgmemPalette16 RainbowStripeColors_p PROGMEM = +{ + 0xFF0000, 0x000000, 0xAB5500, 0x000000, + 0xABAB00, 0x000000, 0x00FF00, 0x000000, + 0x00AB55, 0x000000, 0x0000FF, 0x000000, + 0x5500AB, 0x000000, 0xAB0055, 0x000000 +}; + +// HSV color ramp: blue purple ping red orange yellow (and back) +// Basically, everything but the greens, which tend to make +// people's skin look unhealthy. This palette is good for +// lighting at a club or party, where it'll be shining on people. +extern const TProgmemPalette16 PartyColors_p PROGMEM = +{ + 0x5500AB, 0x84007C, 0xB5004B, 0xE5001B, + 0xE81700, 0xB84700, 0xAB7700, 0xABAB00, + 0xAB5500, 0xDD2200, 0xF2000E, 0xC2003E, + 0x8F0071, 0x5F00A1, 0x2F00D0, 0x0007F9 +}; + +// Approximate "black body radiation" palette, akin to +// the FastLED 'HeatColor' function. +// Recommend that you use values 0-240 rather than +// the usual 0-255, as the last 15 colors will be +// 'wrapping around' from the hot end to the cold end, +// which looks wrong. +extern const TProgmemPalette16 HeatColors_p PROGMEM = +{ + 0x000000, + 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, + 0xFF3300, 0xFF6600, 0xFF9900, 0xFFCC00, 0xFFFF00, + 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC, 0xFFFFFF +}; + +#endif diff --git a/colorpalettes.h b/colorpalettes.h index 0a127ef4..b9622694 100644 --- a/colorpalettes.h +++ b/colorpalettes.h @@ -13,128 +13,23 @@ // use each one, so you only 'pay for' those you actually use. -const TProgmemPalette16 CloudColors_p PROGMEM = -{ - CRGB::Blue, - CRGB::DarkBlue, - CRGB::DarkBlue, - CRGB::DarkBlue, - - CRGB::DarkBlue, - CRGB::DarkBlue, - CRGB::DarkBlue, - CRGB::DarkBlue, - - CRGB::Blue, - CRGB::DarkBlue, - CRGB::SkyBlue, - CRGB::SkyBlue, - - CRGB::LightBlue, - CRGB::White, - CRGB::LightBlue, - CRGB::SkyBlue -}; - -const TProgmemPalette16 LavaColors_p PROGMEM = -{ - CRGB::Black, - CRGB::Maroon, - CRGB::Black, - CRGB::Maroon, - - CRGB::DarkRed, - CRGB::Maroon, - CRGB::DarkRed, - - CRGB::DarkRed, - CRGB::DarkRed, - CRGB::Red, - CRGB::Orange, - - CRGB::White, - CRGB::Orange, - CRGB::Red, - CRGB::DarkRed -}; - - -const TProgmemPalette16 OceanColors_p PROGMEM = -{ - CRGB::MidnightBlue, - CRGB::DarkBlue, - CRGB::MidnightBlue, - CRGB::Navy, - - CRGB::DarkBlue, - CRGB::MediumBlue, - CRGB::SeaGreen, - CRGB::Teal, - - CRGB::CadetBlue, - CRGB::Blue, - CRGB::DarkCyan, - CRGB::CornflowerBlue, - - CRGB::Aquamarine, - CRGB::SeaGreen, - CRGB::Aqua, - CRGB::LightSkyBlue -}; - -const TProgmemPalette16 ForestColors_p PROGMEM = -{ - CRGB::DarkGreen, - CRGB::DarkGreen, - CRGB::DarkOliveGreen, - CRGB::DarkGreen, - - CRGB::Green, - CRGB::ForestGreen, - CRGB::OliveDrab, - CRGB::Green, - - CRGB::SeaGreen, - CRGB::MediumAquamarine, - CRGB::LimeGreen, - CRGB::YellowGreen, - - CRGB::LightGreen, - CRGB::LawnGreen, - CRGB::MediumAquamarine, - CRGB::ForestGreen -}; +extern const TProgmemPalette16 CloudColors_p PROGMEM; +extern const TProgmemPalette16 LavaColors_p PROGMEM; +extern const TProgmemPalette16 OceanColors_p PROGMEM; +extern const TProgmemPalette16 ForestColors_p PROGMEM; // HSV Rainbow -const TProgmemPalette16 RainbowColors_p PROGMEM = -{ - 0xFF0000, 0xD52A00, 0xAB5500, 0xAB7F00, - 0xABAB00, 0x56D500, 0x00FF00, 0x00D52A, - 0x00AB55, 0x0056AA, 0x0000FF, 0x2A00D5, - 0x5500AB, 0x7F0081, 0xAB0055, 0xD5002B -}; +extern const TProgmemPalette16 RainbowColors_p PROGMEM; // HSV Rainbow colors with alternatating stripes of black #define RainbowStripesColors_p RainbowStripeColors_p -const TProgmemPalette16 RainbowStripeColors_p PROGMEM = -{ - 0xFF0000, 0x000000, 0xAB5500, 0x000000, - 0xABAB00, 0x000000, 0x00FF00, 0x000000, - 0x00AB55, 0x000000, 0x0000FF, 0x000000, - 0x5500AB, 0x000000, 0xAB0055, 0x000000 -}; +extern const TProgmemPalette16 RainbowStripeColors_p PROGMEM; // HSV color ramp: blue purple ping red orange yellow (and back) // Basically, everything but the greens, which tend to make // people's skin look unhealthy. This palette is good for // lighting at a club or party, where it'll be shining on people. -const TProgmemPalette16 PartyColors_p PROGMEM = -{ - 0x5500AB, 0x84007C, 0xB5004B, 0xE5001B, - 0xE81700, 0xB84700, 0xAB7700, 0xABAB00, - 0xAB5500, 0xDD2200, 0xF2000E, 0xC2003E, - 0x8F0071, 0x5F00A1, 0x2F00D0, 0x0007F9 -}; +extern const TProgmemPalette16 PartyColors_p PROGMEM; // Approximate "black body radiation" palette, akin to // the FastLED 'HeatColor' function. @@ -142,12 +37,6 @@ const TProgmemPalette16 PartyColors_p PROGMEM = // the usual 0-255, as the last 15 colors will be // 'wrapping around' from the hot end to the cold end, // which looks wrong. -const TProgmemPalette16 HeatColors_p PROGMEM = -{ - 0x000000, - 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, - 0xFF3300, 0xFF6600, 0xFF9900, 0xFFCC00, 0xFFFF00, - 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC, 0xFFFFFF -}; +extern const TProgmemPalette16 HeatColors_p PROGMEM; #endif |