Skip to content

Commit 51acd49

Browse files
authored
Merge pull request wled#1383 from sunbowch/master
mutiple RGBW leds support for DMX control
2 parents 3ba708b + 88e0da7 commit 51acd49

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

wled00/const.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#define DMX_MODE_EFFECT 3 //trigger standalone effects of WLED (11 channels)
7272
#define DMX_MODE_MULTIPLE_RGB 4 //every LED is addressed with its own RGB (ledCount * 3 channels)
7373
#define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels)
74+
#define DMX_MODE_MULTIPLE_RGBW 6 //every LED is addressed with its own RGBW (ledCount * 4 channels)
7475

7576
//Light capability byte (unused) 0bRRCCTTTT
7677
//bits 0/1/2/3: specifies a type of LED driver. A single "driver" may have different chip models but must have the same protocol/behavior

wled00/data/settings_sync.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ <h3>Realtime</h3>
6464
<option value=3>Effect</option>
6565
<option value=4>Multi RGB</option>
6666
<option value=5>Dimmer + Multi RGB</option>
67+
<option value=6>Multi RGBW</option>
6768
</select><br>
6869
<a href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">E1.31 info</a><br>
6970
Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br>

wled00/e131.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "wled.h"
22

3-
#define MAX_LEDS_PER_UNIVERSE 170
3+
#define MAX_3_CH_LEDS_PER_UNIVERSE 170
4+
#define MAX_4_CH_LEDS_PER_UNIVERSE 128
45
#define MAX_CHANNELS_PER_UNIVERSE 512
56

67
/*
@@ -161,8 +162,12 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
161162

162163
case DMX_MODE_MULTIPLE_DRGB:
163164
case DMX_MODE_MULTIPLE_RGB:
165+
case DMX_MODE_MULTIPLE_RGBW:
164166
{
165167
realtimeLock(realtimeTimeoutMs, mde);
168+
bool is4Chan = (DMXMode == DMX_MODE_MULTIPLE_RGBW);
169+
const uint16_t dmxChannelsPerLed = is4Chan ? 4 : 3;
170+
const uint16_t ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
166171
if (realtimeOverride) return;
167172
uint16_t previousLeds, dmxOffset;
168173
if (previousUniverses == 0) {
@@ -176,12 +181,18 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
176181
} else {
177182
// All subsequent universes start at the first channel.
178183
dmxOffset = (protocol == P_ARTNET) ? 0 : 1;
179-
uint16_t ledsInFirstUniverse = (MAX_CHANNELS_PER_UNIVERSE - DMXAddress) / 3;
180-
previousLeds = ledsInFirstUniverse + (previousUniverses - 1) * MAX_LEDS_PER_UNIVERSE;
184+
uint16_t ledsInFirstUniverse = (MAX_CHANNELS_PER_UNIVERSE - DMXAddress) / dmxChannelsPerLed;
185+
previousLeds = ledsInFirstUniverse + (previousUniverses - 1) * ledsPerUniverse;
181186
}
182-
uint16_t ledsTotal = previousLeds + (dmxChannels - dmxOffset +1) / 3;
183-
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
184-
setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], 0);
187+
uint16_t ledsTotal = previousLeds + (dmxChannels - dmxOffset +1) / dmxChannelsPerLed;
188+
if (!is4Chan) {
189+
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
190+
setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], 0);
191+
}
192+
} else {
193+
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
194+
setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++]);
195+
}
185196
}
186197
break;
187198
}

wled00/html_settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ type="checkbox" name="ES"><br>DMX start address: <input name="DA" type="number"
238238
min="0" max="510" required><br>DMX mode: <select name="DM"><option value="0">
239239
Disabled</option><option value="1">Single RGB</option><option value="2">
240240
Single DRGB</option><option value="3">Effect</option><option value="4">Multi RGB
241-
</option><option value="5">Dimmer + Multi RGB</option></select><br><a
241+
</option><option value="5">Dimmer + Multi RGB</option><option value="6">
242+
Multi RGBW</option></select><br><a
242243
href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">
243244
E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000"
244245
required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br>

wled00/set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
152152
t = request->arg(F("DA")).toInt();
153153
if (t >= 0 && t <= 510) DMXAddress = t;
154154
t = request->arg(F("DM")).toInt();
155-
if (t >= DMX_MODE_DISABLED && t <= DMX_MODE_MULTIPLE_DRGB) DMXMode = t;
155+
if (t >= DMX_MODE_DISABLED && t <= DMX_MODE_MULTIPLE_RGBW) DMXMode = t;
156156
t = request->arg(F("ET")).toInt();
157157
if (t > 99 && t <= 65000) realtimeTimeoutMs = t;
158158
arlsForceMaxBri = request->hasArg(F("FB"));

0 commit comments

Comments
 (0)