Finished implementing most time-related settings

Use wled default vendor zone for NTP server
This commit is contained in:
cschwinne 2018-03-14 00:25:54 +01:00
parent bbb27dd70b
commit 37f91c4d50
13 changed files with 215 additions and 111 deletions

Binary file not shown.

View File

@ -37,7 +37,7 @@ const char PAGE_settings_wifi1[] PROGMEM = R"=====(
<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 & Reboot</button><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</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>
@ -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>
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 & Reboot</button>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button>
</form>
</body>
</html>
@ -83,7 +83,7 @@ const char PAGE_settings_leds1[] PROGMEM = R"=====(
<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>
<button type="button" onclick="B()">Back</button><button type="submit">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>
@ -118,7 +118,7 @@ Fade down: <input type="checkbox" name="TLFDE"><br>
<h3>Advanced</h3>
Reverse LED order (rotate 180): <input type="checkbox" name="LEDRV"><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>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
@ -137,7 +137,7 @@ const char PAGE_settings_ui1[] PROGMEM = R"=====(
<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>
<button type="button" onclick="B()">Back</button><button type="submit">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>
@ -170,7 +170,7 @@ 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">Save</button>
</form>
</body>
</html>
@ -186,7 +186,7 @@ const char PAGE_settings_sync1[] PROGMEM = R"=====(
<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>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>Sync setup</h2>
<h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BTNON">
@ -217,7 +217,7 @@ Then, receive <input type="checkbox" name="HURIO"> On/Off, <input type="checkbox
<!--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>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
@ -226,77 +226,86 @@ Hue status: <span class="hms"> Internal ESP Error! </span>
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;
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#time-settings");}function B(){window.open("/settings","_self");}function S(){GetV();Cs();}function gId(s){return document.getElementById(s);}function Cs(){gId("cac").style.display="none";gId("coc").style.display="block";gId("ccc").style.display="none";if (gId("ca").selected){gId("cac").style.display="block";}if (gId("cc").selected){gId("coc").style.display="none";gId("ccc").style.display="block";}if (gId("cn").selected){gId("coc").style.display="none";}}function GetV(){var d = document;
)=====";
const char PAGE_settings_time1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
<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>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>Time setup</h2>
Get time from NTP server: <input type="checkbox" name="NTPON"><br>
<!--NTP server: <input name="NTPSR" maxlength="32"><br>
Use 24h format: <input type="checkbox" name="CL24H"><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>-->
<option value="0" selected>GMT(UTC)</option>
<option value="1">GMT/BST</option>
<option value="2">CET/CEST</option>
<option value="3">EET/EEST</option>
<option value="4">US-EST/EDT</option>
<option value="5">US-CST/CDT</option>
<option value="6">US-MST/MDT</option>
<option value="7">US-AZ</option>
<option value="8">US-PST/PDT</option>
<option value="9">CST(AWST)</option>
<option value="10">JST(KST)</option>
<option value="11">AEST/AEDT</option>
<option value="12">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>-->
UTC offset: <input name="UTCOS" type="number" min="-65500" max="65500" required> seconds (max. 18 hours)<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>Clock</h3>
Clock Overlay:
<select name="OLMDE" onchange="Cs()">
<option value="0" id="cn" selected>None</option>
<option value="1">Static color</option>
<option value="2" id="ca">Analog Clock</option>
<option value="3">Single Digit Clock</option>
<option value="4" id="cc">Cronixie Clock</option>
</select><br>
<div id="coc">
First LED: <input name="OLIN1" type="number" min="0" max="255" required> Last LED: <input name="OLIN2" type="number" min="0" max="255" required><br>
<div id="cac">
12h LED: <input name="OLINM" type="number" min="0" max="255" required><br>
Show 5min marks: <input type="checkbox" name="OL5MI"><br></div>
Seconds (as trail): <input type="checkbox" name="OLSTR"><br>
</div>
<div id="ccc">
Cronixie Display: <input name="CRONX" maxlength="6"><br>
Cronixie Backlight: <input type="checkbox" name="CROBL"><br>
</div>
Countdown Mode: <input type="checkbox" name="CLCND"><br>
Countdown Goal: Year: 20 <input name="CDGYR" type="number" min="0" max="99" required> Month: <input name="CDGMN" type="number" min="1" max="12" required> Day: <input name="CDGDY" type="number" min="1" max="31" required><br>
Hour: <input name="CDGHR" type="number" min="0" max="23" required> Minute: <input name="CDGMI" type="number" min="0" max="59" required> Second: <input name="CDGSC" type="number" min="0" max="59" required><br>
<h3>Advanced Macros</h3>
Coming soon! Not yet implemented!
<!--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>
Define API macros here:<br>
1: <input name="MC1" maxlength="64"><br>
2: <input name="MC2" maxlength="64"><br>
3: <input name="MC3" maxlength="64"><br>
4: <input name="MC4" maxlength="64"><br>
5: <input name="MC5" maxlength="64"><br>
6: <input name="MC6" maxlength="64"><br>
7: <input name="MC7" maxlength="64"><br>
8: <input name="MC8" maxlength="64"><br>
9: <input name="MC9" maxlength="64"><br>
10: <input name="MC10" maxlength="64"><br>
11: <input name="MC11" maxlength="64"><br>
12: <input name="MC12" maxlength="64"><br>
13: <input name="MC13" maxlength="64"><br>
14: <input name="MC14" maxlength="64"><br>
15: <input name="MC15" maxlength="64"><br>
16: <input name="MC16" 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>-->
<i>Use 0 for the default action instead of a macro</i><br>
Time controlled macros coming soon!<br>
Boot Macro: <input name="MCRBT" type="number" min="0" max="16" required><br>
Alexa On/Off Macros: <input name="MCA0I" type="number" min="0" max="16" required> <input name="MCA0O" type="number" min="0" max="16" required><br>
Button Macro: <input name="MCB0D" type="number" min="0" max="16" required> Long Press: <input name="MCB0L" type="number" min="0" max="16" required><br>
Countdown-Over Macro: <input name="MCNTD" type="number" min="0" max="16" required><br>
Timed-Light-Over Macro: <input name="MCNLO" type="number" min="0" max="16" required><br>
<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">Save</button>
</form>
</body>
</html>
@ -313,7 +322,7 @@ const char PAGE_settings_sec1[] PROGMEM = R"=====(
<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 & Reboot</button><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</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>
@ -343,7 +352,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>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 & Reboot</button>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button>
</form>
</body>
</html>

View File

@ -120,7 +120,7 @@ int year(time_t t); // the year for the given time
time_t now(); // return the current time as seconds since Jan 1 1970
void setTime(time_t t);
void setTime(int hr,int min,int sec,int day, int month, int yr);
void getUnixTime(int hr,int min,int sec,int day, int month, int yr); //added by Aircoookie to get epoch time
time_t getUnixTime(int hr,int min,int sec,int day, int month, int yr); //added by Aircoookie to get epoch time
void adjustTime(long adjustment);
/* date strings */

View File

@ -32,7 +32,7 @@
#include "WS2812FX.h"
//version in format yymmddb (b = daily build)
#define VERSION 1803061
#define VERSION 1803141
const String versionString = "0.6.0_dev";
//AP and OTA default passwords (change them!)
@ -100,7 +100,7 @@ uint8_t effectIntensityDefault = 128;
//NTP stuff
boolean ntpEnabled = false;
IPAddress ntpServerIP;
const char* ntpServerName = "pool.ntp.org";
const char* ntpServerName = "0.wled.pool.ntp.org";
//custom chase
uint8_t cc_numPrimary = 2;
uint8_t cc_numSecondary = 4;
@ -113,9 +113,10 @@ uint8_t cc_start = 0;
//alexa
boolean alexaEnabled = true;
String alexaInvocationName = "Light";
uint8_t alexaOnMacro = 0, alexaOffMacro = 0;
uint8_t buttonMacro = 0, countdownMacro = 0;
uint8_t bootMacro = 0;
uint8_t macroBoot = 0, macroNl = 0;
uint8_t macroAlexaOn = 0, macroAlexaOff = 0;
uint8_t macroButton = 0, macroCountdown = 0, macroLongPress = 0;
unsigned long countdownTime = 1514764800L;
@ -186,8 +187,8 @@ int utcOffsetSecs = 0;
//overlay stuff
uint8_t overlayDefault = 0;
uint8_t overlayCurrent = 0;
int overlayMin = 0, overlayMax = 79; //bb: 35, 46, t: 0, 79
int analogClock12pixel = 25; //bb: 41, t: 25
uint8_t overlayMin = 0, overlayMax = ledcount-1;
uint8_t analogClock12pixel = 0;
boolean analogClockSecondsTrail = false;
boolean analogClock5MinuteMarks = false;
uint8_t overlaySpeed = 200;
@ -205,7 +206,7 @@ String cronixieDisplay = "HHMMSS";
byte dP[]{0,0,0,0,0,0};
bool useAMPM = false;
bool cronixieBacklight = true;
bool overlayCountdown = false;
bool countdownMode = false;
bool cronixieInit = false;
int arlsTimeoutMillis = 2500;

View File

@ -14,6 +14,7 @@
//4 -> 0.5.0 and up
//5 -> 0.6.0_dev and up
//todo add settings
void clearEEPROM()
{
for (int i = 0; i < EEPSIZE; i++)
@ -176,6 +177,35 @@ void saveSettingsToEEPROM()
EEPROM.write(2105, hueApplyColor);
EEPROM.write(2106, huePollLightId);
EEPROM.write(2150, overlayMin);
EEPROM.write(2151, overlayMax);
EEPROM.write(2152, analogClock12pixel);
EEPROM.write(2153, analogClock5MinuteMarks);
EEPROM.write(2154, analogClockSecondsTrail);
EEPROM.write(2155, countdownMode);
EEPROM.write(2156, countdownYear);
EEPROM.write(2157, countdownMonth);
EEPROM.write(2158, countdownDay);
EEPROM.write(2159, countdownHour);
EEPROM.write(2160, countdownMin);
EEPROM.write(2161, countdownSec);
setCountdown();
for (int i = 2165; i < 2171; ++i)
{
EEPROM.write(i, cronixieDisplay.charAt(i-2165));
}
EEPROM.write(2171, cronixieBacklight);
setCronixie();
EEPROM.write(2175, macroBoot);
EEPROM.write(2176, macroAlexaOn);
EEPROM.write(2177, macroAlexaOff);
EEPROM.write(2178, macroButton);
EEPROM.write(2179, macroLongPress);
EEPROM.write(2180, macroCountdown);
EEPROM.write(2181, macroNl);
EEPROM.commit();
}
@ -351,6 +381,35 @@ void loadSettingsFromEEPROM(bool first)
hueApplyBri = EEPROM.read(2104);
hueApplyColor = EEPROM.read(2105);
huePollLightId = EEPROM.read(2106);
overlayMin = EEPROM.read(2150);
overlayMax = EEPROM.read(2151);
analogClock12pixel = EEPROM.read(2152);
analogClock5MinuteMarks = EEPROM.read(2153);
analogClockSecondsTrail = EEPROM.read(2154);
countdownMode = EEPROM.read(2155);
countdownYear = EEPROM.read(2156);
countdownMonth = EEPROM.read(2157);
countdownDay = EEPROM.read(2158);
countdownHour = EEPROM.read(2159);
countdownMin = EEPROM.read(2160);
countdownSec = EEPROM.read(2161);
setCountdown();
cronixieDisplay = "";
for (int i = 2165; i < 2171; ++i)
{
if (EEPROM.read(i) == 0) break;
cronixieDisplay += char(EEPROM.read(i));
}
cronixieBacklight = EEPROM.read(2171);
macroBoot = EEPROM.read(2175);
macroAlexaOn = EEPROM.read(2176);
macroAlexaOff = EEPROM.read(2177);
macroButton = EEPROM.read(2178);
macroLongPress = EEPROM.read(2179);
macroCountdown = EEPROM.read(2180);
macroNl = EEPROM.read(2181);
}
bootPreset = EEPROM.read(389);
@ -482,7 +541,7 @@ void applyMacro(uint8_t index)
handleSet(mc);
}
void saveMacro(uint8_t index, String mc)
void saveMacro(uint8_t index, String mc, bool sing=true) //only commit on single save, not in settings
{
index-=1;
if (index > 15) return;
@ -491,6 +550,6 @@ void saveMacro(uint8_t index, String mc)
{
EEPROM.write(i, mc.charAt(i-s));
}
EEPROM.commit();
if (sing) EEPROM.commit();
}

View File

@ -213,7 +213,7 @@ String getSettings(uint8_t subPage)
resp += ds + "TZONE" + si + String(currentTimezone) + ";";
resp += ds + "UTCOS" + v + utcOffsetSecs +";";
resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";";
resp += ds + "OLMDE" + si + String(currentOverlay) + ";";
resp += ds + "OLMDE" + si + String(overlayCurrent) + ";";
resp += ds + "OLIN1" + v + overlayMin +";";
resp += ds + "OLIN2" + v + overlayMax +";";
resp += ds + "OLINM" + v + analogClock12pixel +";";
@ -221,11 +221,11 @@ String getSettings(uint8_t subPage)
resp += ds + "OL5MI" + c + analogClock5MinuteMarks +";";
resp += ds + "CRONX" + v + "\"" + cronixieDisplay + "\";";
resp += ds + "CROBL" + c + cronixieBacklight +";";
resp += ds + "CLCND" + c + overlayCountdown +";";
resp += ds + "CLCND" + c + countdownMode +";";
resp += ds + "CDGYR" + v + countdownYear +";";
resp += ds + "CDGMN" + v + countdownMonth +";";
resp += ds + "CDGDY" + v + countdownDay +";";
resp += ds + "CDGHR" + v + countdownHours +";";
resp += ds + "CDGHR" + v + countdownHour +";";
resp += ds + "CDGMI" + v + countdownMin +";";
resp += ds + "CDGSC" + v + countdownSec +";";
for (int i=1;i<17;i++)
@ -238,7 +238,7 @@ String getSettings(uint8_t subPage)
resp += ds + "MCB0D" + v + macroButton +";";
resp += ds + "MCB0L" + v + macroLongPress +";";
resp += ds + "MCNTD" + v + macroCountdown +";";
resp += ds + "MCLNO" + v + macroNightlight +";";
resp += ds + "MCNLO" + v + macroNl +";";
}
if (subPage == 6)

View File

@ -282,10 +282,7 @@ void handleSettingsSet(uint8_t subPage)
for (int i=0;i<4;i++){
String a = "HUIP"+String(i);
if (server.hasArg(a))
{
int j = server.arg(a).toInt();
if (j >= 0 && j <= 255) hueIP[i] = j;
}
hueIP[i] = server.arg(a).toInt();
}
if (server.hasArg("HUELI"))
{
@ -315,12 +312,49 @@ void handleSettingsSet(uint8_t subPage)
if (subPage == 5)
{
ntpEnabled = server.hasArg("NTPON");
useAMPM = !server.hasArg("CL24H");
if (server.hasArg("TZONE")) currentTimezone = server.arg("TZONE").toInt();
if (server.hasArg("UTCOS")) utcOffsetSecs = server.arg("UTCOS").toInt();
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); //start if not already connected
if (server.hasArg("OLDEF"))
{
int i = server.arg("OLDEF").toInt();
if (i >= 0 && i <= 255) overlayDefault = i;
if (server.hasArg("OLMDE")){
overlayDefault = server.arg("OLMDE").toInt();
overlayCurrent = overlayDefault;
strip.unlockAll();
}
if (server.hasArg("OLIN1")) overlayMin = server.arg("OLIN1").toInt();
if (server.hasArg("OLIN2")) overlayMax = server.arg("OLIN2").toInt();
if (server.hasArg("OLINM")) analogClock12pixel = server.arg("OLINM").toInt();
analogClock5MinuteMarks = server.hasArg("OL5MI");
analogClockSecondsTrail = server.hasArg("OLSTR");
if (server.hasArg("CRONX")) cronixieDisplay = server.arg("CRONX");
bool cbOld = cronixieBacklight;
cronixieBacklight = server.hasArg("CROBL");
if (cbOld != cronixieBacklight && overlayCurrent == 4)
{
strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0;
}
countdownMode = server.hasArg("CLCND");
if (server.hasArg("CDGYR")) countdownYear = server.arg("CDGYR").toInt();
if (server.hasArg("CDGMN")) countdownMonth = server.arg("CDGMN").toInt();
if (server.hasArg("CDGDY")) countdownDay = server.arg("CDGDY").toInt();
if (server.hasArg("CDGHR")) countdownHour = server.arg("CDGHR").toInt();
if (server.hasArg("CDGMI")) countdownMin = server.arg("CDGMI").toInt();
if (server.hasArg("CDGSC")) countdownSec = server.arg("CDGSC").toInt();
for (int i=1;i<17;i++)
{
String a = "MC"+String(i);
if (server.hasArg(a)) saveMacro(i,server.arg(a),false);
}
if (server.hasArg("MCRBT")) macroBoot = server.arg("MCRBT").toInt();
if (server.hasArg("MCA0I")) macroAlexaOn = server.arg("MCA0I").toInt();
if (server.hasArg("MCA0O")) macroAlexaOff = server.arg("MCA0O").toInt();
if (server.hasArg("MCB0D")) macroButton = server.arg("MCB0D").toInt();
if (server.hasArg("MCB0L")) macroLongPress = server.arg("MCB0L").toInt();
if (server.hasArg("MCNTD")) macroCountdown = server.arg("MCNTD").toInt();
if (server.hasArg("MCNLO")) macroNl = server.arg("MCNLO").toInt();
}
//SECURITY
@ -723,10 +757,10 @@ boolean handleSet(String req)
}
pos = req.indexOf("NM="); //mode, 1 countdown
if (pos > 0) {
overlayCountdown = true;
countdownMode = true;
if (req.indexOf("NM=0") > 0)
{
overlayCountdown = false;
countdownMode = false;
}
}
if (req.indexOf("NB=") > 0) //sets backlight

View File

@ -306,6 +306,7 @@ void wledInit()
pinMode(buttonPin, INPUT_PULLUP);
if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true);
if (macroBoot>0) applyMacro(macroBoot);
colorUpdated(0);
if(digitalRead(buttonPin) == LOW) buttonEnabled = false; //disable button if it is "pressed" unintentionally
}

View File

@ -19,11 +19,11 @@ void handleButton()
if (millis() - buttonPressedTime > 7000) {initAP();}
else if (millis() - buttonPressedTime > 700)
{
if (buttonLongPressMacro != 0) {applyMacro(buttonLongPressMacro);}
if (macroLongPress != 0) {applyMacro(macroLongPress);}
else _setRandomColor(false);
}
else {
if (buttonMacro == 0)
if (macroButton == 0)
{
if (bri == 0)
{
@ -35,7 +35,7 @@ void handleButton()
}
colorUpdated(2);
} else {
applyMacro(buttonMacro);
applyMacro(macroButton);
}
}
buttonPressedBefore = false;

View File

@ -116,7 +116,7 @@ boolean checkNTPResponse()
void updateLocalTime()
{
unsigned long tmc = now()+ (utcOffsetSign)? -utcOffsetSecs:utcOffsetSecs;
unsigned long tmc = now()+ utcOffsetSecs;
local = timezones[currentTimezone]->toLocal(tmc);
}
@ -152,11 +152,11 @@ void setCountdown()
//returns true if countdown just over
bool checkCountdown()
{
long diff = countdownTime - local;
long diff = countdownTime - now();
local = abs(diff);
if (diff <0 && !countdownOverTriggered)
{
if (countdownMacro != 0) applyMacro(countdownMacro);
if (macroCountdown != 0) applyMacro(macroCountdown);
countdownOverTriggered = true;
return true;
}

View File

@ -3,20 +3,20 @@
*/
void initCronixie()
{
if (overlayCurrent == 7 && !cronixieInit)
if (overlayCurrent == 4 && !cronixieInit)
{
strip.driverModeCronixie(true);
strip.setCronixieBacklight(cronixieBacklight);
setCronixie(cronixieDefault);
setCronixie();
cronixieInit = true;
} else if (cronixieInit && overlayCurrent != 7)
} else if (cronixieInit && overlayCurrent != 4)
{
strip.driverModeCronixie(false);
cronixieInit = false;
}
}
void _nixieDisplay(int num[], int dur[], int pausedur[], int cnt)
void _nixieDisplay(int num[], uint16_t dur[], uint16_t pausedur[], uint8_t cnt)
{
strip.setRange(overlayMin, overlayMax, 0);
if (num[nixieClockI] >= 0 && !nixiePause)
@ -146,7 +146,7 @@ void _overlayAnalogClock()
{
int overlaySize = overlayMax - overlayMin +1;
strip.unlockAll();
if (overlayCountdown)
if (countdownMode)
{
_overlayAnalogCountdown(); return;
}
@ -192,7 +192,7 @@ void _overlayAnalogClock()
void _overlayNixieClock()
{
if (overlayCountdown)
if (countdownMode)
{
_overlayNixieCountdown(); return;
}

View File

@ -46,12 +46,12 @@ void handleAlexa()
void alexaOn()
{
if (alexaOnMacro == 0)
if (macroAlexaOn == 0)
{
handleSet((alexaNotify)?"win&T=1&IN":"win&T=1&NN&IN");
} else
{
applyMacro(alexaOnMacro);
applyMacro(macroAlexaOn);
}
String body = "[{\"success\":{\"/lights/1/state/on\":true}}]";
@ -64,12 +64,12 @@ void alexaOn()
void alexaOff()
{
if (alexaOffMacro == 0)
if (macroAlexaOff == 0)
{
handleSet((alexaNotify)?"win&T=0&IN":"win&T=0&NN&IN");
} else
{
applyMacro(alexaOffMacro);
applyMacro(macroAlexaOff);
}
String body = "[{\"success\":{\"/lights/1/state/on\":false}}]";

View File

@ -19,7 +19,7 @@ uint8_t getSameCodeLength(char code, int index, char const digits[])
void setCronixie()
{
char digits[] = cronixieDisplay.substring(0,6);
char digits[6]; for (int a=0;a<6;a++) digits[a]=cronixieDisplay.charAt(a);
/*
* digit purpose index
* 0-9 | 0-9 (incl. random)
@ -144,7 +144,7 @@ void setCronixie()
void _overlayCronixie()
{
if (overlayCountdown) checkCountdown();
if (countdownMode) checkCountdown();
uint8_t h = hour(local);
uint8_t h0 = h;
uint8_t m = minute(local);
@ -155,7 +155,7 @@ void _overlayCronixie()
//this has to be changed in time for 22nd century
y -= 2000; if (y<0) y += 30; //makes countdown work
if (useAMPM && !overlayCountdown)
if (useAMPM && !countdownMode)
{
if (h>12) h-=12;
else if (h==0) h+=12;