8266: fix flickering during file write (experimental)

8266 also has problems - file.close() will stall interrupts, so we need to wait a bit until leds were updated
This commit is contained in:
Frank
2026-03-21 20:37:53 +01:00
parent afb383d0a2
commit 11b9b6529c

View File

@@ -50,13 +50,21 @@ void closeFile() {
if (!f) {doCloseFile = false; return;} // WLEDMM only do all this hick-hack when f is an open file
bool oldLock = suspendStripService;
#if defined(WLEDMM_FILEWAIT) // only wait if we don't have the flicker-free RMTHI driver
#if defined(WLEDMM_FILEWAIT) || !defined(ARDUINO_ARCH_ESP32) // only wait if we don't have the flicker-free RMTHI driver
unsigned long t_wait = millis();
if (strip.isUpdating()) suspendStripService = true; // WLEDMM schedule short pause to prevent LEDs glitching during flash write
#if defined(ARDUINO_ARCH_ESP32)
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
#else // 8266: only wait in case that can_yield() tells us we can yield and delay
if (can_yield()) {
yield();
while(strip.isUpdating() && (millis() - t_wait < 96)) delay(1);
yield(); // might help
}
#endif
#endif
#else
bool oldLock = suspendStripService; // fix build f***u* on 8266