Major parts of rework complete

pull/46/head
cschwinne 2018-02-20 22:29:48 +01:00
rodzic 30ee42732e
commit 76dd7b63fb
24 zmienionych plików z 1294 dodań i 470 usunięć

Wyświetl plik

@ -246,7 +246,7 @@ void WS2812FX::mode_static(void) {
/*
* Normal blinking. 50% on/off time.
* Normal blinking. on/off duty time set by FX intensity.
*/
void WS2812FX::mode_blink(void) {
if(_counter_mode_call % 2 == 1) {
@ -254,16 +254,15 @@ void WS2812FX::mode_blink(void) {
if (!_locked[i])
setPixelColor(i, _color);
}
show();
_mode_delay = (100 + ((1986 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX))*(float)(_intensity/128.0);
} else {
for(uint16_t i=0; i < _led_count; i++) {
if (!_locked[i])
setPixelColor(i, _color_sec);
}
show();
_mode_delay = (100 + ((1986 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX))*(float)(2.0-(_intensity/128.0));
}
_mode_delay = 100 + ((1986 * (uint32_t)(SPEED_MAX - _speed)) / SPEED_MAX);
show();
}
@ -342,12 +341,11 @@ void WS2812FX::mode_single_dynamic(void) {
/*
* Lights every LED in a random color. Changes all LED at the same time
* to new random colors.
* Lights multiple random leds in a random color (higher intensity, more updates)
*/
void WS2812FX::mode_multi_dynamic(void) {
for(uint16_t i=0; i < _led_count; i++) {
if (!_locked[i])
if (!_locked[i] && random(256)<=_intensity)
setPixelColor(i, color_wheel(random(256)));
}
show();
@ -493,7 +491,7 @@ void WS2812FX::mode_rainbow(void) {
void WS2812FX::mode_rainbow_cycle(void) {
for(uint16_t i=0; i < _led_count; i++) {
if (!_locked[i])
setPixelColor(i, color_wheel(((i * 256 / _led_count) + _counter_mode_step) % 256));
setPixelColor(i, color_wheel(((i * 256 / ((uint16_t)(_led_count*(float)(_intensity/128.0))+1)) + _counter_mode_step) % 256));
}
show();

Wyświetl plik

@ -56,10 +56,12 @@
} else {
uwv = false;
}
if (d.activeElement != Cf.TX) Cf.TX.selectedIndex = this.responseXML.getElementsByTagName('fx')[0].childNodes[0].nodeValue;
Cf.TX.selectedIndex = this.responseXML.getElementsByTagName('fx')[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;
nla = (this.responseXML.getElementsByTagName('nl')[0].innerHTML)!=0?true:false;
d.Cf.SN.value = this.responseXML.getElementsByTagName('nd')[0].childNodes[0].nodeValue;
d.Cf.ST.value = this.responseXML.getElementsByTagName('nt')[0].childNodes[0].nodeValue;
nState = 0;
nState = (this.responseXML.getElementsByTagName('nr')[0].innerHTML)!=0?1:0;
nState += (this.responseXML.getElementsByTagName('ns')[0].innerHTML)!=0?2:0;
@ -332,11 +334,11 @@
</script>
<style>
:root {
--aCol: #D9B310;
--bCol: #0B3C5D;
--cCol: #1D2731;
--dCol: #328CC1;
--sCol: #000;
--aCol: #0ac;
--bCol: #124;
--cCol: #334;
--dCol: #288;
--sCol: #003eff;
}
.ctrl_box {
margin: auto;

Wyświetl plik

@ -15,15 +15,6 @@
--dCol: #328CC1;
--sCol: #000;
}
body {
font-family: Verdana, Helvetica, sans-serif;
text-align: center;
background: var(--cCol);
color: var(--dCol);
line-height: 200%;
margin: 0;
background-attachment: fixed;
}
button {
background: var(--bCol);
color: var(--dCol);
@ -34,6 +25,15 @@
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>
</head>
<body>

Wyświetl plik

@ -31,11 +31,11 @@
</style>
</head>
<body>
<form action="/settings/wifi" method="post"><button type="submit">WiFi Setup</button></form>
<form action="/settings/leds" method="post"><button type="submit">LED Preferences</button></form>
<form action="/settings/ui" method="post"><button type="submit">User Interface</button></form>
<form action="/settings/sync" method="post"><button type="submit">Sync Interfaces</button></form>
<form action="/settings/time" method="post"><button type="submit">Time & Macros</button></form>
<form action="/settings/sec" method="post"><button type="submit">Security & Updates</button></form>
<form action="/settings/wifi"><button type="submit">WiFi Setup</button></form>
<form action="/settings/leds"><button type="submit">LED Preferences</button></form>
<form action="/settings/ui"><button type="submit">User Interface</button></form>
<form action="/settings/sync"><button type="submit">Sync Interfaces</button></form>
<form action="/settings/time"><button type="submit">Time & Macros</button></form>
<form action="/settings/sec"><button type="submit">Security & Updates</button></form>
</body>
</html>

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,20 @@
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;

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1,17 +1,346 @@
/*
* Settings html
*/
const char PAGE_settings0[] 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>
)=====";
const char PAGE_settings0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>WLED Settings</title>
)=====";
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>
</head>
<body>
<form action=/settings/wifi><button type=submit>WiFi Setup</button></form>
<form action=/settings/leds><button type=submit>LED Preferences</button></form>
<form action=/settings/ui><button type=submit>User Interface</button></form>
<form action=/settings/sync><button type=submit>Sync Interfaces</button></form>
<form action=/settings/time><button type=submit>Time & Macros</button></form>
<form action=/settings/sec><button type=submit>Security & Updates</button></form>
</body>
</html>
)=====";
const char PAGE_settings_wifi0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>WiFi Settings</title><script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#wifi-settings");}function B(){window.history.back();}function GetV(){var d = document;
)=====";
const char PAGE_settings_wifi1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>WiFi setup</h2>
<h3>Connect to existing network</h3>
Network name (SSID, empty to not connect): <br><input name="CSSID" maxlength="32"> <br>
Network password: <br> <input type="password" name="CPASS" maxlength="63"> <br>
Static IP (leave at 0.0.0.0 for DHCP): <br>
<input name="CSIP0" type="number" min="0" max="255" required> .
<input name="CSIP1" type="number" min="0" max="255" required> .
<input name="CSIP2" type="number" min="0" max="255" required> .
<input name="CSIP3" type="number" min="0" max="255" required> <br>
Static gateway: <br>
<input name="CSGW0" type="number" min="0" max="255" required> .
<input name="CSGW1" type="number" min="0" max="255" required> .
<input name="CSGW2" type="number" min="0" max="255" required> .
<input name="CSGW3" type="number" min="0" max="255" required> <br>
Static subnet mask: <br>
<input name="CSSN0" type="number" min="0" max="255" required> .
<input name="CSSN1" type="number" min="0" max="255" required> .
<input name="CSSN2" type="number" min="0" max="255" required> .
<input name="CSSN3" type="number" min="0" max="255" required> <br>
mDNS address (leave empty for no mDNS): <br/>
http:// <input name="CMDNS" maxlength="32"> .local <br>
Try connecting before opening AP for: <input name="APWTM" type="number" min="0" max="255" required> s <br>
Client IP: <span class="sip"> Not connected </span> <br>
<h3>Configure Access Point</h3>
AP SSID (leave empty for no AP): <br> <input name="APSSID" maxlength="32"> <br>
Hide AP name: <input type="checkbox" name="APHSSID"> <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>
AP IP: <span class="sip"> Not active </span> <hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body>
</html>
)=====";
const char PAGE_settings_leds0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<title>LED Settings</title><script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");}function B(){window.history.back();}function GetV(){var d = document;
)=====";
const char PAGE_settings_leds1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>LED setup</h2>
LED count (max. 255): <input name="LEDCN" type="number" min="1" max="255" required> <br>
<i>The default boot color is always saved in preset slot 0.</i><br>
Alternatively, apply preset <input name="BOOTP" type="number" min="0" max="25" required> at boot<br>
Default RGB color:
<input name="CLDFR" type="number" min="0" max="255" required>
<input name="CLDFG" type="number" min="0" max="255" required>
<input name="CLDFB" type="number" min="0" max="255" required> <br>
Default brightness: <input name="CLDFA" type="number" min="0" max="255" required> (0-255) <br>
Default white value (only RGBW, -1 to disable): <input name="CLDFW" type="number" min="-1" max="255" required> <br>
Default effect ID: <input name="FXDEF" type="number" min="0" max="57" required> <br>
Default effect speed: <input name="SXDEF" type="number" min="0" max="255" required> <br>
Default effect intensity: <input name="IXDEF" type="number" min="0" max="255" required> <br>
Default secondary RGB(W):<br>
<input name="CSECR" type="number" min="0" max="255" required>
<input name="CSECG" type="number" min="0" max="255" required>
<input name="CSECB" type="number" min="0" max="255" required>
<input name="CSECW" type="number" min="0" max="255" required><br>
Ignore and use current color, brightness and effects: <input type="checkbox" name="CBEOR"> <br>
Turn on after power up/reset: <input type="checkbox" name="BOOTN"> <br>
Use Gamma correction for brightness: <input type="checkbox" name="GCBRI"> <br>
Use Gamma correction for color: <input type="checkbox" name="GCRGB"> <br>
Brightness factor: <input name="NRBRI" type="number" min="0" max="255" required> %
<h3>Transitions</h3>
Fade: <input type="checkbox" name="TFADE"><br>
Sweep: <input type="checkbox" name="TSWEE"> Invert direction: <input type="checkbox" name="TSDIR"><br>
Transition Delay: <input name="TDLAY" maxlength="5" size="2"> ms
<h3>Timed light</h3>
Default Duration: <input name="TLDUR" type="number" min="1" max="255" required> min<br>
Default Target brightness: <input name="TLBRI" type="number" min="0" max="255" required><br>
Fade down: <input type="checkbox" name="TLFDE"><br>
<h3>Advanced</h3>
Default overlay ID: <input name="OLDEF" type="number" min="0" max="255" required> <br>
WARLS offset: <input name="WOFFS" type="number" min="-255" max="255" required><hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body>
</html>
)=====";
/*
* Settings set html
*/
const char PAGE_msg[] PROGMEM = R"=====(
const char PAGE_settings_ui0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<title>UI Settings</title><script>
function gId(s){return document.getElementById(s);}function S(){GetV();Ct();}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#user-interface-settings");}function B(){window.history.back();}function Ct(){if (gId("co").selected){gId("cth").style.display="block";}else{gId("cth").style.display="none";}}function GetV(){var d = document;
)=====";
const char PAGE_settings_ui1[] PROGMEM = R"=====(
</head>
<body onload="S()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>Web Setup</h2>
Server description: <input name="DESC" maxlength="32"><br>
Use HSB sliders instead of RGB by default: <input type="checkbox" name="COLMD"><br>
Color Theme:
<select name="THEME" onchange="Ct()">
<option value="0" selected>Night</option>
<option value="1">Modern</option>
<option value="2">Bright</option>
<option value="3">Wine</option>
<option value="4">Electric</option>
<option value="5">Mint</option>
<option value="6">Amber</option>
<option value="7">Club</option>
<option value="8">Air</option>
<option value="9">Coookie</option>
<option value="10">Unused</option>
<option value="11">Unused</option>
<option value="12">Unused</option>
<option value="13">Unused</option>
<option value="14">The End</option>
<option value="15" id="co">Custom</option>
</select><br>
<div id="cth">
Please specify your custom hex colors (e.g. #FF0000 for red)<br>
Custom accent color: <input maxlength=9 name="CCOL0"><br>
Custom background: <input maxlength=9 name="CCOL1"><br>
Custom panel color: <input maxlength=9 name="CCOL2"><br>
Custom text color: <input maxlength=9 name="CCOL3"><br>
Custom shadow: <input maxlength=9 name="CCOL4"><br></div>
<hr><button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body>
</html>
)=====";
const char PAGE_settings_sync0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head><title>Sync Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings");}function B(){window.open("/settings","_self");}function GetV(){var d = document;
)=====";
const char PAGE_settings_sync1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>Sync setup</h2>
<h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BTNON">
<h3>WLED Broadcast</h3>
UDP Port: <input name="NUDPP" maxlength="5" size="2"><br>
Receive <input type="checkbox" name="NRCBR">Brightness, <input type="checkbox" name="NRCCL">Color, and <input type="checkbox" name="NRCFX">Effects<br>
Send notifications on direct change: <input type="checkbox" name="NSDIR"> <br>
Send notifications on button press: <input type="checkbox" name="NSBTN"> <br>
Send Alexa notifications: <input type="checkbox" name="NSALX"> <br>
<!--Send Philips Hue change notifications: <input type="checkbox" name="NSHUE">-->
<h3>Alexa Voice Assistant</h3>
Emulate Alexa device: <input type="checkbox" name="ALEXA"> <br>
Alexa invocation name: <input name="AINVN" maxlength="32"><br>
<h3>Philips Hue</h3>
Coming soon! Not yet implemented!
<!--<i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br>
Hue Bridge IP:<br>
<input name="HUIP0" type="number" min="0" max="255" required> .
<input name="HUIP1" type="number" min="0" max="255" required> .
<input name="HUIP2" type="number" min="0" max="255" required> .
<input name="HUIP3" type="number" min="0" max="255" required> <br>
<b>For successful pairing, press the pushlink button on the bridge, then save this page!</b><br>
(when first connecting)<br>
<i> Use 0 for group and light to turn off sending/receiving </i><br>
Update Hue group <input name="HUEGR" type="number" min="0" max="99" required> <br>
Send <input type="checkbox" name="HUEIO"> On/Off, <input type="checkbox" name="HUEBR"> Brightness, and <input type="checkbox" name="HUECL"> Color<br>
Poll Hue light <input name="HUELI" type="number" min="0" max="99" required> every <input name="HUEPL" type="number" min="100" max="62000" required> ms<br>
Then, receive <input type="checkbox" name="HURIO"> On/Off, <input type="checkbox" name="HURBR"> Brightness, and <input type="checkbox" name="HURCL"> Color<br>
After device color update, ignore Hue updates for <input name="HUELI" type="number" min="0" max="255" required> minutes<br>
Hue status: <span class="hms"> Internal ESP error! </span>-->
<hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body>
</html>
)=====";
const char PAGE_settings_time0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head><title>Time Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#time-settings");}function B(){window.open("/settings","_self");}function GetV(){var d = document;
)=====";
const char PAGE_settings_time1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>Time setup</h2>
Requires reboot. <br>
Get time from NTP server: <input type="checkbox" name="NTPON"><br>
NTP server: <input name="NTPSR" maxlength="32"><br>
Time zone:
<select name="TZONE">
<option value="1" selected>GMT(UTC)</option>
<option value="2">GMT/BST</option>
<option value="3">CET/CEST</option>
<option value="4">EET/EEST</option>
<option value="5">US-EST/EDT</option>
<option value="6">US-CST/CDT</option>
<option value="7">US-MST/MDT</option>
<option value="8">US-AZ</option>
<option value="9">US-PST/PDT</option>
<option value="10">CST(AWST)</option>
<option value="11">JST(KST)</option>
<option value="12">AEST/AEDT</option>
<option value="13">NZST/NZDT</option>
</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>
Current local time is <span class="times">unknown</span>.
<h3>Weather</h3>
Coming soon! Not yet implemented!
<!--Get yours on open weather API.<br>
City code: <input name="WCITY" maxlength="32"><br>
Change color depending on weather: <input type="checkbox" name="WCCOL"><br>
Daylight Emulation: <input type="checkbox" name="WDAYL"><br>
Reverse (turns on at sunset): <input type="checkbox" name="WREVL"><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>-->
<h3>Advanced Macros</h3>
Define API macros here:<br>
0: <input name="MCR00" maxlength="64"><br>
1: <input name="MCR01" maxlength="64"><br>
2: <input name="MCR02" maxlength="64"><br>
3: <input name="MCR03" maxlength="64"><br>
4: <input name="MCR04" maxlength="64"><br>
5: <input name="MCR05" maxlength="64"><br>
6: <input name="MCR06" maxlength="64"><br>
7: <input name="MCR07" maxlength="64"><br>
8: <input name="MCR08" maxlength="64"><br>
9: <input name="MCR09" maxlength="64"><br>
10: <input name="MCR10" maxlength="64"><br>
11: <input name="MCR11" maxlength="64"><br>
12: <input name="MCR12" maxlength="64"><br>
13: <input name="MCR13" maxlength="64"><br>
14: <input name="MCR14" maxlength="64"><br>
15: <input name="MCR15" maxlength="64"><br>
<br>
<i>Use -1 to use the default action instead of a macro</i><br>
<!--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>
<!--Emulate 2nd Alexa device:
Emulate 3rd Alexa device:-->
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>
<!--Sunrise Macro
Sunset Macro-->
Countdown-Over Macro: <input name="MCNTD" type="number" min="-1" max="15" required><br>
<hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body></html>
)=====";
const char PAGE_settings_sec0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<title>Misc Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings");}function B(){window.open("/settings","_self");}function U(){window.open("/update","_self");}function GetV(){var d = document;
)=====";
const char PAGE_settings_sec1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<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>
<h2>Security & Update setup</h2>
Enable OTA lock: <input type="checkbox" name="NOOTA"><br>
Passphrase: <input type="password" name="OPASS" maxlength="32"><br>
To enable OTA, for security reasons you need to also enter the correct password!<br>
The password may/should be changed when OTA is enabled.<br>
<b>Disable OTA when not in use, otherwise an attacker could reflash device software!</b><br>
<i>Settings on this page are only changable if OTA lock is disabled!</i><br>
Deny access to WiFi settings if locked: <input type="checkbox" name="OWIFI"><br><br>
Disable recovery AP: <input type="checkbox" name="NORAP"><br>
In case of a connection error there will be no wireless recovery possible!<br>
Completely disables all Access Point functions.<br><br>
Factory reset: <input type="checkbox" name="RESET"><br>
All EEPROM content (settings) will be erased.<br><br>
HTTP traffic is not encrypted. An attacker in the same network could intercept form data!
<h3>Software Update</h3>
<button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AROTA"><br>
<h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.5dev<br>
(c) 2016-2018 Christian Schwinne <br>
<i>Licensed under the MIT license</i><br><br>
<i>Uses libraries:</i><br>
<i>ESP8266/ESP32 Arduino Core</i><br>
<i>(ESP32) <a href="https://github.com/bbx10/WebServer_tng">WebServer_tng</a> by bbx10</i><br>
<i><a href="https://github.com/kitesurfer1404/WS2812FX">WS2812FX</a> by kitesurfer1404 (modified)</i><br>
<i><a href="https://github.com/JChristensen/Timezone">Timezone</a> library by JChristensen</i><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>
Server message: <span class="msg"> Response error! </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit" name="SUBM">Save</button>
</form>
</body>
</html>
)=====";

Wyświetl plik

@ -1,6 +1,44 @@
/*
* Various
*/
const char PAGE_msg0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>WLED Message</title>
<script>function B(){window.history.back()};</script>
)=====";
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>
</head>
<body>
)=====";
const char PAGE_welcome0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<title>WLED Welcome!</title>
)=====";
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);}
</style></head>
<body>
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol id="lnr-smile" viewBox="0 0 1024 1024"><path d="M486.4 1024c-129.922 0-252.067-50.594-343.936-142.464s-142.464-214.014-142.464-343.936c0-129.923 50.595-252.067 142.464-343.936s214.013-142.464 343.936-142.464c129.922 0 252.067 50.595 343.936 142.464s142.464 214.014 142.464 343.936-50.594 252.067-142.464 343.936c-91.869 91.87-214.014 142.464-343.936 142.464zM486.4 102.4c-239.97 0-435.2 195.23-435.2 435.2s195.23 435.2 435.2 435.2 435.2-195.23 435.2-435.2-195.23-435.2-435.2-435.2z"></path><path d="M332.8 409.6c-42.347 0-76.8-34.453-76.8-76.8s34.453-76.8 76.8-76.8 76.8 34.453 76.8 76.8-34.453 76.8-76.8 76.8zM332.8 307.2c-14.115 0-25.6 11.485-25.6 25.6s11.485 25.6 25.6 25.6 25.6-11.485 25.6-25.6-11.485-25.6-25.6-25.6z"></path><path d="M640 409.6c-42.349 0-76.8-34.453-76.8-76.8s34.451-76.8 76.8-76.8 76.8 34.453 76.8 76.8-34.451 76.8-76.8 76.8zM640 307.2c-14.115 0-25.6 11.485-25.6 25.6s11.485 25.6 25.6 25.6 25.6-11.485 25.6-25.6-11.485-25.6-25.6-25.6z"></path><path d="M486.4 870.4c-183.506 0-332.8-149.294-332.8-332.8 0-14.139 11.462-25.6 25.6-25.6s25.6 11.461 25.6 25.6c0 155.275 126.325 281.6 281.6 281.6s281.6-126.325 281.6-281.6c0-14.139 11.461-25.6 25.6-25.6s25.6 11.461 25.6 25.6c0 183.506-149.294 332.8-332.8 332.8z"></path></symbol>
</defs></svg>
<br><br>
<svg><use xlink:href="#lnr-smile"></use></svg>
<h1>Welcome to WLED!</h1>
<h3>Thank you for installing my application!</h3>
Take a quick look at the <a href="https://github.com/Aircoookie/WLED/wiki" target="_blank">wiki</a>!<br>
If you encounter a bug or have a question/feature suggestion, feel free to open a GitHub issue!<br><br>
<b>Next steps:</b><br><br>
Connect the module to your local WiFi <a href="/settings/wifi">here</a>!<br><br>
<i>Just trying this out in AP mode?</i> <a href="/sliders">Here are the controls.</a><br>
</body></html>
)=====";
/*
* SPIFFS editor html
*/
@ -11,7 +49,7 @@ eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js" type="text/javascript" charset="utf-8"></script></head><body onload="onBodyLoad();"><div id="uploader"></div><div id="tree"></div><div id="editor"></div><div id="preview" style="display:none;"></div><iframe id=download-frame style='display:none;'></iframe></body></html>
)=====";
#else
const char PAGE_edit[] PROGMEM = R"=====(SPIFFS disabled by firmware)=====";
const char PAGE_edit[] PROGMEM = R"=====(SPIFFS disabled)=====";
#endif
/*
* favicon

Wyświetl plik

@ -26,10 +26,11 @@
#include "src/dependencies/timezone/Timezone.h"
#include "htmls00.h"
#include "htmls01.h"
#include "htmls02.h"
#include "WS2812FX.h"
//version in format yymmddb (b = daily build)
#define VERSION 1801180
#define VERSION 1802193
const String versionName = "WLED 0.5dev";
//AP and OTA default passwords (change them!)
@ -37,7 +38,7 @@ String appass = "wled1234";
String otapass = "wledota";
//If you have an RGBW strip, also uncomment first line in WS2812FX.h!
boolean useRGBW = false;
bool useRGBW = false;
//overlays, needed for clocks etc.
#define USEOVERLAYS
@ -82,7 +83,8 @@ bool ntpEnabled = true;
#endif
//Default CONFIG
String serverDescription = "WLED 0.5dev";
String serverDescription = versionName;
uint8_t currentTheme = 0;
String clientssid = "Your_Network_Here";
String clientpass = "Dummy_Pass";
String cmdns = "led";
@ -98,26 +100,27 @@ IPAddress staticip(0, 0, 0, 0);
IPAddress staticgateway(0, 0, 0, 0);
IPAddress staticsubnet(255, 255, 255, 0);
IPAddress staticdns(8, 8, 8, 8); //only for NTP
boolean useHSB = false, useHSBDefault = false;
boolean turnOnAtBoot = true;
bool useHSB = false, useHSBDefault = false;
bool turnOnAtBoot = true;
uint8_t bootPreset = 0;
byte col_s[]{255, 159, 0};
byte col_sec_s[]{0, 0, 0};
byte white_s = 0;
byte white_sec_s = 0;
byte bri_s = 127;
uint8_t bri_nl = 0, bri_nls;
boolean fadeTransition = true;
boolean sweepTransition = false; boolean sweepDirection = true;
uint8_t nightlightTargetBri = 0, bri_nl_t;
bool fadeTransition = true;
bool sweepTransition = false, sweepDirection = true;
uint16_t transitionDelay = 1200;
boolean otaLock = true;
boolean onlyAP = false;
boolean buttonEnabled = true;
boolean notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false;
boolean receiveNotifications = true, receiveNotificationsDefault = true;
uint8_t bri_n = 100;
bool otaLock = true;
bool aOtaEnabled = true;
bool onlyAP = false;
bool buttonEnabled = true;
bool notifyDirect = true, notifyButton = true, notifyDirectDefault = true, alexaNotify = false, macroNotify = false;
bool receiveNotifications = true, receiveNotificationBrightness = true, receiveNotificlationColor = true, receiveNotificationEffects = true;
uint8_t briMultiplier = 100;
uint8_t nightlightDelayMins = 60;
boolean nightlightFade = true;
bool nightlightFade = true;
uint16_t udpPort = 21324;
uint8_t effectDefault = 0;
uint8_t effectSpeedDefault = 75;
@ -178,6 +181,8 @@ uint8_t effectSpeed = 75;
uint8_t effectIntensity = 128;
boolean udpConnected = false;
byte udpIn[1026];
String cssCol[]={"","","","","",""};
String cssColorString="";
//NTP stuff
boolean ntpConnected = false;
unsigned int ntpLocalPort = 2390;
@ -217,17 +222,16 @@ boolean arlsSign = true;
uint8_t auxTime = 0;
unsigned long auxStartTime;
boolean auxActive, auxActiveBefore;
boolean initialBoot = false;
boolean showWelcomePage = false;
boolean useGammaCorrectionBri = false;
boolean useGammaCorrectionRGB = true;
int arlsOffset = -22; //10: -22 assuming arls52
//alexa
//alexa udp
WiFiUDP UDP;
IPAddress ipMulti(239, 255, 255, 250);
unsigned int portMulti = 1900;
unsigned int localPort = 1900;
char packetBuffer[255];
String escapedMac;
@ -289,6 +293,10 @@ const uint8_t gamma8[] = {
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
String txd = "Please disable OTA Lock in security settings!";
void serveMessage(int,String,String,bool=false);
void down()
{
bri_t = 0;
@ -316,7 +324,7 @@ void loop() {
yield();
handleButton();
handleNetworkTime();
if (!otaLock) ArduinoOTA.handle();
if (!otaLock && aOtaEnabled) ArduinoOTA.handle();
#ifdef CRONIXIE
handleCronixie();
#endif

Wyświetl plik

@ -19,6 +19,10 @@ void saveSettingsToEEPROM()
{
clearEEPROM();
EEPROM.write(233, 233);
showWelcomePage = true;
} else
{
showWelcomePage = false;
}
for (int i = 0; i < 32; ++i)
@ -67,17 +71,17 @@ void saveSettingsToEEPROM()
EEPROM.write(247, col_s[1]);
EEPROM.write(248, col_s[2]);
EEPROM.write(249, bri_s);
EEPROM.write(250, receiveNotificationsDefault);
EEPROM.write(250, receiveNotificationBrightness);
EEPROM.write(251, fadeTransition);
EEPROM.write(253, (transitionDelay >> 0) & 0xFF);
EEPROM.write(254, (transitionDelay >> 8) & 0xFF);
EEPROM.write(255, bri_n);
EEPROM.write(255, briMultiplier);
//255,250,231,230,226 notifier bytes
for (int i = 256; i < 288; ++i)
{
EEPROM.write(i, otapass.charAt(i-256));
}
EEPROM.write(288, bri_nl);
EEPROM.write(288, nightlightTargetBri);
EEPROM.write(289, otaLock);
EEPROM.write(290, (udpPort >> 0) & 0xFF);
EEPROM.write(291, (udpPort >> 8) & 0xFF);
@ -123,6 +127,19 @@ void saveSettingsToEEPROM()
EEPROM.write(387, cc_fromEnd);
EEPROM.write(388, cc_step);
EEPROM.write(389, bootPreset);
EEPROM.write(390, aOtaEnabled);
EEPROM.write(391, receiveNotificationColor);
EEPROM.write(392, receiveNotificationEffects);
if (currentTheme == 15)
{
for (int k=0;k<6;k++){
for (int i = 900+k*8; i < (908+k*8); ++i)
{
EEPROM.write(i, cssCol[k].charAt(i-900));
}}
}
EEPROM.write(948,currentTheme);
EEPROM.commit();
}
@ -197,18 +214,17 @@ void loadSettingsFromEEPROM(bool first)
{
bri = 0; bri_last = bri_s;
}
receiveNotifications = EEPROM.read(250);
receiveNotificationsDefault = receiveNotifications;
receiveNotificationBrightness = EEPROM.read(250);
fadeTransition = EEPROM.read(251);
transitionDelay = ((EEPROM.read(253) << 0) & 0xFF) + ((EEPROM.read(254) << 8) & 0xFF00);
bri_n = EEPROM.read(255);
briMultiplier = EEPROM.read(255);
otapass = "";
for (int i = 256; i < 288; ++i)
{
if (EEPROM.read(i) == 0) break;
otapass += char(EEPROM.read(i));
}
bri_nl = EEPROM.read(288);
nightlightTargetBri = EEPROM.read(288);
otaLock = EEPROM.read(289);
udpPort = ((EEPROM.read(290) << 0) & 0xFF) + ((EEPROM.read(291) << 8) & 0xFF00);
serverDescription = "";
@ -261,12 +277,28 @@ void loadSettingsFromEEPROM(bool first)
}
if (lastEEPROMversion > 3) {
effectIntensityDefault = EEPROM.read(326); effectIntensity = effectIntensityDefault;
aOtaEnabled = EEPROM.read(390);
receiveNotificationColor = EEPROM.read(391);
receiveNotificationEffects = EEPROM.read(392);
}
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
bootPreset = EEPROM.read(389);
//favorite setting memory (25 slots/ each 20byte)
//400 - 899 reserved
currentTheme = EEPROM.read(948);
if (currentTheme == 15)
{
for (int k=0;k<6;k++){
for (int i = 900+k*8; i < (908+k*8); ++i)
{
if (EEPROM.read(i) == 0) break;
cssCol[k] += char(EEPROM.read(i));
}}
}
//custom macro memory (16 slots/ each 64byte)
//1024-2047 reserved

Wyświetl plik

@ -29,7 +29,13 @@ void XML_response()
resp = resp + receiveNotifications;
resp = resp + "</nr><nl>";
resp = resp + nightlightActive;
resp = resp + "</nl><fx>";
resp = resp + "</nl><nf>";
resp = resp + nightlightFade;
resp = resp + "</nf><nd>";
resp = resp + nightlightDelayMins;
resp = resp + "</nd><nt>";
resp = resp + nightlightTargetBri;
resp = resp + "</nt><fx>";
resp = resp + effectCurrent;
resp = resp + "</fx><sx>";
resp = resp + effectSpeed;
@ -46,7 +52,6 @@ void XML_response()
resp = resp + "</md><desc>";
resp = resp + serverDescription;
resp = resp + "</desc>";
//enable toolbar here
resp = resp + "</vs>";
server.send(200, "text/xml", resp);
}
@ -58,118 +63,147 @@ String getSettings(uint8_t subPage)
DEBUG_PRINTLN(subPage);
String resp = "";
if (subPage <1 || subPage >6) return resp;
String ds = "d.Sf.";
String dg = "d.getElementsByClassName";
String v = ".value=";
String c = ".checked=";
String ih = ".innerHTML=";
resp += ds + "CSSID" + v + "\"" + clientssid + "\";";
resp += ds + "CPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "CSIP0" + v + staticip[0] +";";
resp += ds + "CSIP1" + v + staticip[1] +";";
resp += ds + "CSIP2" + v + staticip[2] +";";
resp += ds + "CSIP3" + v + staticip[3] +";";
resp += ds + "CSGW0" + v + staticgateway[0] +";";
resp += ds + "CSGW1" + v + staticgateway[1] +";";
resp += ds + "CSGW2" + v + staticgateway[2] +";";
resp += ds + "CSGW3" + v + staticgateway[3] +";";
resp += ds + "CSSN0" + v + staticsubnet[0] +";";
resp += ds + "CSSN1" + v + staticsubnet[1] +";";
resp += ds + "CSSN2" + v + staticsubnet[2] +";";
resp += ds + "CSSN3" + v + staticsubnet[3] +";";
resp += ds + "CMDNS" + v + "\"" + cmdns + "\";";
resp += ds + "APWTM" + v + apWaitTimeSecs +";";
resp += ds + "APSSID" + v + "\"" + apssid + "\";";
resp += ds + "APHSSID" + c + aphide + ";";
resp += ds + "APPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "APCHAN" + v + apchannel +";";
resp += ds + "DESC" + v + "\"" + serverDescription + "\";";
resp += ds + "COLMD" + c + useHSBDefault + ";";
resp += ds + "LEDCN" + v + ledcount +";";
resp += ds + "CLDFR" + v + col_s[0] +";";
resp += ds + "CLDFG" + v + col_s[1] +";";
resp += ds + "CLDFB" + v + col_s[2] +";";
resp += ds + "CLDFA" + v + bri_s +";";
if (useRGBW) {
resp += ds + "CLDFW" + v + white_s +";";
} else {
resp += ds + "CLDFW" + v + "-1;";
if (subPage == 1) {
resp += ds + "CSSID" + v + "\"" + clientssid + "\";";
resp += ds + "CPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "CSIP0" + v + staticip[0] +";";
resp += ds + "CSIP1" + v + staticip[1] +";";
resp += ds + "CSIP2" + v + staticip[2] +";";
resp += ds + "CSIP3" + v + staticip[3] +";";
resp += ds + "CSGW0" + v + staticgateway[0] +";";
resp += ds + "CSGW1" + v + staticgateway[1] +";";
resp += ds + "CSGW2" + v + staticgateway[2] +";";
resp += ds + "CSGW3" + v + staticgateway[3] +";";
resp += ds + "CSSN0" + v + staticsubnet[0] +";";
resp += ds + "CSSN1" + v + staticsubnet[1] +";";
resp += ds + "CSSN2" + v + staticsubnet[2] +";";
resp += ds + "CSSN3" + v + staticsubnet[3] +";";
resp += ds + "CMDNS" + v + "\"" + cmdns + "\";";
resp += ds + "APWTM" + v + apWaitTimeSecs +";";
resp += ds + "APSSID" + v + "\"" + apssid + "\";";
resp += ds + "APHSSID" + c + aphide + ";";
resp += ds + "APPASS" + v + "\"";
for (int i = 0; i < clientpass.length(); i++)
{
resp += "*";
}
resp += "\";";
resp += ds + "APCHAN" + v + apchannel +";";
resp += dg + "(\"sip\")[0]" + ih + "\"";
if (!WiFi.localIP()[0] == 0)
{
resp += WiFi.localIP()[0];
resp += + ".";
resp += WiFi.localIP()[1];
resp += ".";
resp += WiFi.localIP()[2];
resp += ".";
resp += WiFi.localIP()[3];
} else
{
resp += "Not connected";
}
resp += "\";";
resp += dg + "(\"sip\")[1]" + ih + "\"";
if (!WiFi.softAPIP()[0] == 0)
{
resp += WiFi.softAPIP()[0];
resp += + ".";
resp += WiFi.softAPIP()[1];
resp += ".";
resp += WiFi.softAPIP()[2];
resp += ".";
resp += WiFi.softAPIP()[3];
} else
{
resp += "Not active";
}
resp += "\";";
}
resp += ds + "CSECR" + v + col_sec_s[0] +";";
resp += ds + "CSECG" + v + col_sec_s[1] +";";
resp += ds + "CSECB" + v + col_sec_s[2] +";";
resp += ds + "CSECW" + v + white_s +";";
resp += ds + "BOOTN" + c + turnOnAtBoot +";";
resp += ds + "BOOTP" + v + bootPreset +";";
resp += ds + "FXDEF" + v + effectDefault +";";
resp += ds + "SXDEF" + v + effectSpeedDefault +";";
resp += ds + "GCBRI" + c + useGammaCorrectionBri +";";
resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";";
resp += ds + "BTNON" + c + buttonEnabled +";";
resp += ds + "TFADE" + c + fadeTransition +";";
resp += ds + "TSWEE" + c + sweepTransition +";";
resp += ds + "TSDIR" + c + !sweepDirection +";";
resp += ds + "TDLAY" + v + transitionDelay +";";
resp += ds + "TLBRI" + v + bri_nl +";";
resp += ds + "TLDUR" + v + nightlightDelayMins +";";
resp += ds + "TLFDE" + c + nightlightFade +";";
resp += ds + "NUDPP" + v + udpPort +";";
resp += ds + "NRBRI" + v + bri_n +";";
resp += ds + "NRCVE" + c + receiveNotificationsDefault +";";
resp += ds + "NSDIR" + c + notifyDirectDefault +";";
resp += ds + "NSBTN" + c + notifyButton +";";
resp += ds + "NTPON" + c + ntpEnabled +";";
resp += ds + "ALEXA" + c + alexaEnabled +";";
resp += ds + "AINVN" + v + "\"" + alexaInvocationName + "\";";
resp += ds + "NSALX" + c + alexaNotify +";";
resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";";
resp += ds + "OLDEF" + v + overlayDefault +";";
resp += ds + "WOFFS" + v + arlsOffset +";";
resp += ds + "NOOTA" + c + otaLock +";";
resp += ds + "NORAP" + c + recoveryAPDisabled +";";
resp += dg + "(\"sip\")[0]" + ih + "\"";
if (!WiFi.localIP()[0] == 0)
{
resp += WiFi.localIP()[0];
resp += + ".";
resp += WiFi.localIP()[1];
resp += ".";
resp += WiFi.localIP()[2];
resp += ".";
resp += WiFi.localIP()[3];
} else
{
resp += "Not connected";
if (subPage == 2) {
resp += ds + "LEDCN" + v + ledcount +";";
resp += ds + "CLDFR" + v + col_s[0] +";";
resp += ds + "CLDFG" + v + col_s[1] +";";
resp += ds + "CLDFB" + v + col_s[2] +";";
resp += ds + "CLDFA" + v + bri_s +";";
if (useRGBW) {
resp += ds + "CLDFW" + v + white_s +";";
} else {
resp += ds + "CLDFW" + v + "-1;";
}
resp += ds + "CSECR" + v + col_sec_s[0] +";";
resp += ds + "CSECG" + v + col_sec_s[1] +";";
resp += ds + "CSECB" + v + col_sec_s[2] +";";
resp += ds + "CSECW" + v + white_s +";";
resp += ds + "BOOTN" + c + turnOnAtBoot +";";
resp += ds + "BOOTP" + v + bootPreset +";";
resp += ds + "FXDEF" + v + effectDefault +";";
resp += ds + "SXDEF" + v + effectSpeedDefault +";";
resp += ds + "GCBRI" + c + useGammaCorrectionBri +";";
resp += ds + "GCRGB" + c + useGammaCorrectionRGB +";";
resp += ds + "TFADE" + c + fadeTransition +";";
resp += ds + "TSWEE" + c + sweepTransition +";";
resp += ds + "TSDIR" + c + !sweepDirection +";";
resp += ds + "TDLAY" + v + transitionDelay +";";
resp += ds + "NRBRI" + v + briMultiplier +";";
resp += ds + "TLBRI" + v + nightlightTargetBri +";";
resp += ds + "TLDUR" + v + nightlightDelayMins +";";
resp += ds + "TLFDE" + c + nightlightFade +";";
resp += ds + "OLDEF" + v + overlayDefault +";";
resp += ds + "WOFFS" + v + arlsOffset +";";
}
resp += "\";";
resp += dg + "(\"sip\")[1]" + ih + "\"";
if (!WiFi.softAPIP()[0] == 0)
{
resp += WiFi.softAPIP()[0];
resp += + ".";
resp += WiFi.softAPIP()[1];
resp += ".";
resp += WiFi.softAPIP()[2];
resp += ".";
resp += WiFi.softAPIP()[3];
} else
{
resp += "Not active";
if (subPage == 3)
{
resp += ds + "DESC" + v + "\"" + serverDescription + "\";";
resp += ds + "COLMD" + c + useHSBDefault + ";";
resp += ds + "THEME.selectedIndex=" + String(currentTheme) + ";";
for(int i=0;i<5;i++)
resp += ds + "CCOL" + i + v + "\"" + cssCol[i] + "\";";
}
resp += "\";";
resp += dg + "(\"msg\")[0]" + ih + "\""+ versionName +" (build " + VERSION + ") OK\";";
if (subPage == 4)
{
resp += ds + "BTNON" + c + buttonEnabled +";";
resp += ds + "NUDPP" + v + udpPort +";";
resp += ds + "NRCBR" + c + receiveNotificationBrightness +";";
resp += ds + "NRCCL" + c + receiveNotificationColor +";";
resp += ds + "NRCFX" + c + receiveNotificationEffects +";";
resp += ds + "NSDIR" + c + notifyDirectDefault +";";
resp += ds + "NSBTN" + c + notifyButton +";";
resp += ds + "ALEXA" + c + alexaEnabled +";";
resp += ds + "AINVN" + v + "\"" + alexaInvocationName + "\";";
resp += ds + "NSALX" + c + alexaNotify +";";
}
if (subPage == 5)
{
resp += ds + "NTPON" + c + ntpEnabled +";";
resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";";
}
if (subPage == 6)
{
resp += ds + "NOOTA" + c + otaLock +";";
resp += ds + "AROTA" + c + aOtaEnabled +";";
resp += ds + "NORAP" + c + recoveryAPDisabled +";";
resp += dg + "(\"msg\")[0]" + ih + "\""+ versionName +" (build " + VERSION + ") OK\";";
}
resp += "}</script>";
return resp;
}

Wyświetl plik

@ -19,260 +19,302 @@ void _setRandomColor(bool _sec)
}
}
void handleSettingsSet()
void handleSettingsSet(uint8_t subPage)
{
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
if (server.hasArg("CPASS"))
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec
if (subPage <1 || subPage >6) return;
//WIFI SETTINGS
if (subPage == 1)
{
if (!server.arg("CPASS").indexOf('*') == 0)
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
if (server.hasArg("CPASS"))
{
DEBUG_PRINTLN("Setting pass");
clientpass = server.arg("CPASS");
}
}
if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS");
if (server.hasArg("APWTM"))
{
int i = server.arg("APWTM").toInt();
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
}
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
aphide = server.hasArg("APHSSID");
if (server.hasArg("APPASS"))
{
if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("APPASS");
}
if (server.hasArg("APCHAN"))
{
int chan = server.arg("APCHAN").toInt();
if (chan > 0 && chan < 14) apchannel = chan;
}
if (server.hasArg("RESET")) //might be dangerous in case arg is always sent
{
clearEEPROM();
server.send(200, "text/plain", "Settings erased. Rebooting...");
reset();
}
if (server.hasArg("CSIP0"))
{
int i = server.arg("CSIP0").toInt();
if (i >= 0 && i <= 255) staticip[0] = i;
}
if (server.hasArg("CSIP1"))
{
int i = server.arg("CSIP1").toInt();
if (i >= 0 && i <= 255) staticip[1] = i;
}
if (server.hasArg("CSIP2"))
{
int i = server.arg("CSIP2").toInt();
if (i >= 0 && i <= 255) staticip[2] = i;
}
if (server.hasArg("CSIP3"))
{
int i = server.arg("CSIP3").toInt();
if (i >= 0 && i <= 255) staticip[3] = i;
}
if (server.hasArg("CSGW0"))
{
int i = server.arg("CSGW0").toInt();
if (i >= 0 && i <= 255) staticgateway[0] = i;
}
if (server.hasArg("CSGW1"))
{
int i = server.arg("CSGW1").toInt();
if (i >= 0 && i <= 255) staticgateway[1] = i;
}
if (server.hasArg("CSGW2"))
{
int i = server.arg("CSGW2").toInt();
if (i >= 0 && i <= 255) staticgateway[2] = i;
}
if (server.hasArg("CSGW3"))
{
int i = server.arg("CSGW3").toInt();
if (i >= 0 && i <= 255) staticgateway[3] = i;
}
if (server.hasArg("CSSN0"))
{
int i = server.arg("CSSN0").toInt();
if (i >= 0 && i <= 255) staticsubnet[0] = i;
}
if (server.hasArg("CSSN1"))
{
int i = server.arg("CSSN1").toInt();
if (i >= 0 && i <= 255) staticsubnet[1] = i;
}
if (server.hasArg("CSSN2"))
{
int i = server.arg("CSSN2").toInt();
if (i >= 0 && i <= 255) staticsubnet[2] = i;
}
if (server.hasArg("CSSN3"))
{
int i = server.arg("CSSN3").toInt();
if (i >= 0 && i <= 255) staticsubnet[3] = i;
}
if (server.hasArg("DESC")) serverDescription = server.arg("DESC");
useHSBDefault = server.hasArg("COLMD");
useHSB = useHSBDefault;
if (server.hasArg("LEDCN"))
{
int i = server.arg("LEDCN").toInt();
if (i >= 0 && i <= LEDCOUNT) ledcount = i;
strip.setLedCount(ledcount);
}
if (server.hasArg("CBEOR")) //ignore settings and save current brightness, colors and fx as default
{
col_s[0] = col[0];
col_s[1] = col[1];
col_s[2] = col[2];
if (useRGBW) white_s = white;
bri_s = bri;
effectDefault = effectCurrent;
effectSpeedDefault = effectSpeed;
} else {
if (server.hasArg("CLDFR"))
{
int i = server.arg("CLDFR").toInt();
if (i >= 0 && i <= 255) col_s[0] = i;
}
if (server.hasArg("CLDFG"))
{
int i = server.arg("CLDFG").toInt();
if (i >= 0 && i <= 255) col_s[1] = i;
}
if (server.hasArg("CLDFB"))
{
int i = server.arg("CLDFB").toInt();
if (i >= 0 && i <= 255) col_s[2] = i;
}
if (server.hasArg("CSECR"))
{
int i = server.arg("CSECR").toInt();
if (i >= 0 && i <= 255) col_sec_s[0] = i;
}
if (server.hasArg("CSECG"))
{
int i = server.arg("CSECG").toInt();
if (i >= 0 && i <= 255) col_sec_s[1] = i;
}
if (server.hasArg("CSECB"))
{
int i = server.arg("CSECB").toInt();
if (i >= 0 && i <= 255) col_sec_s[2] = i;
}
if (server.hasArg("CSECW"))
{
int i = server.arg("CSECW").toInt();
if (i >= 0 && i <= 255) white_sec_s = i;
}
if (server.hasArg("CLDFW"))
{
int i = server.arg("CLDFW").toInt();
if (i >= 0 && i <= 255)
if (!server.arg("CPASS").indexOf('*') == 0)
{
useRGBW = true;
white_s = i;
} else {
useRGBW = false;
white_s = 0;
DEBUG_PRINTLN("Setting pass");
clientpass = server.arg("CPASS");
}
}
if (server.hasArg("CLDFA"))
if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS");
if (server.hasArg("APWTM"))
{
int i = server.arg("CLDFA").toInt();
if (i >= 0 && i <= 255) bri_s = i;
int i = server.arg("APWTM").toInt();
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
}
if (server.hasArg("FXDEF"))
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
aphide = server.hasArg("APHSSID");
if (server.hasArg("APPASS"))
{
int i = server.arg("FXDEF").toInt();
if (i >= 0 && i <= 255) effectDefault = i;
if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("APPASS");
}
if (server.hasArg("SXDEF"))
if (server.hasArg("APCHAN"))
{
int i = server.arg("SXDEF").toInt();
if (i >= 0 && i <= 255) effectSpeedDefault = i;
int chan = server.arg("APCHAN").toInt();
if (chan > 0 && chan < 14) apchannel = chan;
}
if (server.hasArg("CSIP0"))
{
int i = server.arg("CSIP0").toInt();
if (i >= 0 && i <= 255) staticip[0] = i;
}
if (server.hasArg("CSIP1"))
{
int i = server.arg("CSIP1").toInt();
if (i >= 0 && i <= 255) staticip[1] = i;
}
if (server.hasArg("CSIP2"))
{
int i = server.arg("CSIP2").toInt();
if (i >= 0 && i <= 255) staticip[2] = i;
}
if (server.hasArg("CSIP3"))
{
int i = server.arg("CSIP3").toInt();
if (i >= 0 && i <= 255) staticip[3] = i;
}
if (server.hasArg("CSGW0"))
{
int i = server.arg("CSGW0").toInt();
if (i >= 0 && i <= 255) staticgateway[0] = i;
}
if (server.hasArg("CSGW1"))
{
int i = server.arg("CSGW1").toInt();
if (i >= 0 && i <= 255) staticgateway[1] = i;
}
if (server.hasArg("CSGW2"))
{
int i = server.arg("CSGW2").toInt();
if (i >= 0 && i <= 255) staticgateway[2] = i;
}
if (server.hasArg("CSGW3"))
{
int i = server.arg("CSGW3").toInt();
if (i >= 0 && i <= 255) staticgateway[3] = i;
}
if (server.hasArg("CSSN0"))
{
int i = server.arg("CSSN0").toInt();
if (i >= 0 && i <= 255) staticsubnet[0] = i;
}
if (server.hasArg("CSSN1"))
{
int i = server.arg("CSSN1").toInt();
if (i >= 0 && i <= 255) staticsubnet[1] = i;
}
if (server.hasArg("CSSN2"))
{
int i = server.arg("CSSN2").toInt();
if (i >= 0 && i <= 255) staticsubnet[2] = i;
}
if (server.hasArg("CSSN3"))
{
int i = server.arg("CSSN3").toInt();
if (i >= 0 && i <= 255) staticsubnet[3] = i;
}
}
turnOnAtBoot = server.hasArg("BOOTN");
if (server.hasArg("BOOTP"))
//LED SETTINGS
if (subPage == 2)
{
int i = server.arg("BOOTP").toInt();
if (i >= 0 && i <= 25) bootPreset = i;
}
useGammaCorrectionBri = server.hasArg("GCBRI");
useGammaCorrectionRGB = server.hasArg("GCRGB");
buttonEnabled = server.hasArg("BTNON");
fadeTransition = server.hasArg("TFADE");
sweepTransition = server.hasArg("TSWEE");
sweepDirection = !server.hasArg("TSDIR");
if (server.hasArg("TDLAY"))
{
int i = server.arg("TDLAY").toInt();
if (i > 0){
transitionDelay = i;
if (server.hasArg("LEDCN"))
{
int i = server.arg("LEDCN").toInt();
if (i >= 0 && i <= LEDCOUNT) ledcount = i;
strip.setLedCount(ledcount);
}
if (server.hasArg("CBEOR")) //ignore settings and save current brightness, colors and fx as default
{
col_s[0] = col[0];
col_s[1] = col[1];
col_s[2] = col[2];
if (useRGBW) white_s = white;
bri_s = bri;
effectDefault = effectCurrent;
effectSpeedDefault = effectSpeed;
} else {
if (server.hasArg("CLDFR"))
{
int i = server.arg("CLDFR").toInt();
if (i >= 0 && i <= 255) col_s[0] = i;
}
if (server.hasArg("CLDFG"))
{
int i = server.arg("CLDFG").toInt();
if (i >= 0 && i <= 255) col_s[1] = i;
}
if (server.hasArg("CLDFB"))
{
int i = server.arg("CLDFB").toInt();
if (i >= 0 && i <= 255) col_s[2] = i;
}
if (server.hasArg("CSECR"))
{
int i = server.arg("CSECR").toInt();
if (i >= 0 && i <= 255) col_sec_s[0] = i;
}
if (server.hasArg("CSECG"))
{
int i = server.arg("CSECG").toInt();
if (i >= 0 && i <= 255) col_sec_s[1] = i;
}
if (server.hasArg("CSECB"))
{
int i = server.arg("CSECB").toInt();
if (i >= 0 && i <= 255) col_sec_s[2] = i;
}
if (server.hasArg("CSECW"))
{
int i = server.arg("CSECW").toInt();
if (i >= 0 && i <= 255) white_sec_s = i;
}
if (server.hasArg("CLDFW"))
{
int i = server.arg("CLDFW").toInt();
if (i >= 0 && i <= 255)
{
useRGBW = true;
white_s = i;
} else {
useRGBW = false;
white_s = 0;
}
}
if (server.hasArg("CLDFA"))
{
int i = server.arg("CLDFA").toInt();
if (i >= 0 && i <= 255) bri_s = i;
}
if (server.hasArg("FXDEF"))
{
int i = server.arg("FXDEF").toInt();
if (i >= 0 && i <= 255) effectDefault = i;
}
if (server.hasArg("SXDEF"))
{
int i = server.arg("SXDEF").toInt();
if (i >= 0 && i <= 255) effectSpeedDefault = i;
}
}
turnOnAtBoot = server.hasArg("BOOTN");
if (server.hasArg("BOOTP"))
{
int i = server.arg("BOOTP").toInt();
if (i >= 0 && i <= 25) bootPreset = i;
}
useGammaCorrectionBri = server.hasArg("GCBRI");
useGammaCorrectionRGB = server.hasArg("GCRGB");
buttonEnabled = server.hasArg("BTNON");
fadeTransition = server.hasArg("TFADE");
sweepTransition = server.hasArg("TSWEE");
sweepDirection = !server.hasArg("TSDIR");
if (server.hasArg("TDLAY"))
{
int i = server.arg("TDLAY").toInt();
if (i > 0){
transitionDelay = i;
}
}
if (server.hasArg("TLBRI"))
{
nightlightTargetBri = server.arg("TLBRI").toInt();
}
if (server.hasArg("TLDUR"))
{
int i = server.arg("TLDUR").toInt();
if (i > 0) nightlightDelayMins = i;
}
nightlightFade = server.hasArg("TLFDE");
if (server.hasArg("OLDEF"))
{
int i = server.arg("OLDEF").toInt();
if (i >= 0 && i <= 255) overlayDefault = i;
}
if (server.hasArg("WOFFS"))
{
int i = server.arg("WOFFS").toInt();
if (i >= -255 && i <= 255) arlsOffset = i;
arlsSign = (i>=0)?true:false;
}
if (server.hasArg("NRBRI"))
{
int i = server.arg("NRBRI").toInt();
if (i > 0) briMultiplier = i;
}
}
if (server.hasArg("TLBRI"))
//UI
if (subPage == 3)
{
bri_nl = server.arg("TLBRI").toInt();
if (server.hasArg("DESC")) serverDescription = server.arg("DESC");
useHSBDefault = server.hasArg("COLMD");
useHSB = useHSBDefault;
if (server.hasArg("THEME")) currentTheme = server.arg("THEME").toInt();
for(int i=0;i<5;i++)
{
if (server.hasArg(("CCOL"+i))) cssCol[i] = server.arg(("CCOL"+i));
}
buildCssColorString();
}
if (server.hasArg("TLDUR"))
//SYNC
if (subPage == 4)
{
int i = server.arg("TLDUR").toInt();
if (i > 0) nightlightDelayMins = i;
if (server.hasArg("NUDPP"))
{
udpPort = server.arg("NUDPP").toInt();
}
receiveNotificationBrightness = server.hasArg("NRCBR");
receiveNotificationColor = server.hasArg("NRCCL");
receiveNotificationEffects = server.hasArg("NRCFX");
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
notifyDirectDefault = server.hasArg("NSDIR");
notifyDirect = notifyDirectDefault;
notifyButton = server.hasArg("NSBTN");
alexaEnabled = server.hasArg("ALEXA");
if (server.hasArg("AINVN")) alexaInvocationName = server.arg("AINVN");
alexaNotify = server.hasArg("NSALX");
}
nightlightFade = server.hasArg("TLFDE");
if (server.hasArg("NUDPP"))
//TIME
if (subPage == 5)
{
udpPort = server.arg("NUDPP").toInt();
ntpEnabled = server.hasArg("NTPON");
}
receiveNotifications = server.hasArg("NRCVE");
receiveNotificationsDefault = receiveNotifications;
if (server.hasArg("NRBRI"))
{
int i = server.arg("NRBRI").toInt();
if (i > 0) bri_n = i;
}
notifyDirectDefault = server.hasArg("NSDIR");
notifyDirect = notifyDirectDefault;
notifyButton = server.hasArg("NSBTN");
alexaEnabled = server.hasArg("ALEXA");
if (server.hasArg("AINVN")) alexaInvocationName = server.arg("AINVN");
alexaNotify = server.hasArg("NSALX");
ntpEnabled = server.hasArg("NTPON");
if (server.hasArg("OLDEF"))
{
int i = server.arg("OLDEF").toInt();
if (i >= 0 && i <= 255) overlayDefault = i;
}
if (server.hasArg("WOFFS"))
{
int i = server.arg("WOFFS").toInt();
if (i >= -255 && i <= 255) arlsOffset = i;
arlsSign = (i>=0)?true:false;
}
if (server.hasArg("OPASS"))
//SECURITY
if (subPage == 6)
{
if (server.hasArg("RESET"))
{
clearEEPROM();
serveMessage(200, "All Settings erased.", "Rebooting...");
reset();
}
if (server.hasArg("OPASS"))
{
if (!otaLock)
{
if (server.arg("OPASS").length() > 0)
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 (server.arg("OPASS").length() > 0)
otapass = server.arg("OPASS");
} else if (!server.hasArg("NOOTA"))
{
if (otapass.equals(server.arg("OPASS")))
{
otaLock = false;
}
recoveryAPDisabled = server.hasArg("NORAP");
aOtaEnabled = server.hasArg("AROTA");
}
}
if (server.hasArg("NOOTA")) otaLock = true;
if (server.hasArg("NORAP")) {
if (!otaLock) recoveryAPDisabled = true;
} else {
recoveryAPDisabled = false;
}
saveSettingsToEEPROM();
}
@ -329,6 +371,7 @@ boolean handleSet(String req)
if (pos > 0) {
white = req.substring(pos + 3).toInt();
}
//set 2nd red value
pos = req.indexOf("R2=");
if (pos > 0) {
@ -349,6 +392,7 @@ boolean handleSet(String req)
if (pos > 0) {
white_sec = req.substring(pos + 3).toInt();
}
//set 2nd to white
pos = req.indexOf("SW");
if (pos > 0) {
@ -398,6 +442,7 @@ boolean handleSet(String req)
white = white_sec;
white_sec = _temp[3];
}
//set current effect index
pos = req.indexOf("FX=");
if (pos > 0) {
@ -418,6 +463,17 @@ boolean handleSet(String req)
effectUpdated = true;
}
}
//set effect intensity
pos = req.indexOf("IX=");
if (pos > 0) {
if (effectIntensity != req.substring(pos + 3).toInt())
{
effectIntensity = req.substring(pos + 3).toInt();
strip.setIntensity(effectIntensity);
effectUpdated = true;
}
}
//set default control mode (0 - RGB, 1 - HSB)
pos = req.indexOf("MD=");
if (pos > 0) {
@ -511,7 +567,7 @@ boolean handleSet(String req)
//set nightlight target brightness
pos = req.indexOf("NT=");
if (pos > 0) {
bri_nl = req.substring(pos + 3).toInt();
nightlightTargetBri = req.substring(pos + 3).toInt();
nightlightActive_old = false; //re-init
}
//toggle nightlight fade
@ -560,6 +616,7 @@ boolean handleSet(String req)
countdownTime = req.substring(pos+3).toInt();
if (countdownTime - now() > 0) countdownOverTriggered = false;
}
//set custom chase data
bool _cc_updated = false;
pos = req.indexOf("C0="); if (pos > 0) {cc_start = (req.substring(pos + 3).toInt()); _cc_updated = true;}

Wyświetl plik

@ -26,6 +26,7 @@ void wledInit()
loadSettingsFromEEPROM(true);
DEBUG_PRINT("CC: SSID: ");
DEBUG_PRINT(clientssid);
buildCssColorString();
WiFi.disconnect(); //close old connections
@ -71,59 +72,108 @@ void wledInit()
//SERVER INIT
//settings page
server.on("/settings", HTTP_GET, [](){
if (!arlsTimeout) //do not serve while receiving realtime
{
String settingsBuffer = getSettings();
server.setContentLength(strlen_P(PAGE_settings0) + strlen_P(PAGE_settings1) + settingsBuffer.length());
server.send(200, "text/html", "");
server.sendContent_P(PAGE_settings0);
server.sendContent(settingsBuffer);
server.sendContent_P(PAGE_settings1);
} else {
server.send(200, "text/plain", "The settings are not available while receiving real-time data.");
}
serveSettings(0);
});
server.on("/settings/wifi", HTTP_GET, [](){
serveSettings(1);
});
server.on("/settings/leds", HTTP_GET, [](){
serveSettings(2);
});
server.on("/settings/ui", HTTP_GET, [](){
serveSettings(3);
});
server.on("/settings/sync", HTTP_GET, [](){
serveSettings(4);
});
server.on("/settings/time", HTTP_GET, [](){
serveSettings(5);
});
server.on("/settings/sec", HTTP_GET, [](){
serveSettings(6);
});
server.on("/favicon.ico", HTTP_GET, [](){
if(!handleFileRead("/favicon.ico")) server.send(200, "image/x-icon", favicon);
});
server.on("/", HTTP_GET, [](){
if (!initialBoot){
if (!showWelcomePage){
if(!handleFileRead("/index.htm")) {
serveIndex();
}
}else{
if(!handleFileRead("/welcome.htm")) {
serveWelcomePage();
serveSettings(255);
}
}
});
server.on("/sliders", HTTP_GET, serveIndex)
server.on("/welcome", HTTP_GET, serveWelcomePage)
server.on("/sliders", HTTP_GET, serveIndex);
server.on("/welcome", HTTP_GET, [](){
serveSettings(255);
});
server.on("/reset", HTTP_GET, [](){
server.send(200, "text/plain", "Rebooting...");
serveMessage(200,"Rebooting now...","(takes ~15 seconds)");
reset();
});
server.on("/set-settings", HTTP_POST, [](){
handleSettingsSet();
if(!handleFileRead("/settingssaved.htm")) server.send(200, "text/html", PAGE_settingssaved);
server.on("/settings/wifi", HTTP_POST, [](){
handleSettingsSet(1);
serveMessage(200,"WiFi settings saved.","Rebooting now...");
reset();
});
server.on("/settings/leds", HTTP_POST, [](){
handleSettingsSet(2);
serveMessage(200,"LED settings saved.","",true);
});
server.on("/settings/ui", HTTP_POST, [](){
handleSettingsSet(3);
serveMessage(200,"UI settings saved.","",true);
});
server.on("/settings/sync", HTTP_POST, [](){
handleSettingsSet(4);
serveMessage(200,"Sync settings saved.","",true);
});
server.on("/settings/time", HTTP_POST, [](){
handleSettingsSet(5);
serveMessage(200,"Time settings saved.","If you made changes to NTP, please reboot.",true);
});
server.on("/settings/sec", HTTP_POST, [](){
handleSettingsSet(6);
serveMessage(200,"Security settings saved.","Rebooting now...");
reset();
});
server.on("/version", HTTP_GET, [](){
server.send(200, "text/plain", (String)VERSION);
});
server.on("/uptime", HTTP_GET, [](){
server.send(200, "text/plain", (String)millis());
});
server.on("/freeheap", HTTP_GET, [](){
server.send(200, "text/plain", (String)ESP.getFreeHeap());
});
server.on("/power", HTTP_GET, [](){
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!";
server.send(200, "text/plain", val);
});
server.on("/teapot", HTTP_GET, [](){
server.send(418, "text/plain", "418. I'm a teapot. (Tangible Embedded Advanced Project Of Twinkling)");
serveMessage(418, "418. I'm a teapot.","(Tangible Embedded Advanced Project Of Twinkling)");
});
server.on("/build", HTTP_GET, [](){
String info = "hard-coded build info:\r\n\n";
#ifdef ARDUINO_ARCH_ESP32
@ -183,30 +233,22 @@ void wledInit()
server.on("/cleareeprom", HTTP_GET, clearEEPROM);
//init ota page
httpUpdater.setup(&server);
//init ArduinoOTA
ArduinoOTA.onStart([]() {
#ifndef ARDUINO_ARCH_ESP32
wifi_set_sleep_type(NONE_SLEEP_T);
#endif
DEBUG_PRINTLN("Start ArduinoOTA");
});
ArduinoOTA.begin();
} else
{
server.on("/edit", HTTP_GET, [](){
server.send(500, "text/plain", "OTA lock active");
serveMessage(500, "Access Denied", txd);
});
server.on("/down", HTTP_GET, [](){
server.send(500, "text/plain", "OTA lock active");
serveMessage(500, "Access Denied", txd);
});
server.on("/cleareeprom", HTTP_GET, [](){
server.send(500, "text/plain", "OTA lock active");
serveMessage(500, "Access Denied", txd);
});
server.on("/update", HTTP_GET, [](){
server.send(500, "text/plain", "OTA lock active");
serveMessage(500, "Access Denied", txd);
});
server.on("/list", HTTP_GET, [](){
server.send(500, "text/plain", "OTA lock active");
serveMessage(500, "Access Denied", txd);
});
}
//called when the url is not defined here, ajax-in; get-settings
@ -216,7 +258,7 @@ void wledInit()
DEBUG_PRINTLN("Body: " + server.arg(0));
if(!handleSet(server.uri())){
if(!handleAlexaApiCall(server.uri(),server.arg(0)))
server.send(404, "text/plain", "FileNotFound");
server.send(404, "text/plain", "Not Found");
}
});
//init Alexa hue emulation
@ -227,6 +269,18 @@ void wledInit()
// Add service to MDNS
MDNS.addService("http", "tcp", 80);
//init ArduinoOTA
if (aOtaEnabled)
{
ArduinoOTA.onStart([]() {
#ifndef ARDUINO_ARCH_ESP32
wifi_set_sleep_type(NONE_SLEEP_T);
#endif
DEBUG_PRINTLN("Start ArduinoOTA");
});
ArduinoOTA.begin();
}
// Initialize NeoPixel Strip
strip.init();
strip.setLedCount(ledcount);
@ -278,16 +332,31 @@ void initCon()
void buildCssColorString()
{
cssColorString=":root{--aCol:";
switch (currentTheme)
{
default: cssCol[0]="D9B310"; cssCol[1]="0B3C5D"; cssCol[2]="1D2731"; cssCol[3]="328CC1"; cssCol[4]="000"; break; //night
case 1: cssCol[0]="eee"; cssCol[1]="ddd"; cssCol[2]="b9b9b9"; cssCol[3]="049"; cssCol[4]="777"; break; //modern
case 2: cssCol[0]="abc"; cssCol[1]="fff"; cssCol[2]="ddd"; cssCol[3]="000"; cssCol[4]="0004"; break; //bright
case 3: cssCol[0]="c09f80"; cssCol[1]="d7cec7"; cssCol[2]="76323f"; cssCol[3]="888"; cssCol[4]="3334"; break; //wine
case 4: cssCol[0]="3cc47c"; cssCol[1]="828081"; cssCol[2]="d9a803"; cssCol[3]="1e392a"; cssCol[4]="000a"; break; //electric
case 5: cssCol[0]="57bc90"; cssCol[1]="a5a5af"; cssCol[2]="015249"; cssCol[3]="88c9d4"; cssCol[4]="0004"; break; //mint
case 6: cssCol[0]="f7c331"; cssCol[1]="dcc7aa"; cssCol[2]="6b7a8f"; cssCol[3]="f7882f"; cssCol[4]="0007"; break; //amber
case 7: cssCol[0]="fc3"; cssCol[1]="124"; cssCol[2]="334"; cssCol[3]="f1d"; cssCol[4]="f00"; break; //club
case 14: cssCol[0]="fc7"; cssCol[1]="49274a"; cssCol[2]="94618e"; cssCol[3]="f4decb"; cssCol[4]="0008"; break; //end
//case 15 do nothing since custom vals are already loaded
}
cssColorString="<style>:root{--aCol:#";
cssColorString+=cssCol[0];
cssColorString+=";--bCol:";
cssColorString+=";--bCol:#";
cssColorString+=cssCol[1];
cssColorString+=";--cCol:";
cssColorString+=";--cCol:#";
cssColorString+=cssCol[2];
cssColorString+=";--dCol:";
cssColorString+=";--dCol:#";
cssColorString+=cssCol[3];
cssColorString+=";--sCol:";
cssColorString+=";--sCol:#";
cssColorString+=cssCol[4];
cssColorString+=";--tCol:#";
cssColorString+=cssCol[5];
cssColorString+=";}";
}
@ -307,13 +376,80 @@ void serveIndex()
}
}
void serveWelcomePage()
void serveMessage(int code, String headl, String subl="", bool backToSettings)
{
String resp = "";
resp += PAGE_welcome0;
resp += cssColorString;
resp += PAGE_welcome1;
server.send(200, "text/html", resp);
String messageBody = "<h2>";
messageBody += headl;
messageBody += "</h2>";
messageBody += subl;
if (backToSettings)
{
messageBody += "<form action=/settings><button type=submit>Back</button></form>";
}else
{
messageBody += "<br><br><button type=\"button\" onclick=\"B()\">Back</button>";
}
messageBody += "</body></html>";
server.setContentLength(strlen_P(PAGE_msg0) + cssColorString.length() + strlen_P(PAGE_msg1) + messageBody.length());
server.send(code, "text/html", "");
server.sendContent_P(PAGE_msg0);
server.sendContent(cssColorString);
server.sendContent_P(PAGE_msg1);
server.sendContent(messageBody);
}
void serveSettings(uint8_t subPage)
{
//0: menu 1: wifi 2: leds 3: ui 4: sync 5: time 6: sec 255: welcomepage
if (!arlsTimeout) //do not serve while receiving realtime
{
int pl0, pl1;
switch (subPage)
{
case 1: pl0 = strlen_P(PAGE_settings_wifi0); pl1 = strlen_P(PAGE_settings_wifi1); break;
case 2: pl0 = strlen_P(PAGE_settings_leds0); pl1 = strlen_P(PAGE_settings_leds1); break;
case 3: pl0 = strlen_P(PAGE_settings_ui0); pl1 = strlen_P(PAGE_settings_ui1); break;
case 4: pl0 = strlen_P(PAGE_settings_sync0); pl1 = strlen_P(PAGE_settings_sync1); break;
case 5: pl0 = strlen_P(PAGE_settings_time0); pl1 = strlen_P(PAGE_settings_time1); break;
case 6: pl0 = strlen_P(PAGE_settings_sec0); pl1 = strlen_P(PAGE_settings_sec1); break;
case 255: pl0 = strlen_P(PAGE_welcome0); pl1 = strlen_P(PAGE_welcome1); break;
default: pl0 = strlen_P(PAGE_settings0); pl1 = strlen_P(PAGE_settings1);
}
String settingsBuffer = getSettings(subPage);
int sCssLength = (subPage >0 && subPage <7)?strlen_P(PAGE_settingsCss):0;
server.setContentLength(pl0 + cssColorString.length() + settingsBuffer.length() + sCssLength + pl1);
server.send(200, "text/html", "");
switch (subPage)
{
case 1: server.sendContent_P(PAGE_settings_wifi0); break;
case 2: server.sendContent_P(PAGE_settings_leds0); break;
case 3: server.sendContent_P(PAGE_settings_ui0); break;
case 4: server.sendContent_P(PAGE_settings_sync0); break;
case 5: server.sendContent_P(PAGE_settings_time0); break;
case 6: server.sendContent_P(PAGE_settings_sec0); break;
case 255: server.sendContent_P(PAGE_welcome0); break;
default: server.sendContent_P(PAGE_settings0);
}
server.sendContent(settingsBuffer);
server.sendContent(cssColorString);
if (subPage >0 && subPage <7) server.sendContent_P(PAGE_settingsCss);
switch (subPage)
{
case 1: server.sendContent_P(PAGE_settings_wifi1); break;
case 2: server.sendContent_P(PAGE_settings_leds1); break;
case 3: server.sendContent_P(PAGE_settings_ui1); break;
case 4: server.sendContent_P(PAGE_settings_sync1); break;
case 5: server.sendContent_P(PAGE_settings_time1); break;
case 6: server.sendContent_P(PAGE_settings_sec1); break;
case 255: server.sendContent_P(PAGE_welcome1); break;
default: server.sendContent_P(PAGE_settings1);
}
} else {
server.send(200, "text/plain", "The settings are not available while receiving real-time data.");
}
}

Wyświetl plik

@ -3,7 +3,7 @@
*/
void setAllLeds() {
double d = bri_t*bri_n;
double d = bri_t*briMultiplier;
int val = d/100;
if (val > 255) val = 255;
if (useGammaCorrectionBri)
@ -59,7 +59,7 @@ void colorUpdated(int callMode)
}
if (callMode != 5 && nightlightActive && nightlightFade)
{
bri_nls = bri;
bri_nl_t = bri;
nightlightDelayMs -= (millis() - nightlightStartTime);
nightlightStartTime = millis();
}
@ -151,12 +151,12 @@ void handleNightlight()
notify(4);
nightlightDelayMs = (int)(nightlightDelayMins*60000);
nightlightActive_old = true;
bri_nls = bri;
bri_nl_t = bri;
}
float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
if (nightlightFade)
{
bri = bri_nls+((bri_nl - bri_nls)*nper);
bri = bri_nl_t+((nightlightTargetBri - bri_nl_t)*nper);
colorUpdated(5);
}
if (nper >= 1)
@ -164,10 +164,10 @@ void handleNightlight()
nightlightActive = false;
if (!nightlightFade)
{
bri = bri_nl;
bri = nightlightTargetBri;
colorUpdated(5);
}
if (bri == 0) bri_last = bri_nls;
if (bri == 0) bri_last = bri_nl_t;
}
} else if (nightlightActive_old) //early de-init
{

Wyświetl plik

@ -84,3 +84,17 @@ String getTimeString()
return ret;
}
//returns true if countdown just over
bool checkCountdown()
{
long diff = countdownTime - local;
local = abs(diff);
if (diff <0 && !countdownOverTriggered)
{
applyMacro(countdownMacro);
countdownOverTriggered = true;
return true;
}
return false;
}

Wyświetl plik

@ -265,7 +265,7 @@ void _overlayAnalogCountdown()
strip.unlockAll();
if (now() >= countdownTime)
{
//what to do if countdown finished
checkCountdown();
} else
{
long diff = countdownTime - now();
@ -309,13 +309,10 @@ void _overlayNixieCountdown()
{
if (now() >= countdownTime)
{
if (effectCurrent != 8){
effectCurrent = 8;
strip.setMode(8);
strip.setSpeed(255);
if (checkCountdown())
{
_nixieNumber(2019, 2019);
}
_nixieNumber(2018, 2018);
} else
{
long diff = countdownTime - now();

Wyświetl plik

@ -34,7 +34,7 @@ void handleAlexa()
String request = packetBuffer;
if(request.indexOf("M-SEARCH") >= 0) {
if(request.indexOf("upnp:rootdevice") > 0) {
if(request.indexOf("upnp:rootdevice") > 0 || request.indexOf("device:basic:1") > 0) {
DEBUG_PRINTLN("Responding search req...");
respondToSearch();
}
@ -87,7 +87,13 @@ void alexaDim(uint8_t briL)
server.send(200, "application/json", body.c_str());
String ct = (alexaNotify)?"win&IN&A=":"win&NN&IN&A=";
ct = ct + (briL+1);
if (briL < 255)
{
ct = ct + (briL+1);
} else
{
ct = ct + (255);
}
handleSet(ct);
}

Wyświetl plik

@ -148,16 +148,7 @@ void handleCronixie()
{
cronixieRefreshedTime = millis();
local = TZ.toLocal(now(), &tcr);
if (cronixieCountdown)
{
long diff = countdownTime - local;
local = abs(diff);
if (diff <0 && !countdownOverTriggered)
{
applyMacro(countdownMacro);
countdownOverTriggered = true;
}
}
if (cronixieCountdown) checkCountdown();
uint8_t h = hour(local);
uint8_t h0 = h;
uint8_t m = minute(local);