diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index e4959637b..215c3795d 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -267,6 +267,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(receiveNotificationBrightness, if_sync_recv["bri"]); CJSON(receiveNotificationColor, if_sync_recv["col"]); CJSON(receiveNotificationEffects, if_sync_recv["fx"]); + CJSON(receiveGroups, if_sync_recv["grp"]); //! following line might be a problem if called after boot receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); @@ -279,6 +280,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(notifyHue, if_sync_send["hue"]); CJSON(notifyMacro, if_sync_send["macro"]); CJSON(notifyTwice, if_sync_send[F("twice")]); + CJSON(syncGroups, if_sync_send["grp"]); JsonObject if_nodes = interfaces["nodes"]; CJSON(nodeListEnabled, if_nodes[F("list")]); @@ -639,6 +641,7 @@ void serializeConfig() { if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["col"] = receiveNotificationColor; if_sync_recv["fx"] = receiveNotificationEffects; + if_sync_recv["grp"] = receiveGroups; JsonObject if_sync_send = if_sync.createNestedObject("send"); if_sync_send[F("dir")] = notifyDirect; @@ -647,6 +650,7 @@ void serializeConfig() { if_sync_send["hue"] = notifyHue; if_sync_send["macro"] = notifyMacro; if_sync_send[F("twice")] = notifyTwice; + if_sync_send["grp"] = syncGroups; JsonObject if_nodes = interfaces.createNestedObject("nodes"); if_nodes[F("list")] = nodeListEnabled; diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 0f5c513f5..8dff78dc2 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -20,7 +20,42 @@ function GetV(){var d=document;}

Sync setup

WLED Broadcast

UDP Port:
-2nd Port:
+2nd Port:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sync groups12345678
Send:
Receive:

Receive: Brightness, Color, and Effects
Send notifications on direct change:
Send notifications on button press or IR:
diff --git a/wled00/html_settings.h b/wled00/html_settings.h index c3fdc3708..472c7a146 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -245,10 +245,23 @@ class="helpB">

Sync setup

WLED Broadcast

UDP Port:
2nd Port:
Receive: -Brightness, -Color, and Effects
-Send notifications on direct change:
+name="U2" type="number" min="1" max="65535" class="d5" required>

Sync groups123 +45678
Send:
Receive:
+
Receive: Brightness, Color, and Effects +
Send notifications on direct change:
Send notifications on button press or IR:
Send Alexa notifications:
Send Philips Hue change notifications:
diff --git a/wled00/json.cpp b/wled00/json.cpp index b67ce2deb..00158c85f 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -45,7 +45,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId) uint16_t len = elem[F("len")]; stop = (len > 0) ? start + len : seg.stop; } - uint16_t grp = elem[F("grp")] | seg.grouping; + uint16_t grp = elem["grp"] | seg.grouping; uint16_t spc = elem[F("spc")] | seg.spacing; strip.setSegment(id, start, stop, grp, spc); @@ -368,7 +368,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo root["stop"] = seg.stop; } if (!forPreset) root[F("len")] = seg.stop - seg.start; - root[F("grp")] = seg.grouping; + root["grp"] = seg.grouping; root[F("spc")] = seg.spacing; root[F("of")] = seg.offset; root["on"] = seg.getOption(SEG_OPTION_ON); diff --git a/wled00/set.cpp b/wled00/set.cpp index 48ceaf90c..1dbd1a4fd 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -208,6 +208,15 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) if (t > 0) udpPort = t; t = request->arg(F("U2")).toInt(); if (t > 0) udpPort2 = t; + + char k[3]; k[2] = 0; + syncGroups = receiveGroups = 0; + for (uint8_t i=0; i<8; i++) { + k[1] = 49+i; // char '1','2',... + k[0] = 'G'; syncGroups |= request->hasArg(k)<hasArg(k)<hasArg(F("RB")); receiveNotificationColor = request->hasArg(F("RC")); receiveNotificationEffects = request->hasArg(F("RX")); diff --git a/wled00/udp.cpp b/wled00/udp.cpp index 7d2199d2f..aa565c46d 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -4,7 +4,7 @@ * UDP sync notifier / Realtime / Hyperion / TPM2.NET */ -#define WLEDPACKETSIZE 36 +#define WLEDPACKETSIZE 37 #define UDP_IN_MAXSIZE 1472 #define PRESUMED_NETWORK_DELAY 3 //how many ms could it take on avg to reach the receiver? This will be added to transmitted times @@ -39,7 +39,8 @@ void notify(byte callMode, bool followUp) //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 - udpOut[11] = 8; + //9: supports sync groups, 37 byte packet + udpOut[11] = 9; udpOut[12] = colSec[0]; udpOut[13] = colSec[1]; udpOut[14] = colSec[2]; @@ -72,6 +73,9 @@ void notify(byte callMode, bool followUp) uint16_t ms = tm.ms; udpOut[34] = (ms >> 8) & 0xFF; udpOut[35] = (ms >> 0) & 0xFF; + + //sync groups + udpOut[36] = syncGroups & 0xFF; IPAddress broadcastIp; broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP()); @@ -223,6 +227,9 @@ void handleNotifications() //compatibilityVersionByte: byte version = udpIn[11]; + + // if we are not part of any sync group ignore message + if (version > 8 && !(receiveGroups & udpIn[36])) return; bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); //apply colors from notification diff --git a/wled00/wled.h b/wled00/wled.h index 1cbadd452..95ed83200 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2108201 +#define VERSION 2108211 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -301,6 +301,8 @@ WLED_GLOBAL bool liveHSVCorrection _INIT(false); WLED_GLOBAL uint16_t liveHSVSaturation _INIT(13); WLED_GLOBAL uint16_t liveHSVValue _INIT(10); +WLED_GLOBAL uint8_t syncGroups _INIT(0xFF); // sync groups this instance syncs (bit mapped) +WLED_GLOBAL uint8_t receiveGroups _INIT(0xFF); // sync receive groups this instance belongs to (bit mapped) WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup diff --git a/wled00/xml.cpp b/wled00/xml.cpp index bd2d8463a..c6273c156 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -430,6 +430,13 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',SET_F("UP"),udpPort); sappend('v',SET_F("U2"),udpPort2); + char k[3]; k[2] = 0; + for (int i = 0; i<8; i++) + { + k[1] = 49+i; //ascii 1,2,3,... + k[0] = 'G'; sappend('c',k,(syncGroups>>i)&0x01); + k[0] = 'R'; sappend('c',k,(receiveGroups>>i)&0x01); + } sappend('c',SET_F("HX"),liveHSVCorrection); sappend('v',SET_F("HS"),liveHSVSaturation); sappend('v',SET_F("HV"),liveHSVValue);