From ababf58deb33908402f38031a1a7d8dc2898c88d Mon Sep 17 00:00:00 2001 From: mxklb Date: Fri, 17 Nov 2023 01:41:23 +0100 Subject: [PATCH] Added missing main segment check --- wled00/e131.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wled00/e131.cpp b/wled00/e131.cpp index 86ef7c8b..40cd49d2 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -120,6 +120,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ // update status info realtimeIP = clientIP; byte wChannel = 0; + uint16_t dmxChannelCount = 0; uint16_t totalLen = strip.getLengthTotal(); uint16_t availDMXLen = 0; uint16_t dataOffset = DMXAddress; @@ -144,13 +145,13 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ case DMX_MODE_SINGLE_RGB: // 3-4 channels: [R,G,B] + W (if present) if (uni != e131Universe) return; - uint16_t dmxChannelCount; - dmxChannelCount = strip.hasWhiteChannel() ? 4 : 3; - if (availDMXLen < dmxChannelCount) return; realtimeLock(realtimeTimeoutMs, mde); if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return; + dmxChannelCount = useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel() ? 4 : 3; + if (availDMXLen < dmxChannelCount) return; + wChannel = dmxChannelCount == 4 ? e131_data[dataOffset+3] : 0; for (uint16_t i = 0; i < totalLen; i++) setRealtimePixel(i, e131_data[dataOffset+0], e131_data[dataOffset+1], e131_data[dataOffset+2], wChannel); @@ -158,11 +159,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ case DMX_MODE_SINGLE_DRGB: // 4-5 channels: [Dimmer,R,G,B] + W (if present) if (uni != e131Universe) return; - dmxChannelCount = strip.hasWhiteChannel() ? 5 : 4; - if (availDMXLen < dmxChannelCount) return; realtimeLock(realtimeTimeoutMs, mde); if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return; + + dmxChannelCount = useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel() ? 5 : 4; + if (availDMXLen < dmxChannelCount) return; if (bri != e131_data[dataOffset+0]) { bri = e131_data[dataOffset+0];