From de4ff4e58d1644d091c072ae32ca0f8ac4581a49 Mon Sep 17 00:00:00 2001 From: strikeout Date: Thu, 16 Mar 2023 17:56:29 +0100 Subject: [PATCH] Fixes preset and brightness selection via DMX controller to DoS WLED, now same packets are discarded --- wled00/e131.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/wled00/e131.cpp b/wled00/e131.cpp index ababf8d8..5be7472f 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -174,10 +174,20 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ case DMX_MODE_PRESET: // 2 channel: [Dimmer,Preset] if (uni != e131Universe || availDMXLen < 2) return; - applyPreset(e131_data[dataOffset+1], CALL_MODE_NOTIFICATION); - if (bri != e131_data[dataOffset]) { + + // only apply preset if value changed + if (currentPreset != e131_data[dataOffset+1] && e131_data[dataOffset+1] != 0 && + // only apply preset if not in playlist, or playlist changed + (currentPlaylist < 0 || currentPlaylist != e131_data[dataOffset+1])) { + presetCycCurr = e131_data[dataOffset+1]; + unloadPlaylist(); // applying a preset unloads the playlist + applyPreset(e131_data[dataOffset+1], CALL_MODE_NOTIFICATION); + } + // only change brightness if value changed + if (bri != e131_data[dataOffset]) { bri = e131_data[dataOffset]; - strip.setBrightness(bri, true); + strip.setBrightness(scaledBri(bri), false); + stateUpdated(CALL_MODE_WS_SEND); } return; break;