From 1221661ae32f7c0c08fe5e4891a7b6bd3efb8059 Mon Sep 17 00:00:00 2001 From: srg74 <28492985+srg74@users.noreply.github.com> Date: Mon, 24 Feb 2020 16:51:11 -0500 Subject: [PATCH 1/3] Added Heltec WiFi-Kit-8 to UserMod (#717) --- usermods/Wemos_D1_mini+Wemos32_mini_shield/readme.md | 1 + .../Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/usermods/Wemos_D1_mini+Wemos32_mini_shield/readme.md b/usermods/Wemos_D1_mini+Wemos32_mini_shield/readme.md index be97d4b8..765e5683 100644 --- a/usermods/Wemos_D1_mini+Wemos32_mini_shield/readme.md +++ b/usermods/Wemos_D1_mini+Wemos32_mini_shield/readme.md @@ -1,4 +1,5 @@ # Wemos D1 mini and Wemos32 mini shield +- Added third choice of controller Heltec WiFi-Kit-8. Totally DIY but with OLED display. ## Project repository - [Original repository](https://github.com/srg74/WLED-wemos-shield) - WLED Wemos shield repository - [Wemos shield project Wiki](https://github.com/srg74/WLED-wemos-shield/wiki) diff --git a/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino b/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino index 9e6e0b79..58a4e0e6 100644 --- a/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino +++ b/usermods/Wemos_D1_mini+Wemos32_mini_shield/wled06_usermod.ino @@ -7,13 +7,14 @@ OneWire oneWire(23); #else //ESP8266 boards uint8_t SCL_PIN = 5; uint8_t SDA_PIN = 4; +// uint8_t RST_PIN = 16; // Uncoment for Heltec WiFi-Kit-8 OneWire oneWire(13); #endif //The SCL and SDA pins are defined here. //ESP8266 Wemos D1 mini board use SCL=5 SDA=4 while ESP32 Wemos32 mini board use SCL=22 SDA=21 #define U8X8_PIN_SCL SCL_PIN #define U8X8_PIN_SDA SDA_PIN - +//#define U8X8_PIN_RESET RST_PIN // Uncoment for Heltec WiFi-Kit-8 // Dallas sensor DallasTemperature sensor(&oneWire); long temptimer = millis(); @@ -29,6 +30,8 @@ long lastMeasure = 0; U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(U8X8_PIN_NONE, U8X8_PIN_SCL, U8X8_PIN_SDA); // Pins are Reset, SCL, SDA // --> Second choise of cheap I2C OLED 128X64 0.96" or 1.3" //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(U8X8_PIN_NONE, U8X8_PIN_SCL, U8X8_PIN_SDA); // Pins are Reset, SCL, SDA +// --> Third choise of Heltec WiFi-Kit-8 OLED 128X32 0.91" +//U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(U8X8_PIN_RESET, U8X8_PIN_SCL, U8X8_PIN_SDA); // Constracor for Heltec WiFi-Kit-8 // gets called once at boot. Do all initialization that doesn't depend on // network here void userSetup() { From f304a6891fdfdab774b40ce1a47d62fd419f84a9 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 25 Feb 2020 02:19:12 +0100 Subject: [PATCH 2/3] Free more than 2kB of RAM Store Palettes in PROGMEM F() select long and rarely used strings Refactor hue error --- wled00/FX.h | 1 + wled00/FX_fcn.cpp | 25 +++++++---- wled00/NpbWrapper.h | 2 +- wled00/const.h | 9 ++++ wled00/html_settings.h | 2 +- wled00/palettes.h | 91 ++++++++++++++++++---------------------- wled00/wled00.ino | 4 +- wled00/wled02_xml.ino | 31 +++++++++----- wled00/wled15_hue.ino | 27 ++++++------ wled00/wled18_server.ino | 34 +++++++-------- wled00/wled19_json.ino | 2 +- 11 files changed, 123 insertions(+), 105 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index a518317f..abb8c6f0 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -591,6 +591,7 @@ class WS2812FX { uint8_t _brightness; static uint16_t _usedSegmentData; + void load_gradient_palette(uint8_t); void handle_palette(void); void fill(uint32_t); diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index b495de64..ee0ca73a 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -324,7 +324,7 @@ uint8_t WS2812FX::getModeCount() uint8_t WS2812FX::getPaletteCount() { - return 13 + gGradientPaletteCount; + return 13 + GRADIENT_PALETTE_COUNT; } //TODO transitions @@ -707,6 +707,15 @@ CRGB WS2812FX::col_to_crgb(uint32_t color) } +void WS2812FX::load_gradient_palette(uint8_t index) +{ + byte i = constrain(index, 0, GRADIENT_PALETTE_COUNT -1); + byte tcp[72]; //support gradient palettes with up to 18 entries + memcpy_P(tcp, (byte*)pgm_read_dword(&(gGradientPalettes[i])), 72); + targetPalette.loadDynamicGradientPalette(tcp); +} + + /* * FastLED palette modes helper function. Limitation: Due to memory reasons, multiple active segments with FastLED will disable the Palette transitions */ @@ -724,13 +733,13 @@ void WS2812FX::handle_palette(void) case 0: {//default palette. Differs depending on effect switch (SEGMENT.mode) { - case FX_MODE_FIRE_2012 : targetPalette = gGradientPalettes[22]; break;//heat palette - case FX_MODE_COLORWAVES : targetPalette = gGradientPalettes[13]; break;//landscape 33 + case FX_MODE_FIRE_2012 : load_gradient_palette(22); break;//heat palette + case FX_MODE_COLORWAVES : load_gradient_palette(13); break;//landscape 33 case FX_MODE_FILLNOISE8 : targetPalette = OceanColors_p; break; - case FX_MODE_NOISE16_1 : targetPalette = gGradientPalettes[17]; break;//Drywet - case FX_MODE_NOISE16_2 : targetPalette = gGradientPalettes[30]; break;//Blue cyan yellow - case FX_MODE_NOISE16_3 : targetPalette = gGradientPalettes[22]; break;//heat palette - case FX_MODE_NOISE16_4 : targetPalette = gGradientPalettes[13]; break;//landscape 33 + case FX_MODE_NOISE16_1 : load_gradient_palette(17); break;//Drywet + case FX_MODE_NOISE16_2 : load_gradient_palette(30); break;//Blue cyan yellow + case FX_MODE_NOISE16_3 : load_gradient_palette(22); break;//heat palette + case FX_MODE_NOISE16_4 : load_gradient_palette(13); break;//landscape 33 //case FX_MODE_GLITTER : targetPalette = RainbowColors_p; break; default: targetPalette = PartyColors_p; break;//palette, bpm @@ -787,7 +796,7 @@ void WS2812FX::handle_palette(void) case 12: //Rainbow stripe colors targetPalette = RainbowStripeColors_p; break; default: //progmem palettes - targetPalette = gGradientPalettes[constrain(SEGMENT.palette -13, 0, gGradientPaletteCount -1)]; + load_gradient_palette(SEGMENT.palette -13); } if (singleSegmentMode && paletteFade) //only blend if just one segment uses FastLED mode diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index 9709d8aa..f12d057f 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -4,7 +4,7 @@ //PIN CONFIGURATION #ifndef LEDPIN -#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) +#define LEDPIN 5 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) #endif //#define USE_APA102 // Uncomment for using APA102 LEDs. //#define USE_WS2801 // Uncomment for using WS2801 LEDs (make sure you have NeoPixelBus v2.5.6 or newer) diff --git a/wled00/const.h b/wled00/const.h index 242536c9..b54215ca 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -61,4 +61,13 @@ #define TYPE_ANALOG_4CH 9 //analog RGBW #define TYPE_ANALOG_5CH 10 //analog RGB + WW + CW +//Hue error codes +#define HUE_ERROR_INACTIVE 0 +#define HUE_ERROR_UNAUTHORIZED 1 +#define HUE_ERROR_LIGHTID 3 +#define HUE_ERROR_PUSHLINK 101 +#define HUE_ERROR_JSON_PARSING 250 +#define HUE_ERROR_TIMEOUT 251 +#define HUE_ERROR_ACTIVE 255 + #endif diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 157d6b4c..7340e62d 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -335,7 +335,7 @@ Hue Bridge IP:

Press the pushlink button on the bridge, after that save this page!
(when first connecting)
-Hue status: Internal ESP Error!
+Hue status: Disabled in this build
diff --git a/wled00/palettes.h b/wled00/palettes.h index fbdd7bb5..29384395 100644 --- a/wled00/palettes.h +++ b/wled00/palettes.h @@ -13,7 +13,9 @@ #ifndef PalettesWLED_h #define PalettesWLED_h -DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { +#define GRADIENT_PALETTE_COUNT 38 + +const byte ib_jul01_gp[] PROGMEM = { 0, 194, 1, 1, 94, 1, 29, 18, 132, 57,131, 28, @@ -24,7 +26,7 @@ DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { +const byte es_vintage_57_gp[] PROGMEM = { 0, 2, 1, 1, 53, 18, 1, 0, 104, 69, 29, 1, @@ -37,7 +39,7 @@ DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 32 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { +const byte es_vintage_01_gp[] PROGMEM = { 0, 4, 1, 1, 51, 16, 0, 1, 76, 97,104, 3, @@ -53,7 +55,7 @@ DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { +const byte es_rivendell_15_gp[] PROGMEM = { 0, 1, 14, 5, 101, 16, 36, 14, 165, 56, 68, 30, @@ -67,7 +69,7 @@ DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) { // Size: 36 bytes of program space. // Edited to be brighter -DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { +const byte rgi_15_gp[] PROGMEM = { 0, 4, 1, 70, 31, 55, 1, 30, 63, 255, 4, 7, @@ -84,7 +86,7 @@ DEFINE_GRADIENT_PALETTE( rgi_15_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 8 bytes of program space. -DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { +const byte retro2_16_gp[] PROGMEM = { 0, 188,135, 1, 255, 46, 7, 1}; @@ -94,7 +96,7 @@ DEFINE_GRADIENT_PALETTE( retro2_16_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { +const byte Analogous_1_gp[] PROGMEM = { 0, 3, 0,255, 63, 23, 0,255, 127, 67, 0,255, @@ -107,7 +109,7 @@ DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { +const byte es_pinksplash_08_gp[] PROGMEM = { 0, 126, 11,255, 127, 197, 1, 22, 175, 210,157,172, @@ -120,7 +122,7 @@ DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 16 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { +const byte es_ocean_breeze_036_gp[] PROGMEM = { 0, 1, 6, 7, 89, 1, 99,111, 153, 144,209,255, @@ -132,7 +134,7 @@ DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 88 bytes of program space. -DEFINE_GRADIENT_PALETTE( departure_gp ) { +const byte departure_gp[] PROGMEM = { 0, 8, 3, 0, 42, 23, 7, 0, 63, 75, 38, 6, @@ -152,7 +154,7 @@ DEFINE_GRADIENT_PALETTE( departure_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 36 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { +const byte es_landscape_64_gp[] PROGMEM = { 0, 0, 0, 0, 37, 2, 25, 1, 76, 15,115, 5, @@ -169,7 +171,7 @@ DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 24 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { +const byte es_landscape_33_gp[] PROGMEM = { 0, 1, 5, 0, 19, 32, 23, 1, 38, 161, 55, 1, @@ -183,7 +185,7 @@ DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { +const byte rainbowsherbet_gp[] PROGMEM = { 0, 255, 33, 4, 43, 255, 68, 25, 86, 255, 7, 25, @@ -198,7 +200,7 @@ DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 24 bytes of program space. -DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { +const byte gr65_hult_gp[] PROGMEM = { 0, 247,176,247, 48, 255,136,255, 89, 220, 29,226, @@ -212,7 +214,7 @@ DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 32 bytes of program space. -DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { +const byte gr64_hult_gp[] PROGMEM = { 0, 1,124,109, 66, 1, 93, 79, 104, 52, 65, 1, @@ -228,7 +230,7 @@ DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { +const byte GMT_drywet_gp[] PROGMEM = { 0, 47, 30, 2, 42, 213,147, 24, 84, 103,219, 52, @@ -243,7 +245,7 @@ DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 24 bytes of program space. -DEFINE_GRADIENT_PALETTE( ib15_gp ) { +const byte ib15_gp[] PROGMEM = { 0, 113, 91,147, 72, 157, 88, 78, 89, 208, 85, 33, @@ -257,7 +259,7 @@ DEFINE_GRADIENT_PALETTE( ib15_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( Tertiary_01_gp ) { +const byte Tertiary_01_gp[] PROGMEM = { 0, 0, 1,255, 63, 3, 68, 45, 127, 23,255, 0, @@ -270,7 +272,7 @@ DEFINE_GRADIENT_PALETTE( Tertiary_01_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 52 bytes of program space. -DEFINE_GRADIENT_PALETTE( lava_gp ) { +const byte lava_gp[] PROGMEM = { 0, 0, 0, 0, 46, 18, 0, 0, 96, 113, 0, 0, @@ -291,7 +293,7 @@ DEFINE_GRADIENT_PALETTE( lava_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( fierce_ice_gp ) { +const byte fierce_ice_gp[] PROGMEM = { 0, 0, 0, 0, 59, 0, 9, 45, 119, 0, 38,255, @@ -306,7 +308,7 @@ DEFINE_GRADIENT_PALETTE( fierce_ice_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 44 bytes of program space. -DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { +const byte Colorfull_gp[] PROGMEM = { 0, 10, 85, 5, 25, 29,109, 18, 60, 59,138, 42, @@ -325,7 +327,7 @@ DEFINE_GRADIENT_PALETTE( Colorfull_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 44 bytes of program space. -DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { +const byte Pink_Purple_gp[] PROGMEM = { 0, 19, 2, 39, 25, 26, 4, 45, 51, 33, 6, 52, @@ -344,7 +346,7 @@ DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { +const byte Sunset_Real_gp[] PROGMEM = { 0, 120, 0, 0, 22, 179, 22, 0, 51, 255,104, 0, @@ -359,7 +361,7 @@ DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 44 bytes of program space. -DEFINE_GRADIENT_PALETTE( Sunset_Yellow_gp ) { +const byte Sunset_Yellow_gp[] PROGMEM = { 0, 10, 62,123, 36, 56,130,103, 87, 153,225, 85, @@ -378,7 +380,7 @@ DEFINE_GRADIENT_PALETTE( Sunset_Yellow_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 60 bytes of program space. -DEFINE_GRADIENT_PALETTE( Beech_gp ) { +const byte Beech_gp[] PROGMEM = { 0, 255,252,214, 12, 255,252,214, 22, 255,252,214, @@ -401,7 +403,7 @@ DEFINE_GRADIENT_PALETTE( Beech_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 32 bytes of program space. -DEFINE_GRADIENT_PALETTE( Another_Sunset_gp ) { +const byte Another_Sunset_gp[] PROGMEM = { 0, 110, 49, 11, 29, 55, 34, 10, 68, 22, 22, 9, @@ -420,7 +422,7 @@ DEFINE_GRADIENT_PALETTE( Another_Sunset_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 52 bytes of program space. -DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { +const byte es_autumn_19_gp[] PROGMEM = { 0, 26, 1, 1, 51, 67, 4, 1, 84, 118, 14, 1, @@ -441,7 +443,7 @@ DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { +const byte BlacK_Blue_Magenta_White_gp[] PROGMEM = { 0, 0, 0, 0, 42, 0, 0, 45, 84, 0, 0,255, @@ -456,7 +458,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { +const byte BlacK_Magenta_Red_gp[] PROGMEM = { 0, 0, 0, 0, 63, 42, 0, 45, 127, 255, 0,255, @@ -469,7 +471,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 28 bytes of program space. -DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { +const byte BlacK_Red_Magenta_Yellow_gp[] PROGMEM = { 0, 0, 0, 0, 42, 42, 0, 0, 84, 255, 0, 0, @@ -484,7 +486,7 @@ DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) { // converted for FastLED with gammas (2.6, 2.2, 2.5) // Size: 20 bytes of program space. -DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) { +const byte Blue_Cyan_Yellow_gp[] PROGMEM = { 0, 0, 0,255, 63, 0, 55,255, 127, 0,255,255, @@ -494,7 +496,7 @@ DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) { //Custom palette by Aircoookie -DEFINE_GRADIENT_PALETTE( Orange_Teal_gp ) { +const byte Orange_Teal_gp[] PROGMEM = { 0, 0,150, 92, 55, 0,150, 92, 200, 255, 72, 0, @@ -502,7 +504,7 @@ DEFINE_GRADIENT_PALETTE( Orange_Teal_gp ) { //Custom palette by Aircoookie -DEFINE_GRADIENT_PALETTE( Tiamat_gp ) { +const byte Tiamat_gp[] PROGMEM = { 0, 1, 2, 14, //gc 33, 2, 5, 35, //gc from 47, 61,126 100, 13,135, 92, //gc from 88,242,247 @@ -517,7 +519,7 @@ DEFINE_GRADIENT_PALETTE( Tiamat_gp ) { //Custom palette by Aircoookie -DEFINE_GRADIENT_PALETTE( April_Night_gp ) { +const byte April_Night_gp[] PROGMEM = { 0, 1, 5, 45, //deep blue 10, 1, 5, 45, 25, 5,169,175, //light blue @@ -536,7 +538,7 @@ DEFINE_GRADIENT_PALETTE( April_Night_gp ) { 244, 1, 5, 45, 255, 1, 5, 45}; -DEFINE_GRADIENT_PALETTE( Orangery_gp ) { +const byte Orangery_gp[] PROGMEM = { 0, 255, 95, 23, 30, 255, 82, 0, 60, 223, 13, 8, @@ -548,7 +550,7 @@ DEFINE_GRADIENT_PALETTE( Orangery_gp ) { 255, 213, 37, 4}; //inspired by Mark Kriegsman https://gist.github.com/kriegsman/756ea6dcae8e30845b5a -DEFINE_GRADIENT_PALETTE( C9_gp ) { +const byte C9_gp[] PROGMEM = { 0, 184, 4, 0, //red 60, 184, 4, 0, 65, 144, 44, 2, //amber @@ -558,14 +560,14 @@ DEFINE_GRADIENT_PALETTE( C9_gp ) { 195, 7, 7, 88, //blue 255, 7, 7, 88}; -DEFINE_GRADIENT_PALETTE( Sakura_gp ) { +const byte Sakura_gp[] PROGMEM = { 0, 196, 19, 10, 65, 255, 69, 45, 130, 223, 45, 72, 195, 255, 82,103, 255, 223, 13, 17}; -DEFINE_GRADIENT_PALETTE( Aurora_gp ) { +const byte Aurora_gp[] PROGMEM = { 0, 1, 5, 45, //deep blue 64, 0,200, 23, 128, 0,255, 0, //green @@ -578,13 +580,7 @@ DEFINE_GRADIENT_PALETTE( Aurora_gp ) { // This will let us programmatically choose one based on // a number, rather than having to activate each explicitly // by name every time. -// Since it is const, this array could also be moved -// into PROGMEM to save SRAM, but for simplicity of illustration -// we'll keep it in a regular SRAM array. -// -// This list of color palettes acts as a "playlist"; you can -// add or delete, or re-arrange as you wish. -const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { +const byte* const gGradientPalettes[] PROGMEM = { Sunset_Real_gp, //13-00 Sunset es_rivendell_15_gp, //14-01 Rivendell es_ocean_breeze_036_gp, //15-02 Breeze @@ -625,9 +621,4 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { Aurora_gp, //50-37 Aurora }; - -// Count of how many cpt-city gradients are defined: -const uint8_t gGradientPaletteCount = - sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); - #endif diff --git a/wled00/wled00.ino b/wled00/wled00.ino index c147dca3..93789577 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -119,7 +119,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002243 +#define VERSION 2002251 char versionString[] = "0.9.1"; @@ -350,7 +350,7 @@ bool udpConnected = false, udpRgbConnected = false; bool showWelcomePage = false; //hue -char hueError[25] = "Inactive"; +byte hueError = HUE_ERROR_INACTIVE; //uint16_t hueFailCount = 0; float hueXLast = 0, hueYLast = 0; uint16_t hueHueLast = 0, hueCtLast = 0; diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index e5083131..d538e0c4 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -9,7 +9,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr) obuf = (dest == nullptr)? sbuf:dest; olen = 0; - oappend(""); + oappend((const char*)F("")); oappendi((nightlightActive && nightlightFade) ? briT : bri); oappend(""); @@ -65,7 +65,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr) { mesg += "E1.31 mode "; mesg += DMXMode; - mesg += " at DMX Address "; + mesg += F(" at DMX Address "); mesg += DMXAddress; mesg += " from "; mesg += realtimeIP[0]; @@ -85,7 +85,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr) mesg += realtimeIP[i]; } } else if (realtimeMode == REALTIME_MODE_ADALIGHT) { - mesg += "USB Adalight"; + mesg += F("USB Adalight"); } else { //generic mesg += "data"; } @@ -137,11 +137,11 @@ char* URL_response(AsyncWebServerRequest *request) obuf = sbuf; olen = 0; - oappend(""); + oappend((const char*)F("\" target=\"_blank\">")); oappend(s2buf); - oappend(""); + oappend((const char*)F("")); if (request != nullptr) request->send(200, "text/html", obuf); } @@ -355,9 +355,7 @@ void getSettingsJS(byte subPage, char* dest) sappends('s',"MG",mqttGroupTopic); #endif - #ifdef WLED_DISABLE_HUESYNC - sappends('m',"(\"hms\")[0]","Unsupported in build"); - #else + #ifndef WLED_DISABLE_HUESYNC sappend('v',"H0",hueIP[0]); sappend('v',"H1",hueIP[1]); sappend('v',"H2",hueIP[2]); @@ -368,7 +366,20 @@ void getSettingsJS(byte subPage, char* dest) sappend('c',"HO",hueApplyOnOff); sappend('c',"HB",hueApplyBri); sappend('c',"HC",hueApplyColor); - sappends('m',"(\"hms\")[0]",hueError); + char hueErrorString[25]; + switch (hueError) + { + case HUE_ERROR_INACTIVE : strcpy(hueErrorString,(char*)F("Inactive")); break; + case HUE_ERROR_ACTIVE : strcpy(hueErrorString,(char*)F("Active")); break; + case HUE_ERROR_UNAUTHORIZED : strcpy(hueErrorString,(char*)F("Unauthorized")); break; + case HUE_ERROR_LIGHTID : strcpy(hueErrorString,(char*)F("Invalid light ID")); break; + case HUE_ERROR_PUSHLINK : strcpy(hueErrorString,(char*)F("Link button not pressed")); break; + case HUE_ERROR_JSON_PARSING : strcpy(hueErrorString,(char*)F("JSON parsing error")); break; + case HUE_ERROR_TIMEOUT : strcpy(hueErrorString,(char*)F("Timeout")); break; + default: sprintf(hueErrorString,"Bridge Error %i",hueError); + } + + sappends('m',"(\"hms\")[0]",hueErrorString); #endif } diff --git a/wled00/wled15_hue.ino b/wled00/wled15_hue.ino index 77e6622c..5f6b8f5b 100644 --- a/wled00/wled15_hue.ino +++ b/wled00/wled15_hue.ino @@ -23,7 +23,7 @@ void handleHue() reconnectHue(); } else { hueClient->close(); - if (hueError[0] == 'A') strcpy(hueError,"Inactive"); + if (hueError == HUE_ERROR_ACTIVE) hueError = HUE_ERROR_INACTIVE; } } @@ -44,7 +44,7 @@ void reconnectHue() void onHueError(void* arg, AsyncClient* client, int8_t error) { DEBUG_PRINTLN("Hue err"); - strcpy(hueError,"Request timeout"); + hueError = HUE_ERROR_TIMEOUT; } void onHueConnect(void* arg, AsyncClient* client) @@ -59,15 +59,15 @@ void sendHuePoll() String req = ""; if (hueAuthRequired) { - req += "POST /api HTTP/1.1\r\nHost: "; + req += F("POST /api HTTP/1.1\r\nHost: "); req += hueIP.toString(); - req += "\r\nContent-Length: 25\r\n\r\n{\"devicetype\":\"wled#esp\"}"; + req += F("\r\nContent-Length: 25\r\n\r\n{\"devicetype\":\"wled#esp\"}"); } else { req += "GET /api/"; req += hueApiKey; req += "/lights/" + String(huePollLightId); - req += " HTTP/1.1\r\nHost: "; + req += F(" HTTP/1.1\r\nHost: "); req += hueIP.toString(); req += "\r\n\r\n"; } @@ -93,21 +93,18 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len) auto error = deserializeJson(root, str); if (error) { - strcpy(hueError,"JSON parsing error"); return; + hueError = HUE_ERROR_JSON_PARSING; return; } int hueErrorCode = root[0]["error"]["type"]; if (hueErrorCode)//hue bridge returned error { + hueError = hueErrorCode; switch (hueErrorCode) { - case 1: strcpy(hueError,"Unauthorized"); hueAuthRequired = true; break; - case 3: strcpy(hueError,"Invalid light ID"); huePollingEnabled = false; break; - case 101: strcpy(hueError,"Link button not pressed"); hueAuthRequired = true; break; - default: - char coerr[18]; - sprintf(coerr,"Bridge Error %i",hueErrorCode); - strcpy(hueError,coerr); + case 1: hueAuthRequired = true; break; //Unauthorized user + case 3: huePollingEnabled = false; break; //Invalid light ID + case 101: hueAuthRequired = true; break; //link button not presset } return; } @@ -133,7 +130,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len) auto error = deserializeJson(root, str); if (error) { - strcpy(hueError,"JSON parsing error"); return; + hueError = HUE_ERROR_JSON_PARSING; return; } float hueX=0, hueY=0; @@ -173,7 +170,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len) hueBri = 0; } - strcpy(hueError,"Active"); + hueError = HUE_ERROR_ACTIVE; //apply vals if (hueBri != hueBriLast) diff --git a/wled00/wled18_server.ino b/wled00/wled18_server.ino index 826425d1..f11a64be 100644 --- a/wled00/wled18_server.ino +++ b/wled00/wled18_server.ino @@ -62,44 +62,44 @@ void initServer() }); server.on("/reset", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 200,"Rebooting now...","Please wait ~10 seconds...",129); + serveMessage(request, 200,"Rebooting now...",F("Please wait ~10 seconds..."),129); doReboot = true; }); server.on("/settings/wifi", HTTP_POST, [](AsyncWebServerRequest *request){ if (!(wifiLock && otaLock)) handleSettingsSet(request, 1); - serveMessage(request, 200,"WiFi settings saved.","Please connect to the new IP (if changed)",129); + serveMessage(request, 200,F("WiFi settings saved."),F("Please connect to the new IP (if changed)"),129); forceReconnect = true; }); server.on("/settings/leds", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 2); - serveMessage(request, 200,"LED settings saved.","Redirecting...",1); + serveMessage(request, 200,F("LED settings saved."),"Redirecting...",1); }); server.on("/settings/ui", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 3); - serveMessage(request, 200,"UI settings saved.","Redirecting...",1); + serveMessage(request, 200,F("UI settings saved."),"Redirecting...",1); }); server.on("/settings/dmx", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 7); - serveMessage(request, 200,"UI settings saved.","Redirecting...",1); + serveMessage(request, 200,F("UI settings saved."),"Redirecting...",1); }); server.on("/settings/sync", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 4); - serveMessage(request, 200,"Sync settings saved.","Redirecting...",1); + serveMessage(request, 200,F("Sync settings saved."),"Redirecting...",1); }); server.on("/settings/time", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 5); - serveMessage(request, 200,"Time settings saved.","Redirecting...",1); + serveMessage(request, 200,F("Time settings saved."),"Redirecting...",1); }); server.on("/settings/sec", HTTP_POST, [](AsyncWebServerRequest *request){ handleSettingsSet(request, 6); - if (!doReboot) serveMessage(request, 200,"Security settings saved.","Rebooting, please wait ~10 seconds...",129); + if (!doReboot) serveMessage(request, 200,F("Security settings saved."),F("Rebooting, please wait ~10 seconds..."),129); doReboot = true; }); @@ -148,7 +148,7 @@ void initServer() }); server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254); + serveMessage(request, 418, F("418. I'm a teapot."), F("(Tangible Embedded Advanced Project Of Twinkling)"), 254); }); //if OTA is allowed @@ -161,7 +161,7 @@ void initServer() #endif #else server.on("/edit", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 501, "Not implemented", "The SPIFFS editor is disabled in this build.", 254); + serveMessage(request, 501, "Not implemented", F("The SPIFFS editor is disabled in this build."), 254); }); #endif //init ota page @@ -173,9 +173,9 @@ void initServer() server.on("/update", HTTP_POST, [](AsyncWebServerRequest *request){ if (Update.hasError()) { - serveMessage(request, 500, "Failed updating firmware!", "Please check your file and retry!", 254); return; + serveMessage(request, 500, F("Failed updating firmware!"), F("Please check your file and retry!"), 254); return; } - serveMessage(request, 200, "Successfully updated firmware!", "Please wait while the module reboots...", 131); + serveMessage(request, 200, F("Successfully updated firmware!"), F("Please wait while the module reboots..."), 131); doReboot = true; },[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){ if(!index){ @@ -197,7 +197,7 @@ void initServer() #else server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 501, "Not implemented", "OTA updates are disabled in this build.", 254); + serveMessage(request, 501, "Not implemented", F("OTA updates are disabled in this build."), 254); }); #endif } else @@ -217,7 +217,7 @@ void initServer() }); #else server.on("/dmxmap", HTTP_GET, [](AsyncWebServerRequest *request){ - serveMessage(request, 501, "Not implemented", "DMX support is not enabled in this build.", 254); + serveMessage(request, 501, "Not implemented", F("DMX support is not enabled in this build."), 254); }); #endif server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ @@ -292,10 +292,10 @@ String msgProcessor(const String& var) messageBody += ""; } else if (optt == 253) { - messageBody += "

"; //button to settings + messageBody += F("

"); //button to settings } else if (optt == 254) { - messageBody += "

"; + messageBody += F("

"); } return messageBody; } @@ -324,7 +324,7 @@ String settingsProcessor(const String& var) #ifdef WLED_ENABLE_DMX if (var == "DMXMENU") { - return String("
"); + return String(F("
")); } #endif diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 5cc1f519..4d935973 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -343,7 +343,7 @@ void serveJson(AsyncWebServerRequest* request) return; } else if (url.length() > 6) { //not just /json - request->send( 501, "application/json", "{\"error\":\"Not implemented\"}"); + request->send( 501, "application/json", F("{\"error\":\"Not implemented\"}")); return; } From 755448f9f5a8ed9349f828a4b57f711725c421ee Mon Sep 17 00:00:00 2001 From: cschwinne Date: Tue, 25 Feb 2020 02:25:17 +0100 Subject: [PATCH 3/3] Fix LED pin changed --- readme.md | 2 +- wled00/NpbWrapper.h | 4 ++-- wled00/wled00.ino | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 1cbe9b80..c796ca5c 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control ### Features: - WS2812FX library integrated for over 100 special effects -- FastLED noise effects and palettes +- FastLED noise effects and 50 palettes - Modern UI with color, effect and segment controls - Segments to set different effects and colors to parts of the LEDs - Settings page - configuration over network diff --git a/wled00/NpbWrapper.h b/wled00/NpbWrapper.h index f12d057f..71367d98 100644 --- a/wled00/NpbWrapper.h +++ b/wled00/NpbWrapper.h @@ -4,7 +4,7 @@ //PIN CONFIGURATION #ifndef LEDPIN -#define LEDPIN 5 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) +#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos) #endif //#define USE_APA102 // Uncomment for using APA102 LEDs. //#define USE_WS2801 // Uncomment for using WS2801 LEDs (make sure you have NeoPixelBus v2.5.6 or newer) @@ -30,7 +30,7 @@ #endif #ifndef RLYMDE -#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on +#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on #endif //END CONFIGURATION diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 93789577..f214929c 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -119,7 +119,7 @@ #endif //version code in format yymmddb (b = daily build) -#define VERSION 2002251 +#define VERSION 2002252 char versionString[] = "0.9.1"; @@ -430,7 +430,7 @@ IPAddress ntpServerIP; uint16_t ntpLocalPort = 2390; #define NTP_PACKET_SIZE 48 -//maximum number of LEDs - MAX_LEDS is comming from the JSON response getting too big, MAX_LEDS_DMA will become a timing issue +//maximum number of LEDs - MAX_LEDS is coming from the JSON response getting too big, MAX_LEDS_DMA will become a timing issue #define MAX_LEDS 1500 #define MAX_LEDS_DMA 500