diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 139643b47..be13d2f50 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -7,6 +7,8 @@ #define WLEDPACKETSIZE 29 #define UDP_IN_MAXSIZE 1472 +static bool wasOff = false; // flag if strip was Off (bri==0) when realtime started + void notify(byte callMode, bool followUp) { if (!udpConnected) return; @@ -83,8 +85,11 @@ void realtimeLock(uint32_t timeoutMs, byte md) realtimeTimeout = millis() + timeoutMs; if (timeoutMs == 255001 || timeoutMs == 65000) realtimeTimeout = UINT32_MAX; - if (bri == 0 && realtimeMode == REALTIME_MODE_INACTIVE && md != realtimeMode) { - toggleOnOff(); // if strip is off (bri==0) and change from inactive RTM + // if strip is off (bri==0) and not already in RTM + if (bri == 0 && !realtimeMode) { + wasOff = true; + bri = briLast; // global brightness awareness + strip.setBrightness(scaledBri(briLast)); } realtimeMode = md; @@ -120,6 +125,10 @@ void handleNotifications() if (realtimeMode && millis() > realtimeTimeout) { if (realtimeOverride == REALTIME_OVERRIDE_ONCE) realtimeOverride = REALTIME_OVERRIDE_NONE; + if (wasOff) { + bri = 0; // if inital state was off turn strip back off + wasOff = false; + } strip.setBrightness(scaledBri(bri)); realtimeMode = REALTIME_MODE_INACTIVE; realtimeIP[0] = 0; diff --git a/wled00/wled.h b/wled00/wled.h index 4287f117f..9b644853f 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2103180 +#define VERSION 2103190 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG diff --git a/wled00/wled_serial.cpp b/wled00/wled_serial.cpp index de4c3697b..be6f72e47 100644 --- a/wled00/wled_serial.cpp +++ b/wled00/wled_serial.cpp @@ -90,7 +90,7 @@ void handleSerial() if (!realtimeOverride) setRealtimePixel(pixel++, red, green, blue, 0); if (--count > 0) state = AdaState::Data_Red; else { - if (!realtimeMode && bri == 0) strip.setBrightness(briLast); + // if (!realtimeMode && bri == 0) strip.setBrightness(briLast); //realtimeLock() handles turning strip on/off realtimeLock(realtimeTimeoutMs, REALTIME_MODE_ADALIGHT); if (!realtimeOverride) strip.show();