Skip to content

Commit 3ef8d93

Browse files
committed
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!
1 parent 40bfe61 commit 3ef8d93

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wled00/bus_manager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,11 @@ int BusManager::add(BusConfig &bc) {
12681268
void BusManager::removeAll() {
12691269
DEBUG_PRINTLN(F("Removing all."));
12701270
//prevents crashes due to deleting busses while in use.
1271+
#if !defined(ARDUINO_ARCH_ESP32)
12711272
while (!canAllShow()) yield();
1273+
#else
1274+
while (!canAllShow()) delay(2); // WLEDMM on esp32, yield() doesn't work as you think it would
1275+
#endif
12721276
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
12731277
numBusses = 0;
12741278
// WLEDMM clear cached Bus info
@@ -1279,6 +1283,10 @@ void BusManager::removeAll() {
12791283

12801284
void __attribute__((hot)) BusManager::show() {
12811285
for (unsigned i = 0; i < numBusses; i++) {
1286+
#if 1 && defined(ARDUINO_ARCH_ESP32)
1287+
unsigned long t0 = millis();
1288+
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
1289+
#endif
12821290
busses[i]->show();
12831291
}
12841292
}

0 commit comments

Comments
 (0)