diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index ada486d5..c6228539 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -1192,8 +1192,8 @@ class PolyBus { if (num > 7) return I_NONE; #else if (num > 8) return I_NONE; - if (num == 1) offset = 2; // use I2S#1 as 2nd bus - seems to be a good compromise for performance, and reduces flickering for some users - // if (num == 0) offset = 2; // un-comment to use I2S#1 as 1st bus - sometimes helps, if you experience flickering during Wifi or filesystem activity. + //if (num == 1) offset = 2; // use I2S#1 as 2nd bus - seems to be a good compromise for performance, and reduces flickering for some users + if (num == 0) offset = 2; // un-comment to use I2S#1 as 1st bus - sometimes helps, if you experience flickering during Wifi or filesystem activity. #endif #endif #endif diff --git a/wled00/file.cpp b/wled00/file.cpp index bf7c1a7a..9d6e6a1e 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -35,6 +35,14 @@ static File f; // don't export to other cpp files //wrapper to find out how long closing takes void closeFile() { + #ifdef ARDUINO_ARCH_ESP32 + // WLEDMM: file.close() triggers flash writing. While flash is writing, the NPB RMT driver cannot fill its buffer which may create glitches. + unsigned long t_wait = millis(); + while(strip.isUpdating() && (millis() - t_wait < 72)) delay(1); // WLEDMM try to catch a moment when strip is idle + while(strip.isUpdating() && (millis() - t_wait < 96)) delay(0); // try harder + //if (strip.isUpdating()) USER_PRINTLN("closeFile: strip still updating."); + delay(2); // might help + #endif #ifdef WLED_DEBUG_FS DEBUGFS_PRINT(F("Close -> ")); uint32_t s = millis(); diff --git a/wled00/json.cpp b/wled00/json.cpp index 8bd9cd2d..dbb51f91 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -1032,6 +1032,14 @@ void serializeInfo(JsonObject root) if(ESP.getChipCores() > 1) // WLEDMM root[F("resetReason1")] = (int)rtc_get_reset_reason(1); #endif + + #if defined(ARDUINO_ARCH_ESP32) + unsigned long t_wait = millis(); + while(strip.isUpdating() && (millis() - t_wait < 125)) delay(1); // WLEDMM try to catch a moment when strip is idle + while(strip.isUpdating() && (millis() - t_wait < 160)) yield(); // try harder + //if (strip.isUpdating()) USER_PRINTLN("serializeInfo: strip still updating."); + #endif + root[F("lwip")] = 0; //deprecated root[F("totalheap")] = ESP.getHeapSize(); //WLEDMM #else diff --git a/wled00/wled.cpp b/wled00/wled.cpp index e8e9eecc..52c1b321 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1031,6 +1031,12 @@ bool WLED::initEthernet() void WLED::initConnection() { +#ifdef ARDUINO_ARCH_ESP32 + unsigned long t_wait = millis(); + while(strip.isUpdating() && (millis() - t_wait < 86)) delay(1); // WLEDMM try to catch a moment when strip is idle + //if (strip.isUpdating()) USER_PRINTLN("WLED::initConnection: strip still updating."); +#endif + #ifdef WLED_ENABLE_WEBSOCKETS ws.onEvent(wsEvent); #endif @@ -1208,7 +1214,7 @@ void WLED::handleConnection() static unsigned retryCount = 0; // WLEDMM #ifdef ARDUINO_ARCH_ESP32 // reconnect WiFi to clear stale allocations if heap gets too low - if (now - heapTime > 5000) { // WLEDMM: updated with better logic for small heap available by block, not total. + if ((!strip.isUpdating()) && (now - heapTime > 5000)) { // WLEDMM: updated with better logic for small heap available by block, not total. // WLEDMM trying to use a moment when the strip is idle #if defined(ARDUINO_ARCH_ESP32S2) uint32_t heap = ESP.getFreeHeap(); // WLEDMM works better on -S2 #else diff --git a/wled00/wled.h b/wled00/wled.h index 5e5048dd..dc3ee12b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2404230 +#define VERSION 2404260 // WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED. #define _MoonModules_WLED_