diff --git a/wled00/e131.cpp b/wled00/e131.cpp index 68c7ca5a..12acc2c9 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -142,32 +142,33 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){ return; // nothing to do break; - case DMX_MODE_SINGLE_RGB: // 3 channel: [R,G,B] + case DMX_MODE_SINGLE_RGB: // 3-4 channels: [R,G,B] + W (if present) if (uni != e131Universe) return; - if (availDMXLen < 3) return; + const uint16_t dmxChannelCount = strip.hasWhiteChannel() ? 4 : 3; + if (availDMXLen < dmxChannelCount) return; realtimeLock(realtimeTimeoutMs, mde); - if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return; - wChannel = (availDMXLen > 3) ? e131_data[dataOffset+3] : 0; + 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); break; - case DMX_MODE_SINGLE_DRGB: // 4 channel: [Dimmer,R,G,B] + case DMX_MODE_SINGLE_DRGB: // 4-5 channels: [Dimmer,R,G,B] + W (if present) if (uni != e131Universe) return; - if (availDMXLen < 4) return; + const uint16_t dmxChannelCount = strip.hasWhiteChannel() ? 5 : 4; + if (availDMXLen < dmxChannelCount) return; realtimeLock(realtimeTimeoutMs, mde); if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return; - wChannel = (availDMXLen > 4) ? e131_data[dataOffset+4] : 0; if (bri != e131_data[dataOffset+0]) { bri = e131_data[dataOffset+0]; strip.setBrightness(bri, true); } + wChannel = dmxChannelCount == 5 ? e131_data[dataOffset+4] : 0; for (uint16_t i = 0; i < totalLen; i++) setRealtimePixel(i, e131_data[dataOffset+1], e131_data[dataOffset+2], e131_data[dataOffset+3], wChannel); break;