From 021c4ba68ade7c0dd564285365435ac7252cf0a3 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Sun, 29 Aug 2021 11:49:06 -0700 Subject: [PATCH 1/5] Revert changes from PR1902 --- wled00/cfg.cpp | 7 ---- wled00/colors.cpp | 71 ----------------------------------- wled00/data/settings_sync.htm | 7 +--- wled00/fcn_declare.h | 3 -- wled00/html_settings.h | 13 +++---- wled00/set.cpp | 4 -- wled00/udp.cpp | 8 +--- wled00/wled.h | 3 -- wled00/xml.cpp | 4 -- 9 files changed, 9 insertions(+), 111 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 2214584cd..6e3ecd1e2 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -274,10 +274,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(arlsDisableGammaCorrection, if_live[F("no-gc")]); // false CJSON(arlsOffset, if_live[F("offset")]); // 0 - CJSON(liveHSVCorrection, if_live[F("corr")]); - CJSON(liveHSVSaturation, if_live[F("hsvsat")]); - CJSON(liveHSVValue, if_live[F("hsvval")]); - CJSON(alexaEnabled, interfaces["va"][F("alexa")]); // false CJSON(macroAlexaOn, interfaces["va"]["macros"][0]); @@ -622,9 +618,6 @@ void serializeConfig() { if_live[F("maxbri")] = arlsForceMaxBri; if_live[F("no-gc")] = arlsDisableGammaCorrection; if_live[F("offset")] = arlsOffset; - if_live[F("corr")] = liveHSVCorrection; - if_live[F("hsvsat")] = liveHSVSaturation; - if_live[F("hsvval")] = liveHSVValue; JsonObject if_va = interfaces.createNestedObject("va"); if_va[F("alexa")] = alexaEnabled; diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 5db873267..dfdd53e07 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -47,77 +47,6 @@ void relativeChangeWhite(int8_t amount, byte lowerBoundary) col[3] = new_val; } -void colorHSVtoRGB(float hue, float saturation, float value, byte& red, byte& green, byte& blue) -{ - float r, g, b; - - auto i = static_cast(hue * 6); - auto f = hue * 6 - i; - auto p = value * (1 - saturation); - auto q = value * (1 - f * saturation); - auto t = value * (1 - (1 - f) * saturation); - - switch (i % 6) - { - case 0: r = value, g = t, b = p; - break; - case 1: r = q, g = value, b = p; - break; - case 2: r = p, g = value, b = t; - break; - case 3: r = p, g = q, b = value; - break; - case 4: r = t, g = p, b = value; - break; - case 5: r = value, g = p, b = q; - break; - } - - red = static_cast(r * 255); - green = static_cast(g * 255); - blue = static_cast(b * 255); -} - -void colorRGBtoHSV(byte red, byte green, byte blue, float& hue, float& saturation, float& value) -{ - auto rd = static_cast(red) / 255; - auto gd = static_cast(green) / 255; - auto bd = static_cast(blue) / 255; - auto max = std::max({ rd, gd, bd }), min = std::min({ rd, gd, bd }); - - value = max; - - auto d = max - min; - saturation = max == 0 ? 0 : d / max; - - hue = 0; - if (max != min) - { - if (max == rd) hue = (gd - bd) / d + (gd < bd ? 6 : 0); - else if (max == gd) hue = (bd - rd) / d + 2; - else if (max == bd) hue = (rd - gd) / d + 4; - hue /= 6; - } -} - -#define SATURATION_THRESHOLD 0.1 -#define MAX_HSV_VALUE 1 -#define MAX_HSV_SATURATION 1 - -//corrects the realtime colors. 10 is the unchanged saturation/value -//this feature might cause slowdowns with large LED counts -void correctColors(byte r, byte g, byte b, byte* rgb) { - float hsv[3] = { 0,0,0 }; - colorRGBtoHSV(r, g,b , hsv[0], hsv[1], hsv[2]); - float saturated = hsv[1] > SATURATION_THRESHOLD ? - hsv[1] * ((float)liveHSVSaturation / 10) : hsv[1]; - float saturation = saturated < MAX_HSV_SATURATION ? saturated : MAX_HSV_SATURATION; - - float valued = hsv[2] * ((float)liveHSVValue/10); - float value = valued < MAX_HSV_VALUE ? valued : MAX_HSV_VALUE; - colorHSVtoRGB(hsv[0], saturation, value, rgb[0], rgb[1], rgb[2]); -} - void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb { float h = ((float)hue)/65535.0; diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 3e42e35fa..23cddc28a 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -28,7 +28,7 @@ Send notifications twice:
Reboot required to apply changes.

Instance List

Enable instance list:
-Make this instance discoverable: +Make this instance discoverable:

Realtime

Receive UDP realtime:

Network DMX input
@@ -59,10 +59,7 @@ DMX mode: Timeout: ms
Force max brightness:
Disable realtime gamma correction:
-Realtime LED offset:

-Realtime HSV color correction:
-Saturation (1-30):
-Value (1-60): +Realtime LED offset:

Alexa Voice Assistant

Emulate Alexa device:
Alexa invocation name: diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 0e3dc1d81..3c458a155 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -58,9 +58,6 @@ void colorFromUint32(uint32_t in, bool secondary = false); void colorFromUint24(uint32_t in, bool secondary = false); uint32_t colorFromRgbw(byte* rgbw); void relativeChangeWhite(int8_t amount, byte lowerBoundary = 0); -void colorHSVtoRGB(float hue, float saturation, float value, byte& red, byte& green, byte& blue); -void colorRGBtoHSV(byte red, byte green, byte blue, float& hue, float& saturation, float& value); -void correctColors(byte r, byte g, byte b, byte* rgb); void colorHStoRGB(uint16_t hue, byte sat, byte* rgb); //hue, sat to rgb void colorKtoRGB(uint16_t kelvin, byte* rgb); void colorCTtoRGB(uint16_t mired, byte* rgb); //white spectrum to rgb diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 4d02814f1..a2627ae5b 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -254,8 +254,8 @@ Send Macro notifications:
Send notifications twice:
Reboot required to apply changes.

Instance List

Enable instance list:
-Make this instance discoverable:

Realtime -

Receive UDP realtime:

+Make this instance discoverable:

+Realtime

Receive UDP realtime:

Network DMX input
Type: ms
Force max brightness:
Disable realtime gamma correction:
Realtime LED offset:

Realtime HSV color correction:
Saturation (1-30):
Value (1-60):

Alexa Voice Assistant

-Emulate Alexa device:
-Alexa invocation name:

Blynk

+required>

Alexa Voice Assistant

Emulate Alexa device:
Alexa invocation name:

Blynk

Blynk, MQTT and Hue sync all connect to external hosts!
This may impact the responsiveness of the ESP8266.

For best results, only use one of these services at a time.
diff --git a/wled00/set.cpp b/wled00/set.cpp index 080fea9ce..3607e10fb 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -221,10 +221,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) notifyMacro = request->hasArg(F("SM")); notifyTwice = request->hasArg(F("S2")); - liveHSVCorrection = request->hasArg(F("HX")); - liveHSVSaturation = request->arg(F("HS")).toInt(); - liveHSVValue = request->arg(F("HV")).toInt(); - nodeListEnabled = request->hasArg(F("NL")); if (!nodeListEnabled) Nodes.clear(); nodeBroadcastEnabled = request->hasArg(F("NB")); diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 590d25407..31ecf8018 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -161,7 +161,8 @@ void handleNotifications() for (uint16_t i = 0; i < packetSize -2; i += 3) { setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0); - id++; if (id >= ledCount) break; + id++; + if (id >= ledCount) break; } strip.show(); return; @@ -423,11 +424,6 @@ void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w) uint16_t pix = i + arlsOffset; if (pix < ledCount) { - if (liveHSVCorrection) { - byte correctedColors[3] = {0,0,0}; - correctColors(r, g, b, correctedColors); - r = correctedColors[0]; g = correctedColors[1]; b = correctedColors[2]; - } if (!arlsDisableGammaCorrection && strip.gammaCorrectCol) { strip.setPixelColor(pix, strip.gamma8(r), strip.gamma8(g), strip.gamma8(b), strip.gamma8(w)); diff --git a/wled00/wled.h b/wled00/wled.h index 4148478b7..2bf18de22 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -294,9 +294,6 @@ WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port WLED_GLOBAL uint16_t udpPort2 _INIT(65506); // WLED notifier supplemental port WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port -WLED_GLOBAL bool liveHSVCorrection _INIT(false); -WLED_GLOBAL uint16_t liveHSVSaturation _INIT(13); -WLED_GLOBAL uint16_t liveHSVValue _INIT(10); WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color diff --git a/wled00/xml.cpp b/wled00/xml.cpp index f87bf35db..41c83a00c 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -397,10 +397,6 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("UP"),udpPort); sappend('v',SET_F("U2"),udpPort2); - sappend('c',SET_F("HX"),liveHSVCorrection); - sappend('v',SET_F("HS"),liveHSVSaturation); - sappend('v',SET_F("HV"),liveHSVValue); - sappend('c',SET_F("RB"),receiveNotificationBrightness); sappend('c',SET_F("RC"),receiveNotificationColor); sappend('c',SET_F("RX"),receiveNotificationEffects); From e26299b998d8ede81b68974e8ea4230b51d33c0d Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 5 Sep 2021 00:39:47 +0200 Subject: [PATCH 2/5] Revert some small syntactical changes --- wled00/data/settings_sync.htm | 2 +- wled00/html_settings.h | 8 ++++---- wled00/udp.cpp | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 23cddc28a..0aa1125e2 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -28,7 +28,7 @@ Send notifications twice:
Reboot required to apply changes.

Instance List

Enable instance list:
-Make this instance discoverable:
+Make this instance discoverable:

Realtime

Receive UDP realtime:

Network DMX input
diff --git a/wled00/html_settings.h b/wled00/html_settings.h index a2627ae5b..a9724247e 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -254,8 +254,8 @@ Send Macro notifications:
Send notifications twice:
Reboot required to apply changes.

Instance List

Enable instance list:
-Make this instance discoverable:

-Realtime

Receive UDP realtime:

+Make this instance discoverable:

Realtime +

Receive UDP realtime:

Network DMX input
Type: ms
Force max brightness:
Disable realtime gamma correction:
Realtime LED offset:

Alexa Voice Assistant

Emulate Alexa device:
Alexa invocation name:

Alexa Voice Assistant

Emulate Alexa device:
Alexa invocation name:

Blynk

Blynk, MQTT and Hue sync all connect to external hosts!
This may impact the responsiveness of the ESP8266.

diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 31ecf8018..48c412f35 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -161,8 +161,7 @@ void handleNotifications() for (uint16_t i = 0; i < packetSize -2; i += 3) { setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0); - id++; - if (id >= ledCount) break; + id++; if (id >= ledCount) break; } strip.show(); return; From d0440122b9c66640fb69542f8997154b181d2135 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 12 Sep 2021 01:08:19 +0200 Subject: [PATCH 3/5] Bugfix for AutoSave & 4LD. --- .../usermod_v2_auto_save.h | 20 +++++------- .../usermod_v2_four_line_display.h | 31 +++++++++++-------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h index 98937fcfb..f2864362c 100644 --- a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h +++ b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h @@ -38,7 +38,7 @@ class AutoSaveUsermod : public Usermod { bool applyAutoSaveOnBoot = false; // do we load auto-saved preset on boot? // If we've detected the need to auto save, this will be non zero. - uint16_t autoSaveAfter = 0; + unsigned long autoSaveAfter = 0; uint8_t knownBrightness = 0; uint8_t knownEffectSpeed = 0; @@ -87,6 +87,12 @@ class AutoSaveUsermod : public Usermod { display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP); #endif initDone = true; + if (enabled && applyAutoSaveOnBoot) applyPreset(autoSavePreset); + knownBrightness = bri; + knownEffectSpeed = effectSpeed; + knownEffectIntensity = effectIntensity; + knownMode = strip.getMode(); + knownPalette = strip.getSegment(0).palette; } // gets called every time WiFi is (re-)connected. Initialize own network @@ -97,21 +103,11 @@ class AutoSaveUsermod : public Usermod { * Da loop. */ void loop() { - if (!autoSaveAfterSec || !enabled || strip.isUpdating()) return; // setting 0 as autosave seconds disables autosave + if (!autoSaveAfterSec || !enabled || strip.isUpdating() || currentPreset>0) return; // setting 0 as autosave seconds disables autosave unsigned long now = millis(); uint8_t currentMode = strip.getMode(); uint8_t currentPalette = strip.getSegment(0).palette; - if (firstLoop) { - firstLoop = false; - if (applyAutoSaveOnBoot) applyPreset(autoSavePreset); - knownBrightness = bri; - knownEffectSpeed = effectSpeed; - knownEffectIntensity = effectIntensity; - knownMode = currentMode; - knownPalette = currentPalette; - return; - } unsigned long wouldAutoSaveAfter = now + autoSaveAfterSec*1000; if (knownBrightness != bri) { diff --git a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h index 2089db933..03d91e5a9 100644 --- a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h +++ b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h @@ -346,8 +346,8 @@ class FourLineDisplayUsermod : public Usermod { (knownEffectIntensity != effectIntensity) || (knownMode != strip.getMode()) || (knownPalette != strip.getSegment(0).palette)) { - knownHour = 99; // force time update - clear(); + knownHour = 99; // force time update + lastRedraw = now; // update lastRedraw marker } else if (sleepMode && !displayTurnedOff && ((now - lastRedraw)/1000)%5 == 0) { // change line every 5s showName = !showName; @@ -372,13 +372,13 @@ class FourLineDisplayUsermod : public Usermod { break; } knownHour = 99; // force time update + // do not update lastRedraw marker if just switching row contenet } else { // Nothing to change. // Turn off display after 3 minutes with no change. if(sleepMode && !displayTurnedOff && (millis() - lastRedraw > screenTimeout)) { // We will still check if there is a change in redraw() // and turn it back on if it changed. - clear(); // force screen clear sleepOrClock(true); } else if (displayTurnedOff && clockMode) { showTime(); @@ -386,9 +386,6 @@ class FourLineDisplayUsermod : public Usermod { return; } - // do not update lastRedraw marker if just switching row contenet - if (((now - lastRedraw)/1000)%5 != 0) lastRedraw = now; - // Turn the display back on if (displayTurnedOff) sleepOrClock(false); @@ -409,7 +406,7 @@ class FourLineDisplayUsermod : public Usermod { center(line, getCols()-2); drawString(1, 0, line.c_str()); // Print `~` char to indicate that SSID is longer, than our display - if (knownSsid.length() > getCols()-1) { + if (knownSsid.length() > (int)getCols()-1) { drawString(getCols() - 1, 0, "~"); } @@ -523,14 +520,23 @@ class FourLineDisplayUsermod : public Usermod { */ void overlay(const char* line1, const char *line2, long showHowLong) { if (displayTurnedOff) { - // Turn the display back on + // Turn the display back on (includes clear()) sleepOrClock(false); + } else { + clear(); } // Print the overlay - clear(); - if (line1) drawString(0, 1*lineHeight, line1); - if (line2) drawString(0, 2*lineHeight, line2); + if (line1) { + String buf = line1; + center(buf, getCols()); + drawString(0, 1*lineHeight, buf.c_str()); + } + if (line2) { + String buf = line2; + center(buf, getCols()); + drawString(0, 2*lineHeight, buf.c_str()); + } overlayUntil = millis() + showHowLong; } @@ -557,6 +563,7 @@ class FourLineDisplayUsermod : public Usermod { * Enable sleep (turn the display off) or clock mode. */ void sleepOrClock(bool enabled) { + clear(); if (enabled) { if (clockMode) showTime(); else setPowerSave(1); @@ -582,8 +589,6 @@ class FourLineDisplayUsermod : public Usermod { if (knownMinute == minuteCurrent && knownHour == hourCurrent) { // Time hasn't changed. if (!fullScreen) return; - } else { - //if (fullScreen) clear(); } knownMinute = minuteCurrent; knownHour = hourCurrent; From bd239428939fc7f45dde176ba82807303975e141 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Sun, 12 Sep 2021 01:37:41 +0200 Subject: [PATCH 4/5] Fixed IR JSON cmd string (closes #2187 ) --- wled00/ir.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wled00/ir.cpp b/wled00/ir.cpp index ba22421d2..ca99e4d66 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -583,8 +583,9 @@ void decodeIRJson(uint32_t code) return; } - jsonCmdObj = fdo["cmd"]; - cmdStr = String(jsonCmdObj); + cmd = fdo["cmd"]; //string + cmdStr = String(cmd); + jsonCmdObj = fdo["cmd"]; //object if (!cmdStr.isEmpty()) { From 4bc401278ecbcde456504635bdd85dae19267cdb Mon Sep 17 00:00:00 2001 From: Scott Bailey Date: Wed, 15 Sep 2021 18:44:09 -0700 Subject: [PATCH 5/5] add env for sp511 --- platformio.ini | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platformio.ini b/platformio.ini index 6ca479ffa..0a64a94c9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -421,6 +421,13 @@ board_build.ldscript = ${common.ldscript_2m512k} build_flags = ${common.build_flags_esp8266} -D LEDPIN=3 -D BTNPIN=1 lib_deps = ${esp8266.lib_deps} +[env:sp511e] +board = esp_wroom_02 +platform = ${common.platform_wled_default} +board_build.ldscript = ${common.ldscript_2m512k} +build_flags = ${common.build_flags_esp8266} -D LEDPIN=3 -D BTNPIN=2 -D IRPIN=5 -D WLED_MAX_BUTTONS=3 +lib_deps = ${esp8266.lib_deps} + # ------------------------------------------------------------------------------ # travis test board configurations # ------------------------------------------------------------------------------