Merge branch 'sync-groups' into dev
This commit is contained in:
commit
60ce5c67de
@ -1,18 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"><head><meta name="viewport" content="width=500"><meta charset="utf-8"><title>Sync Settings</title>
|
||||
<script>var d=document;
|
||||
function gId(s)
|
||||
{
|
||||
return d.getElementById(s);
|
||||
}
|
||||
function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings");}function B(){window.open("/settings","_self");}
|
||||
function adj(){if (d.Sf.DI.value == 6454) {if (d.Sf.DA.value == 1) d.Sf.DA.value = 0; if (d.Sf.EU.value == 1) d.Sf.EU.value = 0;}
|
||||
else if (d.Sf.DI.value == 5568) {if (d.Sf.DA.value == 0) d.Sf.DA.value = 1; if (d.Sf.EU.value == 0) d.Sf.EU.value = 1;} }
|
||||
function SP(){var p = d.Sf.DI.value; d.getElementById("xp").style.display = (p > 0)?"none":"block"; if (p > 0) d.Sf.EP.value = p;}
|
||||
function SetVal(){switch(parseInt(d.Sf.EP.value)){case 5568: d.Sf.DI.value = 5568; break; case 6454: d.Sf.DI.value = 6454; break; case 4048: d.Sf.DI.value = 4048; break; }; SP();}
|
||||
function FC()
|
||||
{
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
gId("G"+(j+1)).checked=gId("GS").value>>j&1;
|
||||
gId("R"+(j+1)).checked=gId("GR").value>>j&1;
|
||||
}
|
||||
}
|
||||
function GC()
|
||||
{
|
||||
var a=0, b=0;
|
||||
|
||||
var m=1;
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
a+=gId("G"+(j+1)).checked*m;
|
||||
b+=gId("R"+(j+1)).checked*m;
|
||||
m*=2;
|
||||
}
|
||||
gId("GS").value=a;
|
||||
gId("GR").value=b;
|
||||
}
|
||||
function SP(){var p = d.Sf.DI.value; gId("xp").style.display = (p > 0)?"none":"block"; if (p > 0) d.Sf.EP.value = p;}
|
||||
function SetVal(){switch(parseInt(d.Sf.EP.value)){case 5568: d.Sf.DI.value = 5568; break; case 6454: d.Sf.DI.value = 6454; break; case 4048: d.Sf.DI.value = 4048; break; }; SP();FC();}
|
||||
function S(){GetV();SetVal();}
|
||||
function GetV(){var d=document;}
|
||||
</script>
|
||||
<style>@import url("/style.css");</style>
|
||||
</head>
|
||||
<body onload="S()">
|
||||
<form id="form_s" name="Sf" method="post">
|
||||
<form id="form_s" name="Sf" method="post" onsubmit="GC()">
|
||||
<div class="toprow">
|
||||
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
||||
@ -21,6 +47,8 @@ function GetV(){var d=document;}
|
||||
<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><br>
|
||||
<input name="GS" id="GS" type="number" style="display: none;"> <!-- hidden inputs for bitwise group checkboxes -->
|
||||
<input name="GR" id="GR" type="number" style="display: none;">
|
||||
<table style="margin: 0 auto;">
|
||||
<tr>
|
||||
<td>Sync groups</td>
|
||||
|
@ -238,30 +238,32 @@ type="button" onclick="Save()">Save</button></form></body></html>)=====";
|
||||
// Autogenerated from wled00/data/settings_sync.htm, do not edit!!
|
||||
const char PAGE_settings_sync[] PROGMEM = R"=====(<!DOCTYPE html><html lang="en"><head><meta name="viewport" content="width=500">
|
||||
<meta charset="utf-8"><title>Sync Settings</title><script>
|
||||
var d=document;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings")}function B(){window.open("/settings","_self")}function adj(){6454==d.Sf.DI.value?(1==d.Sf.DA.value&&(d.Sf.DA.value=0),1==d.Sf.EU.value&&(d.Sf.EU.value=0)):5568==d.Sf.DI.value&&(0==d.Sf.DA.value&&(d.Sf.DA.value=1),0==d.Sf.EU.value&&(d.Sf.EU.value=1))}function SP(){var e=d.Sf.DI.value;d.getElementById("xp").style.display=e>0?"none":"block",e>0&&(d.Sf.EP.value=e)}function SetVal(){switch(parseInt(d.Sf.EP.value)){case 5568:d.Sf.DI.value=5568;break;case 6454:d.Sf.DI.value=6454;break;case 4048:d.Sf.DI.value=4048}SP()}function S(){GetV(),SetVal()}function GetV() {
|
||||
var d=document;function gId(e){return d.getElementById(e)}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings")}function B(){window.open("/settings","_self")}function adj(){6454==d.Sf.DI.value?(1==d.Sf.DA.value&&(d.Sf.DA.value=0),1==d.Sf.EU.value&&(d.Sf.EU.value=0)):5568==d.Sf.DI.value&&(0==d.Sf.DA.value&&(d.Sf.DA.value=1),0==d.Sf.EU.value&&(d.Sf.EU.value=1))}function FC(){for(j=0;j<8;j++)gId("G"+(j+1)).checked=gId("GS").value>>j&1,gId("R"+(j+1)).checked=gId("GR").value>>j&1}function GC(){var e=0,d=0,n=1;for(j=0;j<8;j++)e+=gId("G"+(j+1)).checked*n,d+=gId("R"+(j+1)).checked*n,n*=2;gId("GS").value=e,gId("GR").value=d}function SP(){var e=d.Sf.DI.value;gId("xp").style.display=e>0?"none":"block",e>0&&(d.Sf.EP.value=e)}function SetVal(){switch(parseInt(d.Sf.EP.value)){case 5568:d.Sf.DI.value=5568;break;case 6454:d.Sf.DI.value=6454;break;case 4048:d.Sf.DI.value=4048}SP(),FC()}function S(){GetV(),SetVal()}function GetV() {
|
||||
%CSS%%SCSS%</head><body onload="S()">
|
||||
<form id="form_s" name="Sf" method="post"><div class="toprow"><div
|
||||
class="helpB"><button type="button" onclick="H()">?</button></div><button
|
||||
<form id="form_s" name="Sf" method="post" onsubmit="GC()"><div class="toprow">
|
||||
<div class="helpB"><button type="button" onclick="H()">?</button></div><button
|
||||
type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
||||
</div><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><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>
|
||||
name="U2" type="number" min="1" max="65535" class="d5" required><br><br><input
|
||||
name="GS" id="GS" type="number" style="display:none"> <input name="GR" id="GR"
|
||||
type="number" style="display:none"><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>
|
||||
|
@ -209,13 +209,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
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;
|
||||
}
|
||||
syncGroups = request->arg(F("GS")).toInt();
|
||||
receiveGroups = request->arg(F("GR")).toInt();
|
||||
|
||||
receiveNotificationBrightness = request->hasArg(F("RB"));
|
||||
receiveNotificationColor = request->hasArg(F("RC"));
|
||||
|
@ -11,6 +11,7 @@
|
||||
void notify(byte callMode, bool followUp)
|
||||
{
|
||||
if (!udpConnected) return;
|
||||
if (!syncGroups) return;
|
||||
switch (callMode)
|
||||
{
|
||||
case CALL_MODE_INIT: return;
|
||||
@ -75,7 +76,7 @@ void notify(byte callMode, bool followUp)
|
||||
udpOut[35] = (ms >> 0) & 0xFF;
|
||||
|
||||
//sync groups
|
||||
udpOut[36] = syncGroups & 0xFF;
|
||||
udpOut[36] = syncGroups;
|
||||
|
||||
IPAddress broadcastIp;
|
||||
broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
||||
@ -229,7 +230,10 @@ void handleNotifications()
|
||||
byte version = udpIn[11];
|
||||
|
||||
// if we are not part of any sync group ignore message
|
||||
if (version > 8 && !(receiveGroups & udpIn[36])) return;
|
||||
if (version < 9 || version > 199) {
|
||||
// legacy senders are treated as if sending in sync group 1 only
|
||||
if (!(receiveGroups & 0x01)) return;
|
||||
} else if (!(receiveGroups & udpIn[36])) return;
|
||||
|
||||
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
||||
//apply colors from notification
|
||||
@ -274,7 +278,7 @@ void handleNotifications()
|
||||
}
|
||||
|
||||
//adjust system time, but only if sender is more accurate than self
|
||||
if (version > 7)
|
||||
if (version > 7 && version < 200)
|
||||
{
|
||||
Toki::Time tm;
|
||||
tm.sec = (udpIn[30] << 24) | (udpIn[31] << 16) | (udpIn[32] << 8) | (udpIn[33]);
|
||||
|
@ -429,14 +429,9 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
{
|
||||
sappend('v',SET_F("UP"),udpPort);
|
||||
sappend('v',SET_F("U2"),udpPort2);
|
||||
sappend('v',SET_F("GS"),syncGroups);
|
||||
sappend('v',SET_F("GR"),receiveGroups);
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user