Send sync group options as bytes, parse in JS
This commit is contained in:
parent
542d6361f2
commit
421f932053
@ -1,23 +1,51 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en"><head><meta name="viewport" content="width=500"><meta charset="utf-8"><title>Sync Settings</title>
|
<html lang="en"><head><meta name="viewport" content="width=500"><meta charset="utf-8"><title>Sync Settings</title>
|
||||||
<script>var d=document;
|
<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 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;}
|
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;} }
|
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 FC()
|
||||||
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();}
|
{
|
||||||
|
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 S(){GetV();SetVal();}
|
||||||
function GetV(){var d=document;}
|
function GetV(){var d=document;}
|
||||||
</script>
|
</script>
|
||||||
<style>@import url("style.css");</style></head>
|
<style>@import url("style.css");</style></head>
|
||||||
<body onload="S()">
|
<body onload="S()">
|
||||||
<form id="form_s" name="Sf" method="post">
|
<form id="form_s" name="Sf" method="post" onsubmit="GC()">
|
||||||
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
<div class="helpB"><button type="button" onclick="H()">?</button></div>
|
||||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
|
||||||
<h2>Sync setup</h2>
|
<h2>Sync setup</h2>
|
||||||
<h3>WLED Broadcast</h3>
|
<h3>WLED Broadcast</h3>
|
||||||
UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required><br>
|
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>
|
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;">
|
<table style="margin: 0 auto;">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Sync groups</td>
|
<td>Sync groups</td>
|
||||||
|
@ -237,30 +237,32 @@ type="button" onclick="Save()">Save</button></form></body></html>)=====";
|
|||||||
// Autogenerated from wled00/data/settings_sync.htm, do not edit!!
|
// 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">
|
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>
|
<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
|
%CSS%%SCSS%</head><body onload="S()"><form
|
||||||
id="form_s" name="Sf" method="post"><div class="helpB"><button type="button"
|
id="form_s" name="Sf" method="post" onsubmit="GC()"><div class="helpB"><button
|
||||||
onclick="H()">?</button></div><button type="button" onclick="B()">Back</button>
|
type="button" onclick="H()">?</button></div><button type="button" onclick="B()">
|
||||||
<button type="submit">Save</button><hr><h2>Sync setup</h2><h3>WLED Broadcast
|
Back</button><button type="submit">Save</button><hr><h2>Sync setup</h2><h3>
|
||||||
</h3>UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5"
|
WLED Broadcast</h3>UDP Port: <input name="UP" type="number" min="1" max="65535"
|
||||||
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"
|
||||||
class="d5" required><br><br><table style="margin:0 auto"><tr><td>Sync groups
|
max="65535" class="d5" required><br><br><input name="GS" id="GS" type="number"
|
||||||
</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8
|
style="display:none"> <input name="GR" id="GR" type="number"
|
||||||
</td></tr><tr><td>Send:</td><td><input type="checkbox" id="G1" name="G1"></td>
|
style="display:none"><table style="margin:0 auto"><tr><td>Sync groups</td><td>1
|
||||||
<td><input type="checkbox" id="G2" name="G2"></td><td><input type="checkbox"
|
</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td></tr>
|
||||||
id="G3" name="G3"></td><td><input type="checkbox" id="G4" name="G4"></td><td>
|
<tr><td>Send:</td><td><input type="checkbox" id="G1" name="G1"></td><td><input
|
||||||
<input type="checkbox" id="G5" name="G5"></td><td><input type="checkbox"
|
type="checkbox" id="G2" name="G2"></td><td><input type="checkbox" id="G3"
|
||||||
id="G6" name="G6"></td><td><input type="checkbox" id="G7" name="G7"></td><td>
|
name="G3"></td><td><input type="checkbox" id="G4" name="G4"></td><td><input
|
||||||
<input type="checkbox" id="G8" name="G8"></td></tr><tr><td>Receive:</td><td>
|
type="checkbox" id="G5" name="G5"></td><td><input type="checkbox" id="G6"
|
||||||
<input type="checkbox" id="R1" name="R1"></td><td><input type="checkbox"
|
name="G6"></td><td><input type="checkbox" id="G7" name="G7"></td><td><input
|
||||||
id="R2" name="R2"></td><td><input type="checkbox" id="R3" name="R3"></td><td>
|
type="checkbox" id="G8" name="G8"></td></tr><tr><td>Receive:</td><td><input
|
||||||
<input type="checkbox" id="R4" name="R4"></td><td><input type="checkbox"
|
type="checkbox" id="R1" name="R1"></td><td><input type="checkbox" id="R2"
|
||||||
id="R5" name="R5"></td><td><input type="checkbox" id="R6" name="R6"></td><td>
|
name="R2"></td><td><input type="checkbox" id="R3" name="R3"></td><td><input
|
||||||
<input type="checkbox" id="R7" name="R7"></td><td><input type="checkbox"
|
type="checkbox" id="R4" name="R4"></td><td><input type="checkbox" id="R5"
|
||||||
id="R8" name="R8"></td></tr></table><br>Receive: <input type="checkbox"
|
name="R5"></td><td><input type="checkbox" id="R6" name="R6"></td><td><input
|
||||||
name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input
|
type="checkbox" id="R7" name="R7"></td><td><input type="checkbox" id="R8"
|
||||||
type="checkbox" name="RX">Effects<br>Send notifications on direct change: <input
|
name="R8"></td></tr></table><br>Receive: <input type="checkbox" name="RB">
|
||||||
type="checkbox" name="SD"><br>Send notifications on button press or IR: <input
|
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"
|
type="checkbox" name="SB"><br>Send Alexa notifications: <input type="checkbox"
|
||||||
name="SA"><br>Send Philips Hue change 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>
|
name="SH"><br>Send Macro notifications: <input type="checkbox" name="SM"><br>
|
||||||
|
1577
wled00/html_ui.h
1577
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -203,13 +203,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
t = request->arg(F("U2")).toInt();
|
t = request->arg(F("U2")).toInt();
|
||||||
if (t > 0) udpPort2 = t;
|
if (t > 0) udpPort2 = t;
|
||||||
|
|
||||||
char k[3]; k[2] = 0;
|
syncGroups = request->arg(F("GS")).toInt();
|
||||||
syncGroups = receiveGroups = 0;
|
receiveGroups = request->arg(F("GR")).toInt();
|
||||||
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"));
|
receiveNotificationBrightness = request->hasArg(F("RB"));
|
||||||
receiveNotificationColor = request->hasArg(F("RC"));
|
receiveNotificationColor = request->hasArg(F("RC"));
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
void notify(byte callMode, bool followUp)
|
void notify(byte callMode, bool followUp)
|
||||||
{
|
{
|
||||||
if (!udpConnected) return;
|
if (!udpConnected) return;
|
||||||
|
if (!syncGroups) return;
|
||||||
switch (callMode)
|
switch (callMode)
|
||||||
{
|
{
|
||||||
case CALL_MODE_INIT: return;
|
case CALL_MODE_INIT: return;
|
||||||
@ -75,7 +76,7 @@ void notify(byte callMode, bool followUp)
|
|||||||
udpOut[35] = (ms >> 0) & 0xFF;
|
udpOut[35] = (ms >> 0) & 0xFF;
|
||||||
|
|
||||||
//sync groups
|
//sync groups
|
||||||
udpOut[36] = syncGroups & 0xFF;
|
udpOut[36] = syncGroups;
|
||||||
|
|
||||||
IPAddress broadcastIp;
|
IPAddress broadcastIp;
|
||||||
broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
broadcastIp = ~uint32_t(Network.subnetMask()) | uint32_t(Network.gatewayIP());
|
||||||
|
@ -396,14 +396,9 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
{
|
{
|
||||||
sappend('v',SET_F("UP"),udpPort);
|
sappend('v',SET_F("UP"),udpPort);
|
||||||
sappend('v',SET_F("U2"),udpPort2);
|
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('c',SET_F("HX"),liveHSVCorrection);
|
||||||
sappend('v',SET_F("HS"),liveHSVSaturation);
|
sappend('v',SET_F("HS"),liveHSVSaturation);
|
||||||
sappend('v',SET_F("HV"),liveHSVValue);
|
sappend('v',SET_F("HV"),liveHSVValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user