Version 0.5.0 nearly done

Improved user interface
Added Nightlight user interface page
Added Welcome page for new users
Added 12 User Interface Themes
Added option for custom theme, including font
Separated settings page into 6 sub-pages
Fixed Favicon not working
Fixed Alexa discovery bug
Added options to specify receiving brightness/color/effect from notifications
Added effect intensity setting. Only experimental use by 3 effects (blink) at the moment
Improved speed of Access point availability on initial setup
Removed need to reboot after enabling NTP time

TODO: IX bug
Updating readmes
This commit is contained in:
cschwinne 2018-02-23 01:33:32 +01:00
parent 76dd7b63fb
commit 6ebe889d5e
19 changed files with 231 additions and 183 deletions

View File

@ -1,8 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <head><meta charset="utf-8">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/> <link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/>
<title>WLED 0.5dev</title> <title>WLED 0.5.0</title>
<script> <script>
var d=document; var d=document;
var w=window.getComputedStyle(d.querySelector("html")); var w=window.getComputedStyle(d.querySelector("html"));
@ -12,6 +12,7 @@
var nsa=false; var nsa=false;
var sto=false; var sto=false;
var uwv=false; var uwv=false;
var sbf=true;
var firstload=true; var firstload=true;
var lastsx = 0; var lastsx = 0;
var nState = 0; var nState = 0;
@ -31,7 +32,6 @@
var w=window.getComputedStyle(d.querySelector("html")); var w=window.getComputedStyle(d.querySelector("html"));
aC = w.getPropertyValue("--aCol"); aC = w.getPropertyValue("--aCol");
bC = w.getPropertyValue("--bCol"); bC = w.getPropertyValue("--bCol");
cC = w.getPropertyValue("--cCol");
dC = w.getPropertyValue("--dCol"); dC = w.getPropertyValue("--dCol");
CV(0); CV(0);
setInterval('GIO()', 5000); setInterval('GIO()', 5000);
@ -60,12 +60,15 @@
d.Cf.SX.value = this.responseXML.getElementsByTagName('sx')[0].childNodes[0].nodeValue; d.Cf.SX.value = this.responseXML.getElementsByTagName('sx')[0].childNodes[0].nodeValue;
d.Cf.IX.value = this.responseXML.getElementsByTagName('ix')[0].childNodes[0].nodeValue; d.Cf.IX.value = this.responseXML.getElementsByTagName('ix')[0].childNodes[0].nodeValue;
nla = (this.responseXML.getElementsByTagName('nl')[0].innerHTML)!=0?true:false; nla = (this.responseXML.getElementsByTagName('nl')[0].innerHTML)!=0?true:false;
if(firstload){
d.Cf.NC.checked = (this.responseXML.getElementsByTagName('nf')[0].innerHTML)!=0?true:false;
d.Cf.SN.value = this.responseXML.getElementsByTagName('nd')[0].childNodes[0].nodeValue; d.Cf.SN.value = this.responseXML.getElementsByTagName('nd')[0].childNodes[0].nodeValue;
d.Cf.ST.value = this.responseXML.getElementsByTagName('nt')[0].childNodes[0].nodeValue; d.Cf.ST.value = this.responseXML.getElementsByTagName('nt')[0].childNodes[0].nodeValue;
CV(parseInt(this.responseXML.getElementsByTagName('md')[0].childNodes[0].nodeValue));
}firstload=false;
nState = 0; nState = 0;
nState = (this.responseXML.getElementsByTagName('nr')[0].innerHTML)!=0?1:0; nState = (this.responseXML.getElementsByTagName('nr')[0].innerHTML)!=0?1:0;
nState += (this.responseXML.getElementsByTagName('ns')[0].innerHTML)!=0?2:0; nState += (this.responseXML.getElementsByTagName('ns')[0].innerHTML)!=0?2:0;
if(firstload)CV(this.responseXML.getElementsByTagName('md')[0].childNodes[0].nodeValue);
d.getElementsByClassName("desc")[0].innerHTML = this.responseXML.getElementsByTagName('desc')[0].innerHTML; d.getElementsByClassName("desc")[0].innerHTML = this.responseXML.getElementsByTagName('desc')[0].innerHTML;
UV(); UV();
} }
@ -75,7 +78,6 @@
request.open("GET", "win/" +resp +nocache, true); request.open("GET", "win/" +resp +nocache, true);
request.send(null); request.send(null);
resp=""; resp="";
firstload=false;
} }
function GC() function GC()
{ {
@ -174,7 +176,7 @@
case 2: gId("path1").style.fill = dC;gId("path2").style.fill = aC;break; case 2: gId("path1").style.fill = dC;gId("path2").style.fill = aC;break;
case 3: gId("path1").style.fill = aC; gId("path2").style.fill = aC; case 3: gId("path1").style.fill = aC; gId("path2").style.fill = aC;
} }
tgb.style.fill=(Cf.SA.selectedIndex>0)?aC:dC; tgb.style.fill=(Cf.SA.value>0)?aC:dC;
ccX.style.display=(Cf.TX.selectedIndex>52)?"block":"none"; ccX.style.display=(Cf.TX.selectedIndex>52)?"block":"none";
fof.style.fill=(Cf.TX.selectedIndex>52)?aC:dC; fof.style.fill=(Cf.TX.selectedIndex>52)?aC:dC;
fmr.style.fill=(Cf.TX.selectedIndex<1)?aC:dC; fmr.style.fill=(Cf.TX.selectedIndex<1)?aC:dC;
@ -239,7 +241,8 @@
stb.style.fill=aC; stb.style.fill=aC;
cdB.style.display="none"; cdB.style.display="none";
stf.style.display="inline"; stf.style.display="inline";
stf.src="/settings"; if(sbf)stf.src="/settings";
sbf=false;
} }
function CloseSettings() function CloseSettings()
{ {
@ -263,6 +266,7 @@
if(nla){ if(nla){
resp+="&NL="+d.Cf.SN.value; resp+="&NL="+d.Cf.SN.value;
resp+="&NT="+d.Cf.ST.value; resp+="&NT="+d.Cf.ST.value;
resp+=(d.Cf.NC.checked)?"&NF=1":"&NF=0";
}else{ }else{
resp+="&NL=0"; resp+="&NL=0";
} }
@ -338,7 +342,8 @@
--bCol: #124; --bCol: #124;
--cCol: #334; --cCol: #334;
--dCol: #288; --dCol: #288;
--sCol: #003eff; --sCol: #FF00FF;
--cFn: Verdana;
} }
.ctrl_box { .ctrl_box {
margin: auto; margin: auto;
@ -402,14 +407,14 @@
background: linear-gradient(to right, black, red); background: linear-gradient(to right, black, red);
} }
body { body {
font-family: Verdana, Helvetica, sans-serif; font-family: var(--cFn), Helvetica, sans-serif;
text-align: center; text-align: center;
background: linear-gradient(var(--bCol),black); background: linear-gradient(var(--bCol),black);
height: 100%; height: 100%;
margin: 0; margin: 0;
background-repeat: no-repeat; background-repeat: no-repeat;
background-attachment: fixed; background-attachment: fixed;
color: var(--dCol); color: var(--tCol);
} }
html { html {
height: 100%; height: 100%;
@ -431,10 +436,10 @@
width: 12vw; width: 12vw;
height: 10vmin; height: 10vmin;
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
} }
input { input {
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-family: var(--cFn), sans-serif;
} }
button { button {
background: var(--bCol); background: var(--bCol);
@ -442,16 +447,18 @@
border: 0.5ch solid var(--bCol); border: 0.5ch solid var(--bCol);
margin-bottom: 1vh; margin-bottom: 1vh;
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-family: var(--cFn), sans-serif;
} }
select { select {
background: var(--bCol); background: var(--bCol);
color: var(--dCol); color: var(--tCol);
border: 0.5ch solid var(--bCol); border: 0.5ch solid var(--bCol);
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-family: var(--cFn), sans-serif;
} }
input[type=number] { input[type=number] {
background: var(--bCol); background: var(--bCol);
color: var(--dCol); color: var(--tCol);
border: 0.5ch solid var(--bCol); border: 0.5ch solid var(--bCol);
width: 3em; width: 3em;
} }

View File

@ -1,11 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html><head> <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WLED Message</title> <title>WLED Message</title>
<script> <script>
function B() { function B() {
window.history.back(); window.history.back();
} }
function RS() {
window.location = "/settings";
}
function RP() {
top.location.href=top.location.href;
}
</script> </script>
<style> <style>
:root { :root {
@ -14,22 +19,25 @@
--cCol: #1D2731; --cCol: #1D2731;
--dCol: #328CC1; --dCol: #328CC1;
--sCol: #000; --sCol: #000;
--tCol: #328CC1;
--cFn: Verdana;
} }
button { button {
background: var(--bCol); background: var(--bCol);
color: var(--dCol); color: var(--tCol);
border: 0.3ch solid var(--bCol); border: 0.3ch solid var(--bCol);
display: inline-block; display: inline-block;
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-family: var(--cFn), sans-serif;
font-size: 20px; font-size: 20px;
margin: 8px; margin: 8px;
margin-top: 12px; margin-top: 12px;
} }
body { body {
font-family: Verdana, Helvetica, sans-serif; font-family: var(--cFn), sans-serif;
text-align: center; text-align: center;
background: var(--cCol); background: var(--cCol);
color: var(--dCol); color: var(--tCol);
line-height: 200%; line-height: 200%;
margin: 0; margin: 0;
background-attachment: fixed; background-attachment: fixed;

View File

@ -9,9 +9,10 @@
--cCol: #1D2731; --cCol: #1D2731;
--dCol: #328CC1; --dCol: #328CC1;
--sCol: #000; --sCol: #000;
--tCol: #328CC1;
--cFn: Verdana;
} }
body { body {
font-family: Verdana, Helvetica, sans-serif;
text-align: center; text-align: center;
background: var(--cCol); background: var(--cCol);
height: 100%; height: 100%;
@ -20,11 +21,13 @@
} }
button { button {
background: var(--bCol); background: var(--bCol);
color: var(--dCol); color: var(--tCol);
font-family: var(--cFn), Helvetica, sans-serif;
border: 0.3ch solid var(--bCol); border: 0.3ch solid var(--bCol);
display: inline-block; display: inline-block;
filter: drop-shadow( -5px -5px 5px var(--sCol) ); filter: drop-shadow( -5px -5px 5px var(--sCol) );
font-size: 9vmin; font-size: 8vmin;
height:13.86vh;
width: 95%; width: 95%;
margin-top: 2.4vh; margin-top: 2.4vh;
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,20 +0,0 @@
6. Amber:
--aCol: #f7c331;
--bCol: #dcc7aa;
--cCol: #6b7a8f;
--dCol: #f7882f;
--sCol: #0007;
7. Club
--aCol: #fc3;
--bCol: #124;
--cCol: #334;
--dCol: #f1d;
--sCol: #f00;
8: Air:
--aCol: #0ac;
--bCol: #124;
--cCol: #334;
--dCol: #00ced1;
--sCol: #003eff;

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <head>
<title>WLED Setup</title> <title>WLED Setup</title>
<style> <style>
:root { :root {
@ -20,6 +20,7 @@
background-attachment: fixed; background-attachment: fixed;
color: var(--dCol); color: var(--dCol);
} }
svg { svg {
fill: var(--dCol); fill: var(--dCol);
} }

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
* Settings html * Settings html
*/ */
const char PAGE_settingsCss[] PROGMEM = R"=====( const char PAGE_settingsCss[] PROGMEM = R"=====(
body{font-family:Verdana,Helvetica,sans-serif;text-align:center;background:var(--cCol);color:var(--dCol);line-height:200%;margin:0;background-attachment:fixed}hr{border-color:var(--dCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}button{background:var(--bCol);color:var(--dCol);border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}.helpB{text-align:left;position:absolute;width:60px}input{background:var(--bCol);color:var(--dCol);border:.5ch solid var(--bCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}input[type=number]{width:3em}select{background:var(--bCol);color:var(--dCol);border:0.5ch solid var(--bCol);filter:drop-shadow( -5px -5px 5px var(--sCol) );}</style> body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed}hr{border-color:var(--dCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}.helpB{text-align:left;position:absolute;width:60px}input{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.5ch solid var(--bCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}input[type=number]{width:3em}select{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:0.5ch solid var(--bCol);filter:drop-shadow( -5px -5px 5px var(--sCol) );}</style>
)====="; )=====";
const char PAGE_settings0[] PROGMEM = R"=====( const char PAGE_settings0[] PROGMEM = R"=====(
@ -13,7 +13,7 @@ const char PAGE_settings0[] PROGMEM = R"=====(
)====="; )=====";
const char PAGE_settings1[] PROGMEM = R"=====( const char PAGE_settings1[] PROGMEM = R"=====(
body{font-family:Verdana,Helvetica,sans-serif;text-align:center;background:var(--cCol);height:100%;margin:0;background-attachment:fixed}button{background:var(--bCol);color:var(--dCol);border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:9vmin;width:95%;margin-top:2.4vh}</style> body{text-align:center;background:var(--cCol);height:100%;margin:0;background-attachment:fixed}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:8vmin;height:13.86vh;width:95%;margin-top:2.4vh}</style>
</head> </head>
<body> <body>
<form action=/settings/wifi><button type=submit>WiFi Setup</button></form> <form action=/settings/wifi><button type=submit>WiFi Setup</button></form>
@ -37,7 +37,7 @@ const char PAGE_settings_wifi1[] PROGMEM = R"=====(
<body onload="GetV()"> <body onload="GetV()">
<form id="form_s" name="Sf" method="post"> <form id="form_s" name="Sf" method="post">
<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" name="SUBM">Save</button><hr> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save & Reboot</button><hr>
<h2>WiFi setup</h2> <h2>WiFi setup</h2>
<h3>Connect to existing network</h3> <h3>Connect to existing network</h3>
Network name (SSID, empty to not connect): <br><input name="CSSID" maxlength="32"> <br> Network name (SSID, empty to not connect): <br><input name="CSSID" maxlength="32"> <br>
@ -67,7 +67,7 @@ Hide AP name: <input type="checkbox" name="APHSSID"> <br>
AP password (leave empty for open): <br> <input type="password" name="APPASS" maxlength="63"> <br> AP password (leave empty for open): <br> <input type="password" name="APPASS" maxlength="63"> <br>
Access Point WiFi channel: <input name="APCHAN" type="number" min="1" max="13" required> <br> Access Point WiFi channel: <input name="APCHAN" type="number" min="1" max="13" required> <br>
AP IP: <span class="sip"> Not active </span> <hr> AP IP: <span class="sip"> Not active </span> <hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save & Reboot</button>
</form> </form>
</body> </body>
</html> </html>
@ -152,21 +152,24 @@ Color Theme:
<option value="6">Amber</option> <option value="6">Amber</option>
<option value="7">Club</option> <option value="7">Club</option>
<option value="8">Air</option> <option value="8">Air</option>
<option value="9">Coookie</option> <option value="9">Nixie</option>
<option value="10">Unused</option> <option value="10">Terminal</option>
<option value="11">Unused</option> <option value="11">Placeholder</option>
<option value="12">Unused</option> <option value="12">Placeholder</option>
<option value="13">Unused</option> <option value="13">Placeholder</option>
<option value="14">The End</option> <option value="14">The End</option>
<option value="15" id="co">Custom</option> <option value="15" id="co">Custom</option>
</select><br> </select><br>
<div id="cth"> <div id="cth">
Please specify your custom hex colors (e.g. #FF0000 for red)<br> Please specify your custom hex colors (e.g. FF0000 for red)<br>
Custom accent color: <input maxlength=9 name="CCOL0"><br> Custom accent color: <input maxlength=9 name="CCOL0"><br>
Custom background: <input maxlength=9 name="CCOL1"><br> Custom background: <input maxlength=9 name="CCOL1"><br>
Custom panel color: <input maxlength=9 name="CCOL2"><br> Custom panel color: <input maxlength=9 name="CCOL2"><br>
Custom text color: <input maxlength=9 name="CCOL3"><br> Custom icon color: <input maxlength=9 name="CCOL3"><br>
Custom shadow: <input maxlength=9 name="CCOL4"><br></div> Custom shadow: <input maxlength=9 name="CCOL4"><br>
Custom text color: <input maxlength=9 name="CCOL5"><br></div>
Use font: <input maxlength=32 name="CFONT"><br>
Make sure the font you use is installed on your system!<br>
<hr><button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button> <hr><button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form> </form>
</body> </body>
@ -233,9 +236,8 @@ const char PAGE_settings_time1[] PROGMEM = R"=====(
<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" name="SUBM">Save</button><hr> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button><hr>
<h2>Time setup</h2> <h2>Time setup</h2>
Requires reboot. <br>
Get time from NTP server: <input type="checkbox" name="NTPON"><br> Get time from NTP server: <input type="checkbox" name="NTPON"><br>
NTP server: <input name="NTPSR" maxlength="32"><br> <!--NTP server: <input name="NTPSR" maxlength="32"><br>
Time zone: Time zone:
<select name="TZONE"> <select name="TZONE">
<option value="1" selected>GMT(UTC)</option> <option value="1" selected>GMT(UTC)</option>
@ -252,7 +254,7 @@ Time zone:
<option value="12">AEST/AEDT</option> <option value="12">AEST/AEDT</option>
<option value="13">NZST/NZDT</option> <option value="13">NZST/NZDT</option>
</select><br> </select><br>
Hour/Min offset: <input name="TOFSH" type="number" min="-255" max="255" required> <input name="TOFSM" type="number" min="-255" max="255" required><br> Hour/Min offset: <input name="TOFSH" type="number" min="-255" max="255" required> <input name="TOFSM" type="number" min="-255" max="255" required><br>-->
Current local time is <span class="times">unknown</span>. Current local time is <span class="times">unknown</span>.
<h3>Weather</h3> <h3>Weather</h3>
Coming soon! Not yet implemented! Coming soon! Not yet implemented!
@ -264,7 +266,8 @@ Reverse (turns on at sunset): <input type="checkbox" name="WREVL"><br>
Fade duration: <input name="WSDUR" type="number" min="0" max="255" required><br> Fade duration: <input name="WSDUR" type="number" min="0" max="255" required><br>
Sunrise/Sunset Offset: <input name="WSOFS" type="number" min="-255" max="255" required>--> Sunrise/Sunset Offset: <input name="WSOFS" type="number" min="-255" max="255" required>-->
<h3>Advanced Macros</h3> <h3>Advanced Macros</h3>
Define API macros here:<br> Coming soon! Not yet implemented!
<!--Define API macros here:<br>
0: <input name="MCR00" maxlength="64"><br> 0: <input name="MCR00" maxlength="64"><br>
1: <input name="MCR01" maxlength="64"><br> 1: <input name="MCR01" maxlength="64"><br>
2: <input name="MCR02" maxlength="64"><br> 2: <input name="MCR02" maxlength="64"><br>
@ -283,19 +286,21 @@ Define API macros here:<br>
15: <input name="MCR15" maxlength="64"><br> 15: <input name="MCR15" maxlength="64"><br>
<br> <br>
<i>Use -1 to use the default action instead of a macro</i><br> <i>Use -1 to use the default action instead of a macro</i><br>
<!--1st Time-Controlled Macro:--> <--1st Time-Controlled Macro:
Alexa On/Off Macros: <input name="MCA0I" type="number" min="-1" max="15" required> <input name="MCA0O" type="number" min="-1" max="15" required><br> Alexa On/Off Macros: <input name="MCA0I" type="number" min="-1" max="15" required> <input name="MCA0O" type="number" min="-1" max="15" required><br>
<!--Emulate 2nd Alexa device: <--Emulate 2nd Alexa device:
Emulate 3rd Alexa device:-->
Emulate 3rd Alexa device:
Button Macro: <input name="MCBT0" type="number" min="-1" max="15" required><br> Button Macro: <input name="MCBT0" type="number" min="-1" max="15" required><br>
Button Long Press Macro: <input name="MCBT1" type="number" min="-1" max="15" required><br> Button Long Press Macro: <input name="MCBT1" type="number" min="-1" max="15" required><br>
<!--Sunrise Macro <--Sunrise Macro
Sunset Macro--> Sunset Macro
Countdown-Over Macro: <input name="MCNTD" type="number" min="-1" max="15" required><br> Countdown-Over Macro: <input name="MCNTD" type="number" min="-1" max="15" required><br>-->
<hr> <hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form> </form>
</body></html> </body>
</html>
)====="; )=====";
const char PAGE_settings_sec0[] PROGMEM = R"=====( const char PAGE_settings_sec0[] PROGMEM = R"=====(
@ -309,7 +314,7 @@ const char PAGE_settings_sec1[] PROGMEM = R"=====(
<body onload="GetV()"> <body onload="GetV()">
<form id="form_s" name="Sf" method="post"> <form id="form_s" name="Sf" method="post">
<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" name="SUBM">Save</button><hr> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save & Reboot</button><hr>
<h2>Security & Update setup</h2> <h2>Security & Update setup</h2>
Enable OTA lock: <input type="checkbox" name="NOOTA"><br> Enable OTA lock: <input type="checkbox" name="NOOTA"><br>
Passphrase: <input type="password" name="OPASS" maxlength="32"><br> Passphrase: <input type="password" name="OPASS" maxlength="32"><br>
@ -328,7 +333,7 @@ HTTP traffic is not encrypted. An attacker in the same network could intercept f
<button type="button" onclick="U()">Manual OTA Update</button><br> <button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br> Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
<h3>About</h3> <h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.5dev<br> <a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.5.0<br>
(c) 2016-2018 Christian Schwinne <br> (c) 2016-2018 Christian Schwinne <br>
<i>Licensed under the MIT license</i><br><br> <i>Licensed under the MIT license</i><br><br>
<i>Uses libraries:</i><br> <i>Uses libraries:</i><br>
@ -339,7 +344,7 @@ Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
<i><a href="https://github.com/Aircoookie/Espalexa">Espalexa</a> by Aircoookie (modified)</i><br><br> <i><a href="https://github.com/Aircoookie/Espalexa">Espalexa</a> by Aircoookie (modified)</i><br><br>
<i>UI icons by <a href="https://linearicons.com">Linearicons</a> created by <a href="https://perxis.com">Perxis</a>! (CC-BY-SA 4.0)</i> <br><br> <i>UI icons by <a href="https://linearicons.com">Linearicons</a> created by <a href="https://perxis.com">Perxis</a>! (CC-BY-SA 4.0)</i> <br><br>
Server message: <span class="msg"> Response error! </span><hr> Server message: <span class="msg"> Response error! </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button> <button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save & Reboot</button>
</form> </form>
</body> </body>
</html> </html>

View File

@ -4,12 +4,11 @@
const char PAGE_msg0[] PROGMEM = R"=====( const char PAGE_msg0[] PROGMEM = R"=====(
<!DOCTYPE html> <!DOCTYPE html>
<html><head> <html><head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>WLED Message</title> <title>WLED Message</title>
<script>function B(){window.history.back()};</script> <script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href=top.location.href;}</script>
)====="; )=====";
const char PAGE_msg1[] PROGMEM = R"=====( const char PAGE_msg1[] PROGMEM = R"=====(
button{background:var(--bCol);color:var(--dCol);border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}body{font-family:Verdana,Helvetica,sans-serif;text-align:center;background:var(--cCol);color:var(--dCol);line-height:200%;margin:0;background-attachment:fixed}</style> button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed}</style>
</head> </head>
<body> <body>
)====="; )=====";
@ -20,7 +19,7 @@ const char PAGE_welcome0[] PROGMEM = R"=====(
<title>WLED Welcome!</title> <title>WLED Welcome!</title>
)====="; )=====";
const char PAGE_welcome1[] PROGMEM = R"=====( const char PAGE_welcome1[] PROGMEM = R"=====(
body{font-family:Verdana, Helvetica, sans-serif;text-align:center;background:linear-gradient(var(--bCol),black);height:100%;margin:0;background-repeat:no-repeat;background-attachment: fixed;color: var(--dCol);}svg {fill: var(--dCol);} body{font-family:var(--cFn),sans-serif;text-align:center;background:linear-gradient(var(--bCol),black);height:100%;margin:0;background-repeat:no-repeat;background-attachment: fixed;color: var(--tCol);}svg {fill: var(--dCol);}
</style></head> </style></head>
<body> <body>
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg"> <svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg">
@ -54,7 +53,7 @@ const char PAGE_edit[] PROGMEM = R"=====(SPIFFS disabled)=====";
/* /*
* favicon * favicon
*/ */
const char favicon[156] PROGMEM = { const char favicon[] PROGMEM = {
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,
0x18, 0x00, 0x86, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x89, 0x50, 0x18, 0x00, 0x86, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x89, 0x50,
0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48,

View File

@ -12,16 +12,17 @@
const char* ESP8266HTTPUpdateServer::_serverIndex = const char* ESP8266HTTPUpdateServer::_serverIndex =
R"(<html><body><h2>WLED Software Update</h2><br>Get the latest binaries on the <a href="https://github.com/Aircoookie/WLED/tree/master/bin">project GitHub page</a>!<br> R"(<html><head><script>function B(){window.history.back()}</script></head><body><h2>WLED Software Update</h2><br>Get the latest binaries on the <a href="https://github.com/Aircoookie/WLED/tree/master/bin">project GitHub page</a>!<br>
<i>Unsure which binary is correct? Go to the <a href="./build">/build subpage</a> to find the details of this version.</i><br> <i>Unsure which binary is correct? Go to the <a href="./build">/build subpage</a> for the details of this version.</i><br>
<b>Double check to be sure to upload a valid .bin firmware file for your ESP! Otherwise you'll need USB recovery!</b><br><br> <b>Be sure to upload a valid .bin file for your ESP! Otherwise you'll need USB recovery!</b><br>
<form method='POST' action='' enctype='multipart/form-data'> <br><br><button onclick="B()\">Back</button><br><br>
<input type='file' name='update'> <form method='POST' action='' enctype='multipart/form-data'>
<input type='submit' value='Update!'> <input type='file' name='update'>
</form> <input type='submit' value='Update!'>
</body></html>)"; </form>
</body></html>)";
const char* ESP8266HTTPUpdateServer::_failedResponse = R"(Update Failed!)"; const char* ESP8266HTTPUpdateServer::_failedResponse = R"(Update Failed!)";
const char* ESP8266HTTPUpdateServer::_successResponse = "<META http-equiv=\"refresh\" content=\"15;URL=./\">Update Successful! Rebooting, please wait for redirect..."; const char* ESP8266HTTPUpdateServer::_successResponse = R"(<script>setTimeout(function(){top.location.href="/";},20000);</script>Update Successful! Rebooting, please wait for redirect...)";
ESP8266HTTPUpdateServer::ESP8266HTTPUpdateServer(bool serial_debug) ESP8266HTTPUpdateServer::ESP8266HTTPUpdateServer(bool serial_debug)
{ {

View File

@ -3,7 +3,7 @@
*/ */
/* /*
* @title WLED project sketch * @title WLED project sketch
* @version 0.5dev * @version 0.5.0
* @author Christian Schwinne * @author Christian Schwinne
*/ */
@ -30,8 +30,8 @@
#include "WS2812FX.h" #include "WS2812FX.h"
//version in format yymmddb (b = daily build) //version in format yymmddb (b = daily build)
#define VERSION 1802193 #define VERSION 1802221
const String versionName = "WLED 0.5dev"; const String versionString = "0.5.0";
//AP and OTA default passwords (change them!) //AP and OTA default passwords (change them!)
String appass = "wled1234"; String appass = "wled1234";
@ -83,7 +83,7 @@ bool ntpEnabled = true;
#endif #endif
//Default CONFIG //Default CONFIG
String serverDescription = versionName; String serverDescription = versionString;
uint8_t currentTheme = 0; uint8_t currentTheme = 0;
String clientssid = "Your_Network_Here"; String clientssid = "Your_Network_Here";
String clientpass = "Dummy_Pass"; String clientpass = "Dummy_Pass";
@ -112,12 +112,12 @@ uint8_t nightlightTargetBri = 0, bri_nl_t;
bool fadeTransition = true; bool fadeTransition = true;
bool sweepTransition = false, sweepDirection = true; bool sweepTransition = false, sweepDirection = true;
uint16_t transitionDelay = 1200; uint16_t transitionDelay = 1200;
bool otaLock = true; bool otaLock = false, wifiLock = false;
bool aOtaEnabled = true; bool aOtaEnabled = true;
bool onlyAP = false; bool onlyAP = false;
bool buttonEnabled = true; bool buttonEnabled = true;
bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false; bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false;
bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificlationColor = true, receiveNotificationEffects = true; bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificationColor = true, receiveNotificationEffects = true;
uint8_t briMultiplier = 100; uint8_t briMultiplier = 100;
uint8_t nightlightDelayMins = 60; uint8_t nightlightDelayMins = 60;
bool nightlightFade = true; bool nightlightFade = true;
@ -182,6 +182,7 @@ uint8_t effectIntensity = 128;
boolean udpConnected = false; boolean udpConnected = false;
byte udpIn[1026]; byte udpIn[1026];
String cssCol[]={"","","","","",""}; String cssCol[]={"","","","","",""};
String cssFont="Verdana";
String cssColorString=""; String cssColorString="";
//NTP stuff //NTP stuff
boolean ntpConnected = false; boolean ntpConnected = false;
@ -252,7 +253,7 @@ WS2812FX strip = WS2812FX(LEDCOUNT);
//1 -> 0.4p 1711272 and up //1 -> 0.4p 1711272 and up
//2 -> 0.4p 1711302 and up //2 -> 0.4p 1711302 and up
//3 -> 0.4 1712121 and up //3 -> 0.4 1712121 and up
//4 -> 0.5dev 1801271 and up //4 -> 0.5.0 and up
#ifdef DEBUG #ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x) #define DEBUG_PRINT(x) Serial.print (x)
@ -295,7 +296,7 @@ const uint8_t gamma8[] = {
String txd = "Please disable OTA Lock in security settings!"; String txd = "Please disable OTA Lock in security settings!";
void serveMessage(int,String,String,bool=false); void serveMessage(int,String,String,int=255);
void down() void down()
{ {

View File

@ -19,7 +19,6 @@ void saveSettingsToEEPROM()
{ {
clearEEPROM(); clearEEPROM();
EEPROM.write(233, 233); EEPROM.write(233, 233);
showWelcomePage = true;
} else } else
{ {
showWelcomePage = false; showWelcomePage = false;
@ -130,15 +129,20 @@ void saveSettingsToEEPROM()
EEPROM.write(390, aOtaEnabled); EEPROM.write(390, aOtaEnabled);
EEPROM.write(391, receiveNotificationColor); EEPROM.write(391, receiveNotificationColor);
EEPROM.write(392, receiveNotificationEffects); EEPROM.write(392, receiveNotificationEffects);
if (currentTheme == 15) EEPROM.write(393, wifiLock);
{
for (int k=0;k<6;k++){ for (int k=0;k<6;k++){
for (int i = 900+k*8; i < (908+k*8); ++i) int in = 900+k*8;
for (int i=in; i < in+8; ++i)
{ {
EEPROM.write(i, cssCol[k].charAt(i-900)); EEPROM.write(i, cssCol[k].charAt(i-in));
}} }}
}
EEPROM.write(948,currentTheme); EEPROM.write(948,currentTheme);
for (int i = 950; i < 982; ++i)
{
EEPROM.write(i, cssFont.charAt(i-950));
}
EEPROM.commit(); EEPROM.commit();
} }
@ -147,6 +151,7 @@ void loadSettingsFromEEPROM(bool first)
{ {
if (EEPROM.read(233) != 233) //first boot/reset to default if (EEPROM.read(233) != 233) //first boot/reset to default
{ {
showWelcomePage=true;
saveSettingsToEEPROM(); saveSettingsToEEPROM();
return; return;
} }
@ -280,24 +285,29 @@ void loadSettingsFromEEPROM(bool first)
aOtaEnabled = EEPROM.read(390); aOtaEnabled = EEPROM.read(390);
receiveNotificationColor = EEPROM.read(391); receiveNotificationColor = EEPROM.read(391);
receiveNotificationEffects = EEPROM.read(392); receiveNotificationEffects = EEPROM.read(392);
cssFont = "";
for (int i = 950; i < 982; ++i)
{
if (EEPROM.read(i) == 0) break;
cssFont += char(EEPROM.read(i));
}
} }
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
bootPreset = EEPROM.read(389); bootPreset = EEPROM.read(389);
wifiLock = EEPROM.read(393);
//favorite setting memory (25 slots/ each 20byte) //favorite setting memory (25 slots/ each 20byte)
//400 - 899 reserved //400 - 899 reserved
currentTheme = EEPROM.read(948); currentTheme = EEPROM.read(948);
if (currentTheme == 15) for (int k=0;k<6;k++){
{ int in=900+k*8;
for (int k=0;k<6;k++){ for (int i=in; i < in+8; ++i)
for (int i = 900+k*8; i < (908+k*8); ++i)
{ {
if (EEPROM.read(i) == 0) break; if (EEPROM.read(i) == 0) break;
cssCol[k] += char(EEPROM.read(i)); cssCol[k] += char(EEPROM.read(i));
}} }}
}
//custom macro memory (16 slots/ each 64byte) //custom macro memory (16 slots/ each 64byte)
//1024-2047 reserved //1024-2047 reserved

View File

@ -153,6 +153,7 @@ String getSettings(uint8_t subPage)
resp += ds + "BOOTP" + v + bootPreset +";"; resp += ds + "BOOTP" + v + bootPreset +";";
resp += ds + "FXDEF" + v + effectDefault +";"; resp += ds + "FXDEF" + v + effectDefault +";";
resp += ds + "SXDEF" + v + effectSpeedDefault +";"; resp += ds + "SXDEF" + v + effectSpeedDefault +";";
resp += ds + "IXDEF" + v + effectIntensityDefault +";";
resp += ds + "GCBRI" + c + useGammaCorrectionBri +";"; resp += ds + "GCBRI" + c + useGammaCorrectionBri +";";
resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";"; resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";";
resp += ds + "TFADE" + c + fadeTransition +";"; resp += ds + "TFADE" + c + fadeTransition +";";
@ -172,8 +173,9 @@ String getSettings(uint8_t subPage)
resp += ds + "DESC" + v + "\"" + serverDescription + "\";"; resp += ds + "DESC" + v + "\"" + serverDescription + "\";";
resp += ds + "COLMD" + c + useHSBDefault + ";"; resp += ds + "COLMD" + c + useHSBDefault + ";";
resp += ds + "THEME.selectedIndex=" + String(currentTheme) + ";"; resp += ds + "THEME.selectedIndex=" + String(currentTheme) + ";";
for(int i=0;i<5;i++) for(int i=0;i<6;i++)
resp += ds + "CCOL" + i + v + "\"" + cssCol[i] + "\";"; resp += ds + "CCOL" + i + v + "\"" + cssCol[i] + "\";";
resp += ds + "CFONT" + v + "\"" + cssFont + "\";";
} }
if (subPage == 4) if (subPage == 4)
@ -199,9 +201,10 @@ String getSettings(uint8_t subPage)
if (subPage == 6) if (subPage == 6)
{ {
resp += ds + "NOOTA" + c + otaLock +";"; resp += ds + "NOOTA" + c + otaLock +";";
resp += ds + "OWIFI" + c + wifiLock +";";
resp += ds + "AROTA" + c + aOtaEnabled +";"; resp += ds + "AROTA" + c + aOtaEnabled +";";
resp += ds + "NORAP" + c + recoveryAPDisabled +";"; resp += ds + "NORAP" + c + recoveryAPDisabled +";";
resp += dg + "(\"msg\")[0]" + ih + "\""+ versionName +" (build " + VERSION + ") OK\";"; resp += dg + "(\"msg\")[0]" + ih + "\"WLED "+ versionString +" (build " + VERSION + ") OK\";";
} }
resp += "}</script>"; resp += "}</script>";

View File

@ -196,6 +196,11 @@ void handleSettingsSet(uint8_t subPage)
int i = server.arg("SXDEF").toInt(); int i = server.arg("SXDEF").toInt();
if (i >= 0 && i <= 255) effectSpeedDefault = i; if (i >= 0 && i <= 255) effectSpeedDefault = i;
} }
if (server.hasArg("IXDEF"))
{
int i = server.arg("IXDEF").toInt();
if (i >= 0 && i <= 255) effectIntensityDefault = i;
}
} }
turnOnAtBoot = server.hasArg("BOOTN"); turnOnAtBoot = server.hasArg("BOOTN");
if (server.hasArg("BOOTP")) if (server.hasArg("BOOTP"))
@ -251,10 +256,11 @@ void handleSettingsSet(uint8_t subPage)
useHSBDefault = server.hasArg("COLMD"); useHSBDefault = server.hasArg("COLMD");
useHSB = useHSBDefault; useHSB = useHSBDefault;
if (server.hasArg("THEME")) currentTheme = server.arg("THEME").toInt(); if (server.hasArg("THEME")) currentTheme = server.arg("THEME").toInt();
for(int i=0;i<5;i++) for(int i=0;i<6;i++)
{ {
if (server.hasArg(("CCOL"+i))) cssCol[i] = server.arg(("CCOL"+i)); if (server.hasArg("CCOL"+String(i))) cssCol[i] = server.arg("CCOL"+String(i));
} }
if (server.hasArg("CFONT")) cssFont = server.arg("CFONT");
buildCssColorString(); buildCssColorString();
} }
@ -281,6 +287,7 @@ void handleSettingsSet(uint8_t subPage)
if (subPage == 5) if (subPage == 5)
{ {
ntpEnabled = server.hasArg("NTPON"); ntpEnabled = server.hasArg("NTPON");
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); //start if not already connected
} }
//SECURITY //SECURITY
@ -289,27 +296,27 @@ void handleSettingsSet(uint8_t subPage)
if (server.hasArg("RESET")) if (server.hasArg("RESET"))
{ {
clearEEPROM(); clearEEPROM();
serveMessage(200, "All Settings erased.", "Rebooting..."); serveMessage(200, "All Settings erased.", "Connect to WLED-AP to setup again...",255);
reset(); reset();
} }
bool pwdCorrect = !otaLock; //always allow access if ota not locked
if (server.hasArg("OPASS")) if (server.hasArg("OPASS"))
{ {
if (!otaLock) if (otaLock && otapass.equals(server.arg("OPASS")))
{
pwdCorrect = true;
}
if (!otaLock && server.arg("OPASS").length() > 0)
{ {
if (server.arg("OPASS").length() > 0)
otapass = server.arg("OPASS"); otapass = server.arg("OPASS");
} else if (!server.hasArg("NOOTA"))
{
if (otapass.equals(server.arg("OPASS")))
{
otaLock = false;
}
} }
} }
if (server.hasArg("NOOTA")) otaLock = true;
if (!otaLock) if (pwdCorrect) //allow changes if correct pwd or no ota active
{ {
otaLock = server.hasArg("NOOTA");
wifiLock = server.hasArg("OWIFI");
recoveryAPDisabled = server.hasArg("NORAP"); recoveryAPDisabled = server.hasArg("NORAP");
aOtaEnabled = server.hasArg("AROTA"); aOtaEnabled = server.hasArg("AROTA");
} }
@ -547,7 +554,8 @@ boolean handleSet(String req)
} }
} }
//toggle nightlight mode //toggle nightlight mode
if (req.indexOf("NL=") > 0) pos = req.indexOf("NL=");
if (pos > 0)
{ {
if (req.indexOf("NL=0") > 0) if (req.indexOf("NL=0") > 0)
{ {
@ -555,15 +563,10 @@ boolean handleSet(String req)
bri = bri_t; bri = bri_t;
} else { } else {
nightlightActive = true; nightlightActive = true;
nightlightDelayMins = req.substring(pos + 3).toInt();
nightlightStartTime = millis(); nightlightStartTime = millis();
} }
} }
//set nightlight delay
pos = req.indexOf("ND=");
if (pos > 0) {
nightlightDelayMins = req.substring(pos + 3).toInt();
nightlightActive_old = false; //re-init
}
//set nightlight target brightness //set nightlight target brightness
pos = req.indexOf("NT="); pos = req.indexOf("NT=");
if (pos > 0) { if (pos > 0) {

View File

@ -75,7 +75,12 @@ void wledInit()
serveSettings(0); serveSettings(0);
}); });
server.on("/settings/wifi", HTTP_GET, [](){ server.on("/settings/wifi", HTTP_GET, [](){
serveSettings(1); if (!(wifiLock && otaLock))
{
serveSettings(1);
}else{
serveMessage(500, "Access Denied", txd, 254);
}
}); });
server.on("/settings/leds", HTTP_GET, [](){ server.on("/settings/leds", HTTP_GET, [](){
serveSettings(2); serveSettings(2);
@ -94,7 +99,10 @@ void wledInit()
}); });
server.on("/favicon.ico", HTTP_GET, [](){ server.on("/favicon.ico", HTTP_GET, [](){
if(!handleFileRead("/favicon.ico")) server.send(200, "image/x-icon", favicon); if(!handleFileRead("/favicon.ico"))
{
server.send_P(200, "image/x-icon", favicon, 156);
}
}); });
server.on("/", HTTP_GET, [](){ server.on("/", HTTP_GET, [](){
@ -116,39 +124,39 @@ void wledInit()
}); });
server.on("/reset", HTTP_GET, [](){ server.on("/reset", HTTP_GET, [](){
serveMessage(200,"Rebooting now...","(takes ~15 seconds)"); serveMessage(200,"Rebooting now...","(takes ~20 seconds, wait for auto-redirect)",139);
reset(); reset();
}); });
server.on("/settings/wifi", HTTP_POST, [](){ server.on("/settings/wifi", HTTP_POST, [](){
handleSettingsSet(1); if (!(wifiLock && otaLock)) handleSettingsSet(1);
serveMessage(200,"WiFi settings saved.","Rebooting now..."); serveMessage(200,"WiFi settings saved.","Rebooting now... (takes ~20 seconds, wait for auto-redirect)",139);
reset(); reset();
}); });
server.on("/settings/leds", HTTP_POST, [](){ server.on("/settings/leds", HTTP_POST, [](){
handleSettingsSet(2); handleSettingsSet(2);
serveMessage(200,"LED settings saved.","",true); serveMessage(200,"LED settings saved.","Redirecting...",1);
}); });
server.on("/settings/ui", HTTP_POST, [](){ server.on("/settings/ui", HTTP_POST, [](){
handleSettingsSet(3); handleSettingsSet(3);
serveMessage(200,"UI settings saved.","",true); serveMessage(200,"UI settings saved.","Reloading to apply theme...",122);
}); });
server.on("/settings/sync", HTTP_POST, [](){ server.on("/settings/sync", HTTP_POST, [](){
handleSettingsSet(4); handleSettingsSet(4);
serveMessage(200,"Sync settings saved.","",true); serveMessage(200,"Sync settings saved.","Redirecting...",1);
}); });
server.on("/settings/time", HTTP_POST, [](){ server.on("/settings/time", HTTP_POST, [](){
handleSettingsSet(5); handleSettingsSet(5);
serveMessage(200,"Time settings saved.","If you made changes to NTP, please reboot.",true); serveMessage(200,"Time settings saved.","Redirecting...",1);
}); });
server.on("/settings/sec", HTTP_POST, [](){ server.on("/settings/sec", HTTP_POST, [](){
handleSettingsSet(6); handleSettingsSet(6);
serveMessage(200,"Security settings saved.","Rebooting now..."); serveMessage(200,"Security settings saved.","Rebooting now... (takes ~20 seconds, wait for auto-redirect)",139);
reset(); reset();
}); });
@ -166,12 +174,12 @@ void wledInit()
server.on("/power", HTTP_GET, [](){ server.on("/power", HTTP_GET, [](){
String val = (String)(int)strip.getPowerEstimate(ledcount,strip.getColor(),strip.getBrightness()); String val = (String)(int)strip.getPowerEstimate(ledcount,strip.getColor(),strip.getBrightness());
val += "mA currently\nNotice: This is just an estimate which does not take into account several factors (like effects and wire resistance). It is NOT an accurate measurement!"; val += "mA currently";
server.send(200, "text/plain", val); serveMessage(200,val,"This is just an estimate (does not take into account several factors like effects and wire resistance). It is NOT an accurate measurement!",254);
}); });
server.on("/teapot", HTTP_GET, [](){ server.on("/teapot", HTTP_GET, [](){
serveMessage(418, "418. I'm a teapot.","(Tangible Embedded Advanced Project Of Twinkling)"); serveMessage(418, "418. I'm a teapot.","(Tangible Embedded Advanced Project Of Twinkling)",254);
}); });
server.on("/build", HTTP_GET, [](){ server.on("/build", HTTP_GET, [](){
@ -181,8 +189,8 @@ void wledInit()
#else #else
info += "platform: esp8266\r\n"; info += "platform: esp8266\r\n";
#endif #endif
info += "name: " + versionName + "\r\n"; info += "version: " + versionString + "\r\n";
info += "version: " + (String)VERSION + "\r\n"; info += "build: " + (String)VERSION + "\r\n";
info += "eepver: " + String(EEPVER) + "\r\n"; info += "eepver: " + String(EEPVER) + "\r\n";
#ifdef RGBW #ifdef RGBW
info += "rgbw: true\r\n"; info += "rgbw: true\r\n";
@ -236,19 +244,19 @@ void wledInit()
} else } else
{ {
server.on("/edit", HTTP_GET, [](){ server.on("/edit", HTTP_GET, [](){
serveMessage(500, "Access Denied", txd); serveMessage(500, "Access Denied", txd, 254);
}); });
server.on("/down", HTTP_GET, [](){ server.on("/down", HTTP_GET, [](){
serveMessage(500, "Access Denied", txd); serveMessage(500, "Access Denied", txd, 254);
}); });
server.on("/cleareeprom", HTTP_GET, [](){ server.on("/cleareeprom", HTTP_GET, [](){
serveMessage(500, "Access Denied", txd); serveMessage(500, "Access Denied", txd, 254);
}); });
server.on("/update", HTTP_GET, [](){ server.on("/update", HTTP_GET, [](){
serveMessage(500, "Access Denied", txd); serveMessage(500, "Access Denied", txd, 254);
}); });
server.on("/list", HTTP_GET, [](){ server.on("/list", HTTP_GET, [](){
serveMessage(500, "Access Denied", txd); serveMessage(500, "Access Denied", txd, 254);
}); });
} }
//called when the url is not defined here, ajax-in; get-settings //called when the url is not defined here, ajax-in; get-settings
@ -313,7 +321,7 @@ void initAP(){
void initCon() void initCon()
{ {
int fail_count = 0; int fail_count = 0;
if (clientssid.length() <1) fail_count = 33; if (clientssid.length() <1 || clientssid.equals("Your_Network_Here")) fail_count = apWaitTimeSecs*2;
WiFi.begin(clientssid.c_str(), clientpass.c_str()); WiFi.begin(clientssid.c_str(), clientpass.c_str());
while(WiFi.status() != WL_CONNECTED) { while(WiFi.status() != WL_CONNECTED) {
delay(500); delay(500);
@ -332,31 +340,37 @@ void initCon()
void buildCssColorString() void buildCssColorString()
{ {
String cs[]={"","","","","",""};
switch (currentTheme) switch (currentTheme)
{ {
default: cssCol[0]="D9B310"; cssCol[1]="0B3C5D"; cssCol[2]="1D2731"; cssCol[3]="328CC1"; cssCol[4]="000"; break; //night default: cs[0]="D9B310"; cs[1]="0B3C5D"; cs[2]="1D2731"; cs[3]="328CC1"; cs[4]="000"; cs[5]="328CC1"; break; //night
case 1: cssCol[0]="eee"; cssCol[1]="ddd"; cssCol[2]="b9b9b9"; cssCol[3]="049"; cssCol[4]="777"; break; //modern case 1: cs[0]="eee"; cs[1]="ddd"; cs[2]="b9b9b9"; cs[3]="049"; cs[4]="777"; cs[5]="049"; break; //modern
case 2: cssCol[0]="abc"; cssCol[1]="fff"; cssCol[2]="ddd"; cssCol[3]="000"; cssCol[4]="0004"; break; //bright case 2: cs[0]="abc"; cs[1]="fff"; cs[2]="ddd"; cs[3]="000"; cs[4]="0004"; cs[5]="000"; break; //bright
case 3: cssCol[0]="c09f80"; cssCol[1]="d7cec7"; cssCol[2]="76323f"; cssCol[3]="888"; cssCol[4]="3334"; break; //wine case 3: cs[0]="c09f80"; cs[1]="d7cec7"; cs[2]="76323f"; cs[3]="888"; cs[4]="3334"; cs[5]="888"; break; //wine
case 4: cssCol[0]="3cc47c"; cssCol[1]="828081"; cssCol[2]="d9a803"; cssCol[3]="1e392a"; cssCol[4]="000a"; break; //electric case 4: cs[0]="3cc47c"; cs[1]="828081"; cs[2]="d9a803"; cs[3]="1e392a"; cs[4]="000a"; cs[5]="1e392a"; break; //electric
case 5: cssCol[0]="57bc90"; cssCol[1]="a5a5af"; cssCol[2]="015249"; cssCol[3]="88c9d4"; cssCol[4]="0004"; break; //mint case 5: cs[0]="57bc90"; cs[1]="a5a5af"; cs[2]="015249"; cs[3]="88c9d4"; cs[4]="0004"; cs[5]="88c9d4"; break; //mint
case 6: cssCol[0]="f7c331"; cssCol[1]="dcc7aa"; cssCol[2]="6b7a8f"; cssCol[3]="f7882f"; cssCol[4]="0007"; break; //amber case 6: cs[0]="f7c331"; cs[1]="dcc7aa"; cs[2]="6b7a8f"; cs[3]="f7882f"; cs[4]="0007"; cs[5]="f7882f"; break; //amber
case 7: cssCol[0]="fc3"; cssCol[1]="124"; cssCol[2]="334"; cssCol[3]="f1d"; cssCol[4]="f00"; break; //club case 7: cs[0]="fc3"; cs[1]="124"; cs[2]="334"; cs[3]="f1d"; cs[4]="f00"; cs[5]="f1d"; break;//club
case 14: cssCol[0]="fc7"; cssCol[1]="49274a"; cssCol[2]="94618e"; cssCol[3]="f4decb"; cssCol[4]="0008"; break; //end case 8: cs[0]="0ac"; cs[1]="124"; cs[2]="224"; cs[3]="003eff"; cs[4]="003eff"; cs[5]="003eff"; break;//air
//case 15 do nothing since custom vals are already loaded case 9: cs[0]="f70"; cs[1]="421"; cs[2]="221"; cs[3]="a50"; cs[4]="f70"; cs[5]="f70"; break;//nixie
case 10: cs[0]="2d2"; cs[1]="010"; cs[2]="121"; cs[3]="060"; cs[4]="040"; cs[5]="3f3"; break; //terminal
case 14: cs[0]="fc7"; cs[1]="49274a"; cs[2]="94618e"; cs[3]="f4decb"; cs[4]="0008"; cs[5]="f4decb"; break; //end
case 15: for (int i=0;i<6;i++)cs[i]=cssCol[i];//custom
} }
cssColorString="<style>:root{--aCol:#"; cssColorString="<style>:root{--aCol:#";
cssColorString+=cssCol[0]; cssColorString+=cs[0];
cssColorString+=";--bCol:#"; cssColorString+=";--bCol:#";
cssColorString+=cssCol[1]; cssColorString+=cs[1];
cssColorString+=";--cCol:#"; cssColorString+=";--cCol:#";
cssColorString+=cssCol[2]; cssColorString+=cs[2];
cssColorString+=";--dCol:#"; cssColorString+=";--dCol:#";
cssColorString+=cssCol[3]; cssColorString+=cs[3];
cssColorString+=";--sCol:#"; cssColorString+=";--sCol:#";
cssColorString+=cssCol[4]; cssColorString+=cs[4];
cssColorString+=";--tCol:#"; cssColorString+=";--tCol:#";
cssColorString+=cssCol[5]; cssColorString+=cs[5];
cssColorString+=";--cFn:";
cssColorString+=cssFont;
cssColorString+=";}"; cssColorString+=";}";
} }
@ -376,18 +390,27 @@ void serveIndex()
} }
} }
void serveMessage(int code, String headl, String subl="", bool backToSettings) void serveMessage(int code, String headl, String subl="", int optionType)
{ {
String messageBody = "<h2>"; String messageBody = "<h2>";
messageBody += headl; messageBody += headl;
messageBody += "</h2>"; messageBody += "</h2>";
messageBody += subl; messageBody += subl;
if (backToSettings) switch(optionType)
{ {
messageBody += "<form action=/settings><button type=submit>Back</button></form>"; case 255: break; //simple message
}else case 254: messageBody += "<br><br><button type=\"button\" onclick=\"B()\">Back</button>"; break; //back button
case 253: messageBody += "<br><br><form action=/settings><button type=submit>Back</button></form>"; //button to settings
}
if (optionType < 60) //redirect to settings after optionType seconds
{ {
messageBody += "<br><br><button type=\"button\" onclick=\"B()\">Back</button>"; messageBody += "<script>setTimeout(RS," + String(optionType*1000) + ")</script>";
} else if (optionType < 120) //redirect back after optionType-60 seconds
{
messageBody += "<script>setTimeout(B," + String((optionType-60)*1000) + ")</script>";
} else if (optionType < 180) //reload parent after optionType-120 seconds
{
messageBody += "<script>setTimeout(RP," + String((optionType-120)*1000) + ")</script>";
} }
messageBody += "</body></html>"; messageBody += "</body></html>";
server.setContentLength(strlen_P(PAGE_msg0) + cssColorString.length() + strlen_P(PAGE_msg1) + messageBody.length()); server.setContentLength(strlen_P(PAGE_msg0) + cssColorString.length() + strlen_P(PAGE_msg1) + messageBody.length());

View File

@ -46,36 +46,39 @@ void handleNotifications()
{ {
if(udpConnected && receiveNotifications){ if(udpConnected && receiveNotifications){
int packetSize = notifierUdp.parsePacket(); int packetSize = notifierUdp.parsePacket();
if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) if(packetSize && notifierUdp.remoteIP() != WiFi.localIP()) //don't process broadcasts we send ourselves
{ {
notifierUdp.read(udpIn, packetSize); notifierUdp.read(udpIn, packetSize);
if (udpIn[0] == 0 && !arlsTimeout) //wled notifier, block if realtime packets active if (udpIn[0] == 0 && !arlsTimeout) //wled notifier, block if realtime packets active
{ {
if (receiveNotificationColor)
{
col[0] = udpIn[3]; col[0] = udpIn[3];
col[1] = udpIn[4]; col[1] = udpIn[4];
col[2] = udpIn[5]; col[2] = udpIn[5];
if (udpIn[11] > 1)
{
col_sec[0] = udpIn[12];
col_sec[1] = udpIn[13];
col_sec[2] = udpIn[14];
white_sec = udpIn[15];
} }
if (udpIn[11] > 0) //check if sending modules white val is inteded if (udpIn[11] > 0 && receiveNotificationColor) //check if sending modules white val is inteded
{ {
white = udpIn[10]; white = udpIn[10];
if (udpIn[11] > 1 )
{
col_sec[0] = udpIn[12];
col_sec[1] = udpIn[13];
col_sec[2] = udpIn[14];
white_sec = udpIn[15];
}
} }
if (udpIn[8] != effectCurrent) if (udpIn[8] != effectCurrent && receiveNotificationEffects)
{ {
effectCurrent = udpIn[8]; effectCurrent = udpIn[8];
strip.setMode(effectCurrent); strip.setMode(effectCurrent);
} }
if (udpIn[9] != effectSpeed) if (udpIn[9] != effectSpeed && receiveNotificationEffects)
{ {
effectSpeed = udpIn[9]; effectSpeed = udpIn[9];
strip.setSpeed(effectSpeed); strip.setSpeed(effectSpeed);
} }
if (udpIn[11] > 3 && udpIn[16] != effectIntensity) if (udpIn[11] > 3 && udpIn[16] != effectIntensity && receiveNotificationEffects)
{ {
effectSpeed = udpIn[16]; effectSpeed = udpIn[16];
strip.setIntensity(effectIntensity); strip.setIntensity(effectIntensity);
@ -83,7 +86,7 @@ void handleNotifications()
nightlightActive = udpIn[6]; nightlightActive = udpIn[6];
if (!nightlightActive) if (!nightlightActive)
{ {
bri = udpIn[2]; if (receiveNotificationBrightness) bri = udpIn[2];
colorUpdated(3); colorUpdated(3);
} }
} else if (udpIn[0] == 1) //warls } else if (udpIn[0] == 1) //warls