From 0fb07b9d07dd3c6b9cfe06f7f0932b6a9eda1d3e Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 15 Jan 2026 12:39:26 +0100 Subject: [PATCH] (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 --- wled00/dmx_output.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wled00/dmx_output.cpp b/wled00/dmx_output.cpp index b3f2eadd..6caa3ec8 100644 --- a/wled00/dmx_output.cpp +++ b/wled00/dmx_output.cpp @@ -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