From 1808fa776b8cf899849f21b672633294174a8b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Sun, 29 Jun 2025 22:42:33 +0200 Subject: [PATCH] Prevent parallel I2S use if different LED types are used. - helps with #4315 - add-on to #4762 - increases parallel I2S LED limit to 600 per bus --- wled00/FX_fcn.cpp | 12 +++++++--- wled00/data/settings_leds.htm | 42 ++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 6fc49cb27..027c6aaa1 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1203,21 +1203,27 @@ void WS2812FX::finalizeInit() { #if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) // determine if it is sensible to use parallel I2S outputs on ESP32 (i.e. more than 5 outputs = 1 I2S + 4 RMT) unsigned maxLedsOnBus = 0; + unsigned busType = 0; for (const auto &bus : busConfigs) { if (Bus::isDigital(bus.type) && !Bus::is2Pin(bus.type)) { digitalCount++; + if (busType == 0) busType = bus.type; // remember first bus type + if (busType != bus.type) { + DEBUG_PRINTF_P(PSTR("Mixed digital bus types detected! Forcing single I2S output.\n")); + useParallelI2S = false; // mixed bus types, no parallel I2S + } if (bus.count > maxLedsOnBus) maxLedsOnBus = bus.count; } } DEBUG_PRINTF_P(PSTR("Maximum LEDs on a bus: %u\nDigital buses: %u\n"), maxLedsOnBus, digitalCount); - // we may remove 300 LEDs per bus limit when NeoPixelBus is updated beyond 2.9.0 - if (maxLedsOnBus <= 300 && useParallelI2S) BusManager::useParallelOutput(); // must call before creating buses + // we may remove 600 LEDs per bus limit when NeoPixelBus is updated beyond 2.8.3 + if (maxLedsOnBus <= 600 && useParallelI2S) BusManager::useParallelOutput(); // must call before creating buses else useParallelI2S = false; // enforce single I2S + digitalCount = 0; #endif // create buses/outputs unsigned mem = 0; - digitalCount = 0; for (const auto &bus : busConfigs) { mem += bus.memUsage(Bus::isDigital(bus.type) && !Bus::is2Pin(bus.type) ? digitalCount++ : 0); // includes global buffer if (mem <= MAX_LED_MEMORY) { diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 6c6811c2d..a418590a8 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -6,8 +6,7 @@ LED Settings