diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 4afb99906b..adcc5e7079 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1585,7 +1585,9 @@ void WS2812FX::blendSegment(const Segment &topSegment) const { // workaround for On/Off transition // (bri != briT) && !bri => from On to Off // (bri != briT) && bri => from Off to On - if ((briOld == 0 || bri == 0) && ((!clipped && (bri != briT) && !bri) || (clipped && (bri != briT) && bri))) c_a = BLACK; + // note: only blank pixels once the segment transition has actually started; bri changes before + // startTransition() is called (stateUpdated()) and a frame rendered in that window would blank the whole segment + if (topSegment.isInTransition() && (briOld == 0 || bri == 0) && ((!clipped && (bri != briT) && !bri) || (clipped && (bri != briT) && bri))) c_a = BLACK; } // map it into frame buffer x = c; // restore coordiates if we were PUSHing @@ -1657,7 +1659,9 @@ void WS2812FX::blendSegment(const Segment &topSegment) const { // workaround for On/Off transition // (bri != briT) && !bri => from On to Off // (bri != briT) && bri => from Off to On - if ((briOld == 0 || bri == 0) && ((!clipped && (bri != briT) && !bri) || (clipped && (bri != briT) && bri))) c_a = BLACK; + // note: only blank pixels once the segment transition has actually started; bri changes before + // startTransition() is called (stateUpdated()) and a frame rendered in that window would blank the whole segment + if (topSegment.isInTransition() && (briOld == 0 || bri == 0) && ((!clipped && (bri != briT) && !bri) || (clipped && (bri != briT) && bri))) c_a = BLACK; } // map into frame buffer i = k; // restore index if we were PUSHing @@ -1907,8 +1911,9 @@ void WS2812FX::resetSegments() { if (isServicing()) return; _segments.clear(); // destructs all Segment as part of clearing _segments.emplace_back(0, isMatrix ? Segment::maxWidth : _length, 0, isMatrix ? Segment::maxHeight : 1); - if(_segments.size() == 0) { - _segments.emplace_back(); // if out of heap, create a default segment + if (getActiveSegmentsNum() == 0) { + _segments.clear(); // free failed segment + _segments.emplace_back(); // if out of heap, create a default 30 pixel segment errorFlag = ERR_NORAM_PX; } _segments.shrink_to_fit(); // just in case ... @@ -1985,6 +1990,7 @@ void WS2812FX::makeAutoSegments(bool forceReset) { #endif } } + if (getActiveSegmentsNum() == 0) resetSegments(); // fallback if auto segment creation failed _mainSegment = 0; fixInvalidSegments(); diff --git a/wled00/network.cpp b/wled00/network.cpp index 606fa65d9e..83e196178d 100644 --- a/wled00/network.cpp +++ b/wled00/network.cpp @@ -421,7 +421,8 @@ void WiFiEvent(WiFiEvent_t event) switch (event) { case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED: // AP client disconnected - if (--apClients == 0 && isWiFiConfigured()) forceReconnect = true; // no clients reconnect WiFi if awailable + if (apClients > 0) apClients--; + if (apClients == 0 && isWiFiConfigured()) forceReconnect = true; // no clients reconnect WiFi if available DEBUG_PRINTF_P(PSTR("WiFi-E: AP Client Disconnected (%d) @ %lus.\n"), (int)apClients, millis()/1000); break; case ARDUINO_EVENT_WIFI_AP_STACONNECTED: diff --git a/wled00/playlist.cpp b/wled00/playlist.cpp index c5acecdaf1..d8dde0c744 100644 --- a/wled00/playlist.cpp +++ b/wled00/playlist.cpp @@ -109,7 +109,8 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) { it++; } } - for (int i = it; i < playlistLen; i++) playlistEntries[i].tr = playlistEntries[it -1].tr; + if (it > 0) // should never happen but just in case + for (int i = it; i < playlistLen; i++) playlistEntries[i].tr = playlistEntries[it -1].tr; int rep = playlistObj[F("repeat")]; bool shuffle = false; diff --git a/wled00/set.cpp b/wled00/set.cpp index fb516ac7d6..7f61cb87bb 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -105,7 +105,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) apBehavior = request->arg(F("AB")).toInt(); char oldSSID[33]; strcpy(oldSSID, apSSID); strlcpy(apSSID, request->arg(F("AS")).c_str(), 33); - if (!strcmp(oldSSID, apSSID) && apActive) forceReconnect = true; + if ((strcmp(oldSSID, apSSID) != 0) && apActive) forceReconnect = true; // AP SSID changed apHide = request->hasArg(F("AH")); int passlen = request->arg(F("AP")).length(); if (passlen == 0 || (passlen > 7 && !isAsterisksOnly(request->arg(F("AP")).c_str(), 65))) {