Added support for E1.31 with more than 170 LEDs

This commit is contained in:
cschwinne 2018-11-01 01:05:35 +01:00
parent 042605701e
commit 48c165b0b4
2 changed files with 25 additions and 17 deletions

View File

@ -58,7 +58,7 @@
//version code in format yymmddb (b = daily build)
#define VERSION 1810271
#define VERSION 1810311
char versionString[] = "0.8.1";

View File

@ -76,6 +76,27 @@ void initE131(){
}
}
void handleE131(){
//E1.31 protocol support
if(e131Enabled) {
uint16_t len = e131->parsePacket();
if (!len || e131->universe < e131Universe || e131->universe > e131Universe +4) return;
len /= 3; //one LED is 3 DMX channels
uint16_t multipacketOffset = (e131->universe - e131Universe)*170; //if more than 170 LEDs (510 channels), client will send in next higher universe
if (ledCount <= multipacketOffset) return;
arlsLock(realtimeTimeoutMs);
if (len + multipacketOffset > ledCount) len = ledCount - multipacketOffset;
for (uint16_t i = 0; i < len; i++) {
int j = i * 3;
setRealtimePixel(i + multipacketOffset, e131->data[j], e131->data[j+1], e131->data[j+2], 0);
}
strip.show();
}
}
void handleNotifications()
{
//send second notification if enabled
@ -83,20 +104,7 @@ void handleNotifications()
notify(notificationSentCallMode,true);
}
//E1.31 protocol support
if(e131Enabled) {
uint16_t len = e131->parsePacket();
if (len && e131->universe == e131Universe) {
arlsLock(realtimeTimeoutMs);
if (len > ledCount) len = ledCount;
for (uint16_t i = 0; i < len; i++) {
int j = i * 3;
setRealtimePixel(i, e131->data[j], e131->data[j+1], e131->data[j+2], 0);
}
strip.show();
}
}
handleE131();
//unlock strip when realtime UDP times out
if (realtimeActive && millis() > realtimeTimeout)
@ -227,9 +235,9 @@ void handleNotifications()
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
for (uint16_t i = 4; i < packetSize -2; i += 3)
{
if (id >= ledCount) break;
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
id++; if (id >= ledCount) break;
id++;
}
}
strip.show();