Skip to content

Commit 0fb07b9

Browse files
committed
(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 * wled#5216 * wled#5287
1 parent 1bda6ba commit 0fb07b9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

wled00/dmx_output.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifdef WLED_ENABLE_DMX
1414
#pragma message "DMX network output enabled"
1515

16+
#define MAX_DMX_RATE 44 // max DMX update rate in Hz
17+
1618
// WLEDMM: seems that DMX output triggers watchdog resets when compiling for IDF 4.4.x
1719
#ifdef ARDUINO_ARCH_ESP32
1820
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
@@ -32,8 +34,21 @@ void handleDMXOutput()
3234
// don't act, when in DMX Proxy mode
3335
if (e131ProxyUniverse != 0) return;
3436

37+
// Ensure segments exist before accessing strip data
38+
if (strip.getSegmentsNum() == 0) return;
39+
40+
// Rate limiting
41+
static unsigned long last_dmx_time = 0;
42+
constexpr unsigned long dmxFrameTime = (1000UL + MAX_DMX_RATE - 1) / MAX_DMX_RATE; // Ceiling division to round up
43+
if (millis() - last_dmx_time < dmxFrameTime) return;
44+
3545
uint8_t brightness = strip.getBrightness();
3646

47+
// Skip DMX entirely if strip is off
48+
//if (brightness == 0) return; // WLEDMM not sure about this line - it possibly prevents that the final "black" color gets transmitted
49+
50+
last_dmx_time = millis();
51+
3752
bool calc_brightness = true;
3853

3954
// check if no shutter channel is set

0 commit comments

Comments
 (0)