Remove toggleOnOff() and use setBrightness().

Return state to Off if it was Off when realtime mode started.
This commit is contained in:
Blaž Kristan 2021-03-19 08:24:45 +01:00
parent c59e792178
commit baf4a241a2
3 changed files with 13 additions and 4 deletions

View File

@ -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;

View File

@ -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

View File

@ -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();