mutiple RGBW leds support for DMX control

RGBW leds can be individually adressed through E1.31 control.
-Added option 'Multi RGBW' to the settings
-Modified e131.cpp accordingly
-Tuned other parameters to make it work
This commit is contained in:
sunbowch 2020-11-27 11:37:39 +01:00
parent ac010cd7b2
commit 3d89588eb1
5 changed files with 26 additions and 2 deletions

View File

@ -71,6 +71,7 @@
#define DMX_MODE_EFFECT 3 //trigger standalone effects of WLED (11 channels)
#define DMX_MODE_MULTIPLE_RGB 4 //every LED is addressed with its own RGB (ledCount * 3 channels)
#define DMX_MODE_MULTIPLE_DRGB 5 //every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels)
#define DMX_MODE_MULTIPLE_RGBW 6 //every LED is addressed with its own RGBW (ledCount * 4 channels)
//Light capability byte (unused) 0bRRCCTTTT
//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

View File

@ -64,6 +64,7 @@ DMX mode:
<option value=3>Effect</option>
<option value=4>Multi RGB</option>
<option value=5>Dimmer + Multi RGB</option>
<option value=6>Multi RGBW</option>
</select><br>
<a href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">E1.31 info</a><br>
Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br>

View File

@ -185,6 +185,28 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
}
break;
}
case DMX_MODE_MULTIPLE_RGBW: //Implementation of RGBW leds
{
const byte dmxChannelsperLed=4; //4 DMX Channels/Led
const byte ledsPerUniverse=128; //Max.128 leds/Universe
realtimeLock(realtimeTimeoutMs, mde);
if (realtimeOverride) return;
uint16_t previousLeds, dmxOffset;
if (previousUniverses == 0) {
if (dmxChannels-DMXAddress < 1) return;
dmxOffset = DMXAddress;
previousLeds = 0;
} else{
dmxOffset = (protocol == P_ARTNET) ? 0 : 1;
uint16_t ledsInFirstUniverse = (MAX_CHANNELS_PER_UNIVERSE - DMXAddress) / dmxChannelsperLed;
previousLeds = ledsInFirstUniverse + (previousUniverses - 1) * ledsPerUniverse; // Max leds/universe is only 128 with 4 Ch./led
}
uint16_t ledsTotal = previousLeds + (dmxChannels - dmxOffset +1) / dmxChannelsperLed;
for (uint16_t i = previousLeds; i < ledsTotal; i++) {
setRealtimePixel(i, e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++], e131_data[dmxOffset++]);
}
break;
}
default:
DEBUG_PRINTLN(F("unknown E1.31 DMX mode"));
return; // nothing to do

View File

@ -152,7 +152,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
t = request->arg(F("DA")).toInt();
if (t >= 0 && t <= 510) DMXAddress = t;
t = request->arg(F("DM")).toInt();
if (t >= DMX_MODE_DISABLED && t <= DMX_MODE_MULTIPLE_DRGB) DMXMode = t;
if (t >= DMX_MODE_DISABLED && t <= DMX_MODE_MULTIPLE_RGBW) DMXMode = t;
t = request->arg(F("ET")).toInt();
if (t > 99 && t <= 65000) realtimeTimeoutMs = t;
arlsForceMaxBri = request->hasArg(F("FB"));

View File

@ -262,7 +262,7 @@ WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this
#endif
WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes)
WLED_GLOBAL uint16_t e131Port _INIT(5568); // DMX in port. E1.31 default is 5568, Art-Net is 6454
WLED_GLOBAL byte DMXMode _INIT(DMX_MODE_MULTIPLE_RGB); // DMX mode (s.a.)
WLED_GLOBAL byte DMXMode _INIT(DMX_MODE_MULTIPLE_RGBW-1); // DMX mode (s.a.)
WLED_GLOBAL uint16_t DMXAddress _INIT(1); // DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol]
WLED_GLOBAL byte DMXOldDimmer _INIT(0); // only update brightness on change
WLED_GLOBAL byte e131LastSequenceNumber[E131_MAX_UNIVERSE_COUNT]; // to detect packet loss