-
-
Notifications
You must be signed in to change notification settings - Fork 133
change effect IDs from 8bit to 16bit #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mdev
Are you sure you want to change the base?
Changes from 6 commits
5ed7b44
82910a6
894052f
68aad22
e7831a4
8cad7aa
03bb24b
733c798
1bf6be4
ea1b97f
0ecd460
b4e900c
9bedbd2
e0c0bb5
16c05d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,7 +231,7 @@ void handleDMXData(uint16_t uni, uint16_t dmxChannels, uint8_t* e131_data, uint8 | |
| return; | ||
|
|
||
| if (e131_data[dataOffset+1] < strip.getModeCount()) | ||
| if (e131_data[dataOffset+1] != seg.mode) seg.setMode( e131_data[dataOffset+1]); | ||
| if (e131_data[dataOffset+1] != seg.mode) seg.setMode( e131_data[dataOffset+1]); // WLEDMM Only one byte for mode, so DMX cannot control effects with id>255 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo: update for the dual channel approach |
||
| if (e131_data[dataOffset+2] != seg.speed) seg.speed = e131_data[dataOffset+2]; | ||
| if (e131_data[dataOffset+3] != seg.intensity) seg.intensity = e131_data[dataOffset+3]; | ||
| if (e131_data[dataOffset+4] != seg.palette) seg.setPalette(e131_data[dataOffset+4]); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ void notify(byte callMode, bool followUp) | |
| udpOut[5] = B(col); | ||
| udpOut[6] = nightlightActive; | ||
| udpOut[7] = nightlightDelayMins; | ||
| udpOut[8] = mainseg.mode; | ||
| udpOut[8] = byte(mainseg.mode); // WLEDMM toDo: need workaround for 16bit mode numbers | ||
| udpOut[9] = mainseg.speed; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 16-bit sync regression in UDP payload With 🤖 Prompt for AI Agents
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the (very clumsy) workaround for now is to clamp effect ID at 255 or udp. For a real solution, there should be a new version of the UDP dataset. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @softhack007 Agreed. Here’s a minimal, backward-compatible “UDP notifier v13” that carries 16-bit effect IDs via the per-segment payload, while keeping the header’s mode field clamped to 8-bit for legacy peers. This avoids changing the fixed 41-byte header and uses the already variable per-segment block size. Key points
Proposed patch (wled00/udp.cpp) diff --git a/wled00/udp.cpp b/wled00/udp.cpp
index 5f6c9ab..b0c2e33 100644
--- a/wled00/udp.cpp
+++ b/wled00/udp.cpp
@@ -6,7 +6,8 @@
* UDP sync notifier / Realtime / Hyperion / TPM2.NET
*/
-#define UDP_SEG_SIZE 36
+// v13: extend per-segment payload by 2 bytes (mode MSB + reserved)
+#define UDP_SEG_SIZE 38
#define SEG_OFFSET (41+(MAX_NUM_SEGMENTS*UDP_SEG_SIZE))
#define WLEDPACKETSIZE (41+(MAX_NUM_SEGMENTS*UDP_SEG_SIZE)+0)
#define UDP_IN_MAXSIZE 1472
@@ -33,10 +34,10 @@ void notify(byte callMode, bool followUp)
udpOut[4] = G(col);
udpOut[5] = B(col);
udpOut[6] = nightlightActive;
udpOut[7] = nightlightDelayMins;
- udpOut[8] = min(mainseg.mode, uint16_t(255)); // WLEDMM toDo: need workaround for 16bit mode numbers - critical as this affects webUI
+ udpOut[8] = min(mainseg.mode, uint16_t(255)); // v13: header remains 8-bit for legacy peers; 16-bit lives in per-segment payload
udpOut[9] = mainseg.speed;
udpOut[10] = W(col);
//compatibilityVersionByte:
//0: old 1: supports white 2: supports secondary color
//3: supports FX intensity, 24 byte packet 4: supports transitionDelay 5: sup palette
//6: supports timebase syncing, 29 byte packet 7: supports tertiary color 8: supports sys time sync, 36 byte packet
//9: supports sync groups, 37 byte packet 10: supports CCT, 39 byte packet 11: per segment options, variable packet length (40+MAX_NUM_SEGMENTS*3)
- //12: enhanced effect sliders, 2D & mapping options
- udpOut[11] = 12;
+ //12: enhanced effect sliders, 2D & mapping options 13: 16-bit effect ID in per-segment payload
+ udpOut[11] = 13;
col = mainseg.colors[1];
udpOut[12] = R(col);
udpOut[13] = G(col);
@@ -86,6 +87,8 @@ void notify(byte callMode, bool followUp)
udpOut[10+ofs] = selseg.opacity;
- udpOut[11+ofs] = min(selseg.mode, uint16_t(255)); // WLEDMM toDo: need workaround for 16bit mode numbers
+ // Per-segment effect: keep LSB at legacy location for old receivers, add MSB at the tail for v13+
+ udpOut[11+ofs] = min(selseg.mode, uint16_t(255));
udpOut[12+ofs] = selseg.speed;
udpOut[13+ofs] = selseg.intensity;
udpOut[14+ofs] = selseg.palette;
@@ -109,6 +112,10 @@ void notify(byte callMode, bool followUp)
udpOut[34+ofs] = selseg.stopY >> 8;
udpOut[35+ofs] = selseg.stopY & 0xFF;
+ // v13 additions for 16-bit effect IDs
+ udpOut[36+ofs] = (selseg.mode >> 8) & 0xFF; // mode MSB
+ udpOut[37+ofs] = 0; // reserved for future use
++s;
}
@@ -282,12 +289,21 @@ void handleNotifications()
selseg.setOpacity(udpIn[10+ofs]);
if (applyEffects) {
- strip.setMode(id, udpIn[11+ofs]);
+ // Reconstruct 16-bit mode when sender is v13+ and per-segment size >= 38
+ uint16_t rxMode = udpIn[11+ofs];
+ if (version >= 13 && udpIn[40] >= 38) {
+ rxMode |= uint16_t(udpIn[36+ofs]) << 8;
+ }
+ strip.setMode(id, rxMode);
selseg.speed = udpIn[12+ofs];
selseg.intensity = udpIn[13+ofs];
selseg.palette = udpIn[14+ofs];
}
if (receiveNotificationColor || !someSel) {
selseg.setColor(0, RGBW32(udpIn[15+ofs],udpIn[16+ofs],udpIn[17+ofs],udpIn[18+ofs]));
selseg.setColor(1, RGBW32(udpIn[19+ofs],udpIn[20+ofs],udpIn[21+ofs],udpIn[22+ofs]));
selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]));
selseg.setCCT(udpIn[27+ofs]);
}Behavior and compatibility
Limitations
Test plan
Would you like me to open a follow-up issue titled “UDP notifier v13: 16-bit effect IDs in segment payload” and reference this PR/comment so we can track the wider rollout (UI docs, config hint to enable receiveSegmentOptions, etc.)? |
||
| udpOut[10] = W(col); | ||
| //compatibilityVersionByte: | ||
|
|
@@ -107,7 +107,7 @@ void notify(byte callMode, bool followUp) | |
| udpOut[8 +ofs] = selseg.offset & 0xFF; | ||
| udpOut[9 +ofs] = selseg.options & 0x8F; //only take into account selected, mirrored, on, reversed, reverse_y (for 2D); ignore freeze, reset, transitional | ||
| udpOut[10+ofs] = selseg.opacity; | ||
| udpOut[11+ofs] = selseg.mode; | ||
| udpOut[11+ofs] = byte(selseg.mode); // WLEDMM toDo: need workaround for 16bit mode numbers | ||
| udpOut[12+ofs] = selseg.speed; | ||
| udpOut[13+ofs] = selseg.intensity; | ||
| udpOut[14+ofs] = selseg.palette; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.