Added UDP sync groups.

This commit is contained in:
Blaz Kristan 2021-08-21 12:22:26 +02:00
parent ff8145b745
commit 9609b48f2f
8 changed files with 875 additions and 799 deletions

View File

@ -237,6 +237,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[F("groups")]);
//! following line might be a problem if called after boot
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
@ -249,6 +250,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[F("groups")]);
JsonObject if_nodes = interfaces["nodes"];
CJSON(nodeListEnabled, if_nodes[F("list")]);
@ -589,6 +591,7 @@ void serializeConfig() {
if_sync_recv["bri"] = receiveNotificationBrightness;
if_sync_recv["col"] = receiveNotificationColor;
if_sync_recv["fx"] = receiveNotificationEffects;
if_sync_recv[F("groups")] = receiveGroups;
JsonObject if_sync_send = if_sync.createNestedObject("send");
if_sync_send[F("dir")] = notifyDirect;
@ -597,6 +600,7 @@ void serializeConfig() {
if_sync_send["hue"] = notifyHue;
if_sync_send["macro"] = notifyMacro;
if_sync_send[F("twice")] = notifyTwice;
if_sync_send[F("groups")] = syncGroups;
JsonObject if_nodes = interfaces.createNestedObject("nodes");
if_nodes[F("list")] = nodeListEnabled;

View File

@ -17,7 +17,42 @@ function GetV(){var d=document;}
<h2>Sync setup</h2>
<h3>WLED Broadcast</h3>
UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required><br>
2nd Port: <input name="U2" type="number" min="1" max="65535" class="d5" required><br>
2nd Port: <input name="U2" type="number" min="1" max="65535" class="d5" required><br><br>
<table style="margin: 0 auto;">
<tr>
<td>Sync groups</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>Send:</td>
<td><input type="checkbox" id="G1" name="G1"></td>
<td><input type="checkbox" id="G2" name="G2"></td>
<td><input type="checkbox" id="G3" name="G3"></td>
<td><input type="checkbox" id="G4" name="G4"></td>
<td><input type="checkbox" id="G5" name="G5"></td>
<td><input type="checkbox" id="G6" name="G6"></td>
<td><input type="checkbox" id="G7" name="G7"></td>
<td><input type="checkbox" id="G8" name="G8"></td>
</tr>
<tr>
<td>Receive:</td>
<td><input type="checkbox" id="R1" name="R1"></td>
<td><input type="checkbox" id="R2" name="R2"></td>
<td><input type="checkbox" id="R3" name="R3"></td>
<td><input type="checkbox" id="R4" name="R4"></td>
<td><input type="checkbox" id="R5" name="R5"></td>
<td><input type="checkbox" id="R6" name="R6"></td>
<td><input type="checkbox" id="R7" name="R7"></td>
<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>
Send notifications on direct change: <input type="checkbox" name="SD"><br>
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>

View File

@ -244,13 +244,26 @@ onclick="H()">?</button></div><button type="button" onclick="B()">Back</button>
<button type="submit">Save</button><hr><h2>Sync setup</h2><h3>WLED Broadcast
</h3>UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5"
required><br>2nd Port: <input name="U2" type="number" min="1" max="65535"
class="d5" required><br>Receive: <input type="checkbox" name="RB">Brightness,
<input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">
Effects<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>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br>
class="d5" required><br><br><table style="margin:0 auto"><tr><td>Sync groups
</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8
</td></tr><tr><td>Send:</td><td><input type="checkbox" id="G1" name="G1"></td>
<td><input type="checkbox" id="G2" name="G2"></td><td><input type="checkbox"
id="G3" name="G3"></td><td><input type="checkbox" id="G4" name="G4"></td><td>
<input type="checkbox" id="G5" name="G5"></td><td><input type="checkbox"
id="G6" name="G6"></td><td><input type="checkbox" id="G7" name="G7"></td><td>
<input type="checkbox" id="G8" name="G8"></td></tr><tr><td>Receive:</td><td>
<input type="checkbox" id="R1" name="R1"></td><td><input type="checkbox"
id="R2" name="R2"></td><td><input type="checkbox" id="R3" name="R3"></td><td>
<input type="checkbox" id="R4" name="R4"></td><td><input type="checkbox"
id="R5" name="R5"></td><td><input type="checkbox" id="R6" name="R6"></td><td>
<input type="checkbox" id="R7" name="R7"></td><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>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>Send Philips Hue change notifications: <input type="checkbox"
name="SH"><br>Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br><i>
Reboot required to apply changes.</i><h3>Instance List</h3>
Enable instance list: <input type="checkbox" name="NL"><br>

File diff suppressed because it is too large Load Diff

View File

@ -202,6 +202,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)<<i;
k[0] = 'R'; receiveGroups |= request->hasArg(k)<<i;
}
receiveNotificationBrightness = request->hasArg(F("RB"));
receiveNotificationColor = request->hasArg(F("RC"));
receiveNotificationEffects = request->hasArg(F("RX"));

View File

@ -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());
@ -219,6 +223,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

View File

@ -298,6 +298,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

View File

@ -397,6 +397,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);