Send segment ID, start, stop, and cct
This commit is contained in:
parent
d28eb6ae21
commit
5f0b102671
@ -82,8 +82,8 @@ UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required
|
||||
<td><input type="checkbox" id="R8" name="R8"></td>
|
||||
</tr>
|
||||
</table><br>
|
||||
Receive: <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">Effects<br>
|
||||
<input type="checkbox" name="SO">Segment options<br>
|
||||
Receive: <input type="checkbox" name="RB"> Brightness, <input type="checkbox" name="RC"> Color, and <input type="checkbox" name="RX"> Effects<br>
|
||||
<input type="checkbox" name="SO"> Segment options<br>
|
||||
Send notifications on direct change: <input type="checkbox" name="SD"><br>
|
||||
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
|
||||
Send Alexa notifications: <input type="checkbox" name="SA"><br>
|
||||
|
@ -725,9 +725,6 @@ void serializePalettes(JsonObject root, AsyncWebServerRequest* request)
|
||||
|
||||
for (int i = start; i < end; i++) {
|
||||
JsonArray curPalette = palettes.createNestedArray(String(i));
|
||||
CRGB prim;
|
||||
CRGB sec;
|
||||
CRGB ter;
|
||||
switch (i) {
|
||||
case 0: //default palette
|
||||
setPaletteColors(curPalette, PartyColors_p);
|
||||
|
@ -129,8 +129,8 @@ void colorUpdated(int callMode)
|
||||
|
||||
void updateInterfaces(uint8_t callMode)
|
||||
{
|
||||
lastInterfaceUpdate = millis();
|
||||
sendDataWs();
|
||||
lastInterfaceUpdate = millis();
|
||||
if (callMode == CALL_MODE_WS_SEND) return;
|
||||
|
||||
#ifndef WLED_DISABLE_ALEXA
|
||||
|
113
wled00/udp.cpp
113
wled00/udp.cpp
@ -4,7 +4,7 @@
|
||||
* UDP sync notifier / Realtime / Hyperion / TPM2.NET
|
||||
*/
|
||||
|
||||
#define UDP_SEG_SIZE 22
|
||||
#define UDP_SEG_SIZE 28
|
||||
#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
|
||||
@ -92,28 +92,34 @@ void notify(byte callMode, bool followUp)
|
||||
for (uint8_t i = 0; i < strip.getMaxSegments(); i++) {
|
||||
WS2812FX::Segment &selseg = strip.getSegment(i);
|
||||
uint16_t ofs = 41 + i*UDP_SEG_SIZE; //start of segment offset byte
|
||||
udpOut[0 +ofs] = selseg.grouping;
|
||||
udpOut[1 +ofs] = selseg.spacing;
|
||||
udpOut[2 +ofs] = selseg.offset >> 8;
|
||||
udpOut[3 +ofs] = selseg.offset & 0xFF;
|
||||
udpOut[4 +ofs] = selseg.options & 0x0F; //only take into account mirrored, selected, on, reversed
|
||||
udpOut[5 +ofs] = selseg.opacity;
|
||||
udpOut[6 +ofs] = selseg.mode;
|
||||
udpOut[7 +ofs] = selseg.speed;
|
||||
udpOut[8 +ofs] = selseg.intensity;
|
||||
udpOut[9 +ofs] = selseg.palette;
|
||||
udpOut[10+ofs] = R(selseg.colors[0]);
|
||||
udpOut[11+ofs] = G(selseg.colors[0]);
|
||||
udpOut[12+ofs] = B(selseg.colors[0]);
|
||||
udpOut[13+ofs] = W(selseg.colors[0]);
|
||||
udpOut[14+ofs] = R(selseg.colors[1]);
|
||||
udpOut[15+ofs] = G(selseg.colors[1]);
|
||||
udpOut[16+ofs] = B(selseg.colors[1]);
|
||||
udpOut[17+ofs] = W(selseg.colors[1]);
|
||||
udpOut[18+ofs] = R(selseg.colors[2]);
|
||||
udpOut[19+ofs] = G(selseg.colors[2]);
|
||||
udpOut[20+ofs] = B(selseg.colors[2]);
|
||||
udpOut[21+ofs] = W(selseg.colors[2]);
|
||||
udpOut[0 +ofs] = i;
|
||||
udpOut[1 +ofs] = selseg.start >> 8;
|
||||
udpOut[2 +ofs] = selseg.start & 0xFF;
|
||||
udpOut[3 +ofs] = selseg.stop >> 8;
|
||||
udpOut[4 +ofs] = selseg.stop & 0xFF;
|
||||
udpOut[5 +ofs] = selseg.grouping;
|
||||
udpOut[6 +ofs] = selseg.spacing;
|
||||
udpOut[7 +ofs] = selseg.offset >> 8;
|
||||
udpOut[8 +ofs] = selseg.offset & 0xFF;
|
||||
udpOut[9 +ofs] = selseg.options & 0x0F; //only take into account mirrored, selected, on, reversed
|
||||
udpOut[10+ofs] = selseg.opacity;
|
||||
udpOut[11+ofs] = selseg.mode;
|
||||
udpOut[12+ofs] = selseg.speed;
|
||||
udpOut[13+ofs] = selseg.intensity;
|
||||
udpOut[14+ofs] = selseg.palette;
|
||||
udpOut[15+ofs] = R(selseg.colors[0]);
|
||||
udpOut[16+ofs] = G(selseg.colors[0]);
|
||||
udpOut[17+ofs] = B(selseg.colors[0]);
|
||||
udpOut[18+ofs] = W(selseg.colors[0]);
|
||||
udpOut[19+ofs] = R(selseg.colors[1]);
|
||||
udpOut[20+ofs] = G(selseg.colors[1]);
|
||||
udpOut[21+ofs] = B(selseg.colors[1]);
|
||||
udpOut[22+ofs] = W(selseg.colors[1]);
|
||||
udpOut[23+ofs] = R(selseg.colors[2]);
|
||||
udpOut[24+ofs] = G(selseg.colors[2]);
|
||||
udpOut[25+ofs] = B(selseg.colors[2]);
|
||||
udpOut[26+ofs] = W(selseg.colors[2]);
|
||||
udpOut[27+ofs] = selseg.cct;
|
||||
}
|
||||
|
||||
//uint16_t offs = SEG_OFFSET;
|
||||
@ -281,28 +287,23 @@ void handleNotifications()
|
||||
} else if (!(receiveGroups & udpIn[36])) return;
|
||||
|
||||
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||
//apply colors from notification
|
||||
if (receiveNotificationColor || !someSel) {
|
||||
if (version < 11 || !receiveSegmentOptions) {
|
||||
// only change col[] if not syncing full segments
|
||||
|
||||
//apply colors from notification to main segment, only if not syncing full segments
|
||||
if ((receiveNotificationColor || !someSel) && (version < 11 || !receiveSegmentOptions)) {
|
||||
col[0] = udpIn[3];
|
||||
col[1] = udpIn[4];
|
||||
col[2] = udpIn[5];
|
||||
}
|
||||
if (version > 0) //sending module's white val is intended
|
||||
{
|
||||
// only change col[3] if not syncing full segments
|
||||
if (version < 11 || !receiveSegmentOptions) col[3] = udpIn[10];
|
||||
if (version > 1 && (version < 11 || !receiveSegmentOptions)) {
|
||||
// only change colSec[] if not syncing full segments
|
||||
col[3] = udpIn[10];
|
||||
if (version > 1) {
|
||||
colSec[0] = udpIn[12];
|
||||
colSec[1] = udpIn[13];
|
||||
colSec[2] = udpIn[14];
|
||||
colSec[3] = udpIn[15];
|
||||
}
|
||||
if (version > 6 && (version < 11 || !receiveSegmentOptions)) {
|
||||
if (version > 6) {
|
||||
strip.setColor(2, RGBW32(udpIn[20], udpIn[21], udpIn[22], udpIn[23])); //tertiary color
|
||||
}
|
||||
if (version > 9 && version < 200 && udpIn[37] < 255) { //valid CCT/Kelvin value
|
||||
uint8_t cct = udpIn[38];
|
||||
if (udpIn[37] > 0) { //Kelvin
|
||||
@ -313,41 +314,51 @@ void handleNotifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool timebaseUpdated = false;
|
||||
//apply effects from notification
|
||||
if (version < 200 && (receiveNotificationEffects || !someSel))
|
||||
bool applyEffects = (receiveNotificationEffects || !someSel);
|
||||
if (version < 200)
|
||||
{
|
||||
if (currentPlaylist>=0) unloadPlaylist();
|
||||
if (applyEffects && currentPlaylist >= 0) unloadPlaylist();
|
||||
if (version > 10 && receiveSegmentOptions) {
|
||||
//does not sync start & stop
|
||||
uint8_t srcSegs = udpIn[39];
|
||||
if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments();
|
||||
//if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments();
|
||||
for (uint8_t i = 0; i < srcSegs; i++) {
|
||||
WS2812FX::Segment& selseg = strip.getSegment(i);
|
||||
uint16_t ofs = 41 + i*UDP_SEG_SIZE; //start of segment offset byte
|
||||
for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[4 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed
|
||||
selseg.setOpacity( udpIn[5+ofs], i);
|
||||
strip.setMode(i, udpIn[6+ofs]);
|
||||
selseg.speed = udpIn[7+ofs];
|
||||
selseg.intensity = udpIn[8+ofs];
|
||||
selseg.palette = udpIn[9+ofs];
|
||||
selseg.setColor(0, RGBW32(udpIn[10+ofs],udpIn[11+ofs],udpIn[12+ofs],udpIn[13+ofs]), i);
|
||||
selseg.setColor(1, RGBW32(udpIn[14+ofs],udpIn[15+ofs],udpIn[16+ofs],udpIn[17+ofs]), i);
|
||||
selseg.setColor(2, RGBW32(udpIn[18+ofs],udpIn[19+ofs],udpIn[20+ofs],udpIn[21+ofs]), i);
|
||||
strip.setSegment(i, selseg.start, selseg.stop, udpIn[0+ofs], udpIn[1+ofs], (udpIn[2+ofs]<<8 | udpIn[3+ofs])); //also properly resets segments
|
||||
uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte
|
||||
uint8_t id = udpIn[0 +ofs];
|
||||
if (id > strip.getMaxSegments()) continue;
|
||||
WS2812FX::Segment& selseg = strip.getSegment(id);
|
||||
//bytes 1+2 contain start, 3+4 stop, unused at this time
|
||||
for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[9 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed
|
||||
selseg.setOpacity(udpIn[10+ofs], id);
|
||||
if (applyEffects) {
|
||||
strip.setMode(id, udpIn[11+ofs]);
|
||||
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]), id);
|
||||
selseg.setColor(1, RGBW32(udpIn[19+ofs],udpIn[20+ofs],udpIn[21+ofs],udpIn[22+ofs]), id);
|
||||
selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]), id);
|
||||
selseg.setCCT(udpIn[27+ofs], id);
|
||||
}
|
||||
strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], (udpIn[7+ofs]<<8 | udpIn[8+ofs])); //also properly resets segments
|
||||
}
|
||||
setValuesFromMainSeg();
|
||||
effectChanged = true;
|
||||
colorChanged = true;
|
||||
} else { //simple effect sync, applies to all selected
|
||||
} else if (applyEffects) { //simple effect sync, applies to all selected
|
||||
if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8];
|
||||
effectSpeed = udpIn[9];
|
||||
if (version > 2) effectIntensity = udpIn[16];
|
||||
if (version > 4 && udpIn[19] < strip.getPaletteCount()) effectPalette = udpIn[19];
|
||||
}
|
||||
|
||||
if (version > 5) {
|
||||
if (applyEffects && version > 5) {
|
||||
uint32_t t = (udpIn[25] << 24) | (udpIn[26] << 16) | (udpIn[27] << 8) | (udpIn[28]);
|
||||
t += PRESUMED_NETWORK_DELAY; //adjust trivially for network delay
|
||||
t -= millis();
|
||||
|
Loading…
Reference in New Issue
Block a user