(hotfix) DMX-output rate limiting to prevent watchdog reset

this is a quick workaround for custom builds with WLED_ENABLE_DMX. it adds rate limiting to the dmx-output handler function.

still waiting for a good solution from upstream
* https://github.com/wled/WLED/pull/5216
* https://github.com/wled/WLED/pull/5287
This commit is contained in:
Frank
2026-01-15 12:39:26 +01:00
parent 1bda6ba072
commit 0fb07b9d07

View File

@@ -13,6 +13,8 @@
#ifdef WLED_ENABLE_DMX
#pragma message "DMX network output enabled"
#define MAX_DMX_RATE 44 // max DMX update rate in Hz
// WLEDMM: seems that DMX output triggers watchdog resets when compiling for IDF 4.4.x
#ifdef ARDUINO_ARCH_ESP32
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
@@ -32,8 +34,21 @@ void handleDMXOutput()
// don't act, when in DMX Proxy mode
if (e131ProxyUniverse != 0) return;
// Ensure segments exist before accessing strip data
if (strip.getSegmentsNum() == 0) return;
// Rate limiting
static unsigned long last_dmx_time = 0;
constexpr unsigned long dmxFrameTime = (1000UL + MAX_DMX_RATE - 1) / MAX_DMX_RATE; // Ceiling division to round up
if (millis() - last_dmx_time < dmxFrameTime) return;
uint8_t brightness = strip.getBrightness();
// Skip DMX entirely if strip is off
//if (brightness == 0) return; // WLEDMM not sure about this line - it possibly prevents that the final "black" color gets transmitted
last_dmx_time = millis();
bool calc_brightness = true;
// check if no shutter channel is set