From 3ef8d93bbe5afd50956ad5a3aeb5fca62f963baa Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:50:39 +0100 Subject: [PATCH] another attempt to reduces flickering * BusManager::show(): explicitly wait until the bus driver is idle (done by NPB show, too, but in a different way) * BusManager::removeAll(): use delay() instead of yield() - yield() does _not_ free the processor on esp32! --- wled00/bus_manager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 5dd51d0a..2c87c498 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -1268,7 +1268,11 @@ int BusManager::add(BusConfig &bc) { void BusManager::removeAll() { DEBUG_PRINTLN(F("Removing all.")); //prevents crashes due to deleting busses while in use. +#if !defined(ARDUINO_ARCH_ESP32) while (!canAllShow()) yield(); +#else + while (!canAllShow()) delay(2); // WLEDMM on esp32, yield() doesn't work as you think it would +#endif for (uint8_t i = 0; i < numBusses; i++) delete busses[i]; numBusses = 0; // WLEDMM clear cached Bus info @@ -1279,6 +1283,10 @@ void BusManager::removeAll() { void __attribute__((hot)) BusManager::show() { for (unsigned i = 0; i < numBusses; i++) { +#if 1 && defined(ARDUINO_ARCH_ESP32) + unsigned long t0 = millis(); + while ((busses[i]->canShow() == false) && (millis() - t0 < 80)) delay(1); // WLEDMM experimental: wait until bus driver is ready (max 80ms) - costs us 1-2 fps but reduces flickering +#endif busses[i]->show(); } }