2016-12-31 00:38:51 +01:00
|
|
|
/*
|
|
|
|
* Receives client input
|
|
|
|
*/
|
|
|
|
|
2018-03-15 13:03:50 +01:00
|
|
|
void _setRandomColor(bool _sec,bool fromButton=false)
|
2017-12-11 23:59:12 +01:00
|
|
|
{
|
|
|
|
lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);
|
|
|
|
if (_sec){
|
2018-03-15 13:03:50 +01:00
|
|
|
colorHStoRGB(lastRandomIndex*256,255,colSec);
|
2017-12-11 23:59:12 +01:00
|
|
|
} else {
|
2018-03-15 13:03:50 +01:00
|
|
|
colorHStoRGB(lastRandomIndex*256,255,col);
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
2018-03-15 13:03:50 +01:00
|
|
|
if (fromButton) colorUpdated(2);
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
void handleSettingsSet(byte subPage)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
//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)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CS")) clientSSID = server.arg("CS");
|
|
|
|
if (server.hasArg("CP"))
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (!server.arg("CP").indexOf('*') == 0)
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
|
|
|
DEBUG_PRINTLN("Setting pass");
|
2018-03-14 19:05:51 +01:00
|
|
|
clientPass = server.arg("CP");
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CM")) cmDNS = server.arg("CM");
|
|
|
|
if (server.hasArg("AT"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("AT").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("AS")) apSSID = server.arg("AS");
|
|
|
|
apHide = server.hasArg("AH");
|
|
|
|
if (server.hasArg("AP"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (!server.arg("AP").indexOf('*') == 0) apPass = server.arg("AP");
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("AC"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int chan = server.arg("AC").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (chan > 0 && chan < 14) apChannel = chan;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("I0"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("I0").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticIP[0] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("I1"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("I1").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticIP[1] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("I2"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("I2").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticIP[2] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("I3"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("I3").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticIP[3] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("G0"))
|
2017-10-12 17:09:59 +02:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("G0").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticGateway[0] = i;
|
2017-10-12 17:09:59 +02:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("G1"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("G1").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticGateway[1] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("G2"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("G2").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticGateway[2] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("G3"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("G3").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticGateway[3] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("S0"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("S0").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticSubnet[0] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("S1"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("S1").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticSubnet[1] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("S2"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("S2").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticSubnet[2] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("S3"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("S3").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) staticSubnet[3] = i;
|
2016-11-27 16:45:54 +01:00
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
//LED SETTINGS
|
|
|
|
if (subPage == 2)
|
2016-12-11 20:11:14 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("LC"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("LC").toInt();
|
2018-04-13 00:28:29 +02:00
|
|
|
if (i >= 0 && i <= 1200) ledCount = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-04-14 18:56:35 +02:00
|
|
|
useRGBW = server.hasArg("EW");
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("IS")) //ignore settings and save current brightness, colors and fx as default
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
colS[0] = col[0];
|
|
|
|
colS[1] = col[1];
|
|
|
|
colS[2] = col[2];
|
|
|
|
if (useRGBW) whiteS = white;
|
|
|
|
briS = bri;
|
2018-02-20 22:29:48 +01:00
|
|
|
effectDefault = effectCurrent;
|
|
|
|
effectSpeedDefault = effectSpeed;
|
|
|
|
} else {
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CR"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("CR").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colS[0] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CG"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("CG").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colS[1] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CB"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("CB").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colS[2] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("SR"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("SR").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colSecS[0] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("SG"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("SG").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colSecS[1] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("SB"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("SB").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) colSecS[2] = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("SW"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("SW").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) whiteSecS = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CW"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("CW").toInt();
|
2018-04-14 18:56:35 +02:00
|
|
|
if (i >= 0 && i <= 255) whiteS = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CA"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("CA").toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
if (i >= 0 && i <= 255) briS = i;
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("FX"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("FX").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i >= 0 && i <= 255) effectDefault = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("SX"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("SX").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i >= 0 && i <= 255) effectSpeedDefault = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("IX"))
|
2018-02-23 01:33:32 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("IX").toInt();
|
2018-02-23 01:33:32 +01:00
|
|
|
if (i >= 0 && i <= 255) effectIntensityDefault = i;
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
turnOnAtBoot = server.hasArg("BO");
|
|
|
|
if (server.hasArg("BP"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("BP").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i >= 0 && i <= 25) bootPreset = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
useGammaCorrectionBri = server.hasArg("GB");
|
|
|
|
useGammaCorrectionRGB = server.hasArg("GC");
|
|
|
|
fadeTransition = server.hasArg("TF");
|
|
|
|
sweepTransition = server.hasArg("TS");
|
|
|
|
sweepDirection = !server.hasArg("TI");
|
|
|
|
if (server.hasArg("TD"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("TD").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i > 0){
|
|
|
|
transitionDelay = i;
|
|
|
|
}
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("TB"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
nightlightTargetBri = server.arg("TB").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("TL"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("TL").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i > 0) nightlightDelayMins = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
nightlightFade = server.hasArg("TW");
|
|
|
|
reverseMode = server.hasArg("RV");
|
2018-03-15 12:04:14 +01:00
|
|
|
initLedsLast = server.hasArg("EI");
|
2018-03-14 11:41:24 +01:00
|
|
|
strip.setReverseMode(reverseMode);
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("WO"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("WO").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i >= -255 && i <= 255) arlsOffset = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("BF"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("BF").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
if (i > 0) briMultiplier = i;
|
|
|
|
}
|
2018-04-14 18:56:35 +02:00
|
|
|
strip.init(useRGBW,ledCount,PIN);
|
2016-12-11 20:11:14 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
//UI
|
|
|
|
if (subPage == 3)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("DS")) serverDescription = server.arg("DS");
|
|
|
|
useHSBDefault = server.hasArg("MD");
|
2018-02-20 22:29:48 +01:00
|
|
|
useHSB = useHSBDefault;
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("TH")) currentTheme = server.arg("TH").toInt();
|
2018-02-23 01:33:32 +01:00
|
|
|
for(int i=0;i<6;i++)
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("C"+String(i))) cssCol[i] = server.arg("C"+String(i));
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CF")) cssFont = server.arg("CF");
|
2018-02-20 22:29:48 +01:00
|
|
|
buildCssColorString();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
//SYNC
|
|
|
|
if (subPage == 4)
|
2017-02-24 23:21:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
buttonEnabled = server.hasArg("BT");
|
|
|
|
if (server.hasArg("UP"))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
udpPort = server.arg("UP").toInt();
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
receiveNotificationBrightness = server.hasArg("RB");
|
|
|
|
receiveNotificationColor = server.hasArg("RC");
|
|
|
|
receiveNotificationEffects = server.hasArg("RX");
|
2018-02-20 22:29:48 +01:00
|
|
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
|
2018-03-14 19:05:51 +01:00
|
|
|
notifyDirectDefault = server.hasArg("SD");
|
2018-02-20 22:29:48 +01:00
|
|
|
notifyDirect = notifyDirectDefault;
|
2018-03-14 19:05:51 +01:00
|
|
|
notifyButton = server.hasArg("SB");
|
|
|
|
notifyTwice = server.hasArg("S2");
|
|
|
|
alexaEnabled = server.hasArg("AL");
|
|
|
|
if (server.hasArg("AI")) alexaInvocationName = server.arg("AI");
|
|
|
|
alexaNotify = server.hasArg("SA");
|
|
|
|
notifyHue = server.hasArg("SH");
|
2018-02-28 00:27:10 +01:00
|
|
|
for (int i=0;i<4;i++){
|
2018-03-14 19:05:51 +01:00
|
|
|
String a = "H"+String(i);
|
2018-02-28 00:27:10 +01:00
|
|
|
if (server.hasArg(a))
|
2018-03-14 00:25:54 +01:00
|
|
|
hueIP[i] = server.arg(a).toInt();
|
2018-02-28 00:27:10 +01:00
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("HL"))
|
2018-02-28 00:27:10 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("HL").toInt();
|
2018-02-28 00:27:10 +01:00
|
|
|
if (i > 0) huePollLightId = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("HI"))
|
2018-02-28 00:27:10 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
int i = server.arg("HI").toInt();
|
2018-02-28 00:27:10 +01:00
|
|
|
if (i > 50) huePollIntervalMs = i;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
hueApplyOnOff = server.hasArg("HO");
|
|
|
|
hueApplyBri = server.hasArg("HB");
|
|
|
|
hueApplyColor = server.hasArg("HC");
|
|
|
|
if (server.hasArg("HP"))
|
2018-02-28 00:27:10 +01:00
|
|
|
{
|
|
|
|
if (!huePollingEnabled) hueAttempt = true;
|
|
|
|
if (!setupHue()) hueAttempt = true;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
huePollingEnabled = false;
|
|
|
|
hueError = "Inactive";
|
|
|
|
}
|
2017-02-24 23:21:48 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
//TIME
|
|
|
|
if (subPage == 5)
|
2017-02-24 23:21:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
ntpEnabled = server.hasArg("NT");
|
|
|
|
useAMPM = !server.hasArg("CF");
|
|
|
|
if (server.hasArg("TZ")) currentTimezone = server.arg("TZ").toInt();
|
|
|
|
if (server.hasArg("UO")) utcOffsetSecs = server.arg("UO").toInt();
|
2018-02-23 01:33:32 +01:00
|
|
|
if (ntpEnabled && WiFi.status() == WL_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); //start if not already connected
|
2018-03-14 00:25:54 +01:00
|
|
|
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("OL")){
|
|
|
|
overlayDefault = server.arg("OL").toInt();
|
2018-03-14 00:25:54 +01:00
|
|
|
overlayCurrent = overlayDefault;
|
|
|
|
strip.unlockAll();
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("O1")) overlayMin = server.arg("O1").toInt();
|
|
|
|
if (server.hasArg("O2")) overlayMax = server.arg("O2").toInt();
|
|
|
|
if (server.hasArg("OM")) analogClock12pixel = server.arg("OM").toInt();
|
|
|
|
analogClock5MinuteMarks = server.hasArg("O5");
|
|
|
|
analogClockSecondsTrail = server.hasArg("OS");
|
2018-03-14 00:25:54 +01:00
|
|
|
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("CX")) cronixieDisplay = server.arg("CX");
|
2018-03-14 00:25:54 +01:00
|
|
|
bool cbOld = cronixieBacklight;
|
2018-03-14 19:05:51 +01:00
|
|
|
cronixieBacklight = server.hasArg("CB");
|
2018-03-14 00:25:54 +01:00
|
|
|
if (cbOld != cronixieBacklight && overlayCurrent == 4)
|
|
|
|
{
|
|
|
|
strip.setCronixieBacklight(cronixieBacklight); overlayRefreshedTime = 0;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
countdownMode = server.hasArg("CE");
|
|
|
|
if (server.hasArg("CY")) countdownYear = server.arg("CY").toInt();
|
|
|
|
if (server.hasArg("CI")) countdownMonth = server.arg("CI").toInt();
|
|
|
|
if (server.hasArg("CD")) countdownDay = server.arg("CD").toInt();
|
|
|
|
if (server.hasArg("CH")) countdownHour = server.arg("CH").toInt();
|
|
|
|
if (server.hasArg("CM")) countdownMin = server.arg("CM").toInt();
|
|
|
|
if (server.hasArg("CS")) countdownSec = server.arg("CS").toInt();
|
2018-03-14 00:25:54 +01:00
|
|
|
|
|
|
|
for (int i=1;i<17;i++)
|
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
String a = "M"+String(i);
|
2018-03-14 00:25:54 +01:00
|
|
|
if (server.hasArg(a)) saveMacro(i,server.arg(a),false);
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("MB")) macroBoot = server.arg("MB").toInt();
|
|
|
|
if (server.hasArg("A0")) macroAlexaOn = server.arg("A0").toInt();
|
|
|
|
if (server.hasArg("A1")) macroAlexaOff = server.arg("A1").toInt();
|
|
|
|
if (server.hasArg("MP")) macroButton = server.arg("MP").toInt();
|
|
|
|
if (server.hasArg("ML")) macroLongPress = server.arg("ML").toInt();
|
|
|
|
if (server.hasArg("MC")) macroCountdown = server.arg("MC").toInt();
|
|
|
|
if (server.hasArg("MN")) macroNl = server.arg("MN").toInt();
|
2017-02-24 23:21:48 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
|
|
|
//SECURITY
|
|
|
|
if (subPage == 6)
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("RS"))
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
clearEEPROM();
|
2018-02-23 01:33:32 +01:00
|
|
|
serveMessage(200, "All Settings erased.", "Connect to WLED-AP to setup again...",255);
|
2018-02-20 22:29:48 +01:00
|
|
|
reset();
|
|
|
|
}
|
2018-02-23 01:33:32 +01:00
|
|
|
|
|
|
|
bool pwdCorrect = !otaLock; //always allow access if ota not locked
|
2018-03-14 19:05:51 +01:00
|
|
|
if (server.hasArg("OP"))
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
if (otaLock && otaPass.equals(server.arg("OP")))
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-02-23 01:33:32 +01:00
|
|
|
pwdCorrect = true;
|
|
|
|
}
|
2018-03-14 19:05:51 +01:00
|
|
|
if (!otaLock && server.arg("OP").length() > 0)
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
otaPass = server.arg("OP");
|
2016-11-20 01:47:15 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-23 01:33:32 +01:00
|
|
|
|
|
|
|
if (pwdCorrect) //allow changes if correct pwd or no ota active
|
2018-02-20 22:29:48 +01:00
|
|
|
{
|
2018-03-14 19:05:51 +01:00
|
|
|
otaLock = server.hasArg("NO");
|
|
|
|
wifiLock = server.hasArg("OW");
|
|
|
|
recoveryAPDisabled = server.hasArg("NA");
|
|
|
|
aOtaEnabled = server.hasArg("AO");
|
2018-02-20 22:29:48 +01:00
|
|
|
}
|
2016-11-20 01:47:15 +01:00
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
saveSettingsToEEPROM();
|
|
|
|
}
|
|
|
|
|
2018-03-14 13:16:28 +01:00
|
|
|
bool handleSet(String req)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
bool effectUpdated = false;
|
2017-02-01 19:25:36 +01:00
|
|
|
if (!(req.indexOf("win") >= 0)) {
|
2016-11-19 19:39:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int pos = 0;
|
2017-12-30 01:16:00 +01:00
|
|
|
DEBUG_PRINT("API req: ");
|
|
|
|
DEBUG_PRINTLN(req);
|
2017-12-28 00:37:13 +01:00
|
|
|
|
2017-12-30 01:16:00 +01:00
|
|
|
//save macro, requires &MS=<slot>(<macro>) format
|
2017-12-28 00:37:13 +01:00
|
|
|
pos = req.indexOf("&MS=");
|
|
|
|
if (pos > 0) {
|
|
|
|
int i = req.substring(pos + 4).toInt();
|
2017-12-30 01:16:00 +01:00
|
|
|
pos = req.indexOf('(') +1;
|
2017-12-28 00:37:13 +01:00
|
|
|
if (pos > 0) {
|
2017-12-30 01:16:00 +01:00
|
|
|
int en = req.indexOf(')');
|
2017-12-28 00:37:13 +01:00
|
|
|
String mc = req.substring(pos);
|
|
|
|
if (en > 0) mc = req.substring(pos, en);
|
|
|
|
saveMacro(i, mc);
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = req.indexOf("IN");
|
|
|
|
if (pos < 1) XML_response();
|
|
|
|
return true;
|
|
|
|
//if you save a macro in one request, other commands in that request are ignored due to unwanted behavior otherwise
|
|
|
|
}
|
|
|
|
|
2017-11-19 15:31:17 +01:00
|
|
|
//set brigthness
|
2017-12-02 23:58:22 +01:00
|
|
|
pos = req.indexOf("&A=");
|
2016-11-19 19:39:17 +01:00
|
|
|
if (pos > 0) {
|
2017-12-02 23:58:22 +01:00
|
|
|
bri = req.substring(pos + 3).toInt();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-28 00:27:10 +01:00
|
|
|
|
|
|
|
//set hue
|
|
|
|
pos = req.indexOf("HU=");
|
|
|
|
if (pos > 0) {
|
|
|
|
uint16_t temphue = req.substring(pos + 3).toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
byte tempsat = 255;
|
2018-02-28 00:27:10 +01:00
|
|
|
pos = req.indexOf("SA=");
|
|
|
|
if (pos > 0) {
|
|
|
|
tempsat = req.substring(pos + 3).toInt();
|
|
|
|
}
|
2018-03-14 13:16:28 +01:00
|
|
|
colorHStoRGB(temphue,tempsat,(req.indexOf("H2")>0)? colSec:col);
|
2018-02-28 00:27:10 +01:00
|
|
|
}
|
|
|
|
|
2017-11-19 15:31:17 +01:00
|
|
|
//set red value
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&R=");
|
2016-11-19 19:39:17 +01:00
|
|
|
if (pos > 0) {
|
2017-12-11 23:59:12 +01:00
|
|
|
col[0] = req.substring(pos + 3).toInt();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set green value
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&G=");
|
2016-11-19 19:39:17 +01:00
|
|
|
if (pos > 0) {
|
2017-12-11 23:59:12 +01:00
|
|
|
col[1] = req.substring(pos + 3).toInt();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set blue value
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&B=");
|
2016-11-19 19:39:17 +01:00
|
|
|
if (pos > 0) {
|
2017-12-11 23:59:12 +01:00
|
|
|
col[2] = req.substring(pos + 3).toInt();
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set white value
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&W=");
|
2017-10-12 17:09:59 +02:00
|
|
|
if (pos > 0) {
|
2017-12-11 23:59:12 +01:00
|
|
|
white = req.substring(pos + 3).toInt();
|
2017-10-12 17:09:59 +02:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2017-11-28 16:04:11 +01:00
|
|
|
//set 2nd red value
|
|
|
|
pos = req.indexOf("R2=");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
colSec[0] = req.substring(pos + 3).toInt();
|
2017-11-28 16:04:11 +01:00
|
|
|
}
|
|
|
|
//set 2nd green value
|
|
|
|
pos = req.indexOf("G2=");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
colSec[1] = req.substring(pos + 3).toInt();
|
2017-11-28 16:04:11 +01:00
|
|
|
}
|
|
|
|
//set 2nd blue value
|
|
|
|
pos = req.indexOf("B2=");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
colSec[2] = req.substring(pos + 3).toInt();
|
2017-11-28 16:04:11 +01:00
|
|
|
}
|
|
|
|
//set 2nd white value
|
|
|
|
pos = req.indexOf("W2=");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
whiteSec = req.substring(pos + 3).toInt();
|
2017-11-28 16:04:11 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2017-12-11 23:59:12 +01:00
|
|
|
//set 2nd to white
|
|
|
|
pos = req.indexOf("SW");
|
|
|
|
if (pos > 0) {
|
|
|
|
if(useRGBW) {
|
2018-03-14 13:16:28 +01:00
|
|
|
whiteSec = 255;
|
|
|
|
colSec[0] = 0;
|
|
|
|
colSec[1] = 0;
|
|
|
|
colSec[2] = 0;
|
2017-12-11 23:59:12 +01:00
|
|
|
} else {
|
2018-03-14 13:16:28 +01:00
|
|
|
colSec[0] = 255;
|
|
|
|
colSec[1] = 255;
|
|
|
|
colSec[2] = 255;
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//set 2nd to black
|
|
|
|
pos = req.indexOf("SB");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
whiteSec = 0;
|
|
|
|
colSec[0] = 0;
|
|
|
|
colSec[1] = 0;
|
|
|
|
colSec[2] = 0;
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
|
|
|
//set to random hue SR=0->1st SR=1->2nd
|
|
|
|
pos = req.indexOf("SR");
|
|
|
|
if (pos > 0) {
|
|
|
|
_setRandomColor(req.substring(pos + 3).toInt());
|
|
|
|
}
|
|
|
|
//set 2nd to 1st
|
|
|
|
pos = req.indexOf("SP");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
colSec[0] = col[0];
|
|
|
|
colSec[1] = col[1];
|
|
|
|
colSec[2] = col[2];
|
|
|
|
whiteSec = white;
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
|
|
|
//swap 2nd & 1st
|
|
|
|
pos = req.indexOf("SC");
|
|
|
|
if (pos > 0) {
|
2018-03-14 13:16:28 +01:00
|
|
|
byte _temp[4];
|
2017-12-11 23:59:12 +01:00
|
|
|
for (int i = 0; i<3; i++)
|
|
|
|
{
|
|
|
|
_temp[i] = col[i];
|
2018-03-14 13:16:28 +01:00
|
|
|
col[i] = colSec[i];
|
|
|
|
colSec[i] = _temp[i];
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
|
|
|
_temp[3] = white;
|
2018-03-14 13:16:28 +01:00
|
|
|
white = whiteSec;
|
|
|
|
whiteSec = _temp[3];
|
2017-12-11 23:59:12 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2017-11-19 15:31:17 +01:00
|
|
|
//set current effect index
|
2016-12-14 21:40:09 +01:00
|
|
|
pos = req.indexOf("FX=");
|
|
|
|
if (pos > 0) {
|
2016-12-17 23:43:07 +01:00
|
|
|
if (effectCurrent != req.substring(pos + 3).toInt())
|
|
|
|
{
|
|
|
|
effectCurrent = req.substring(pos + 3).toInt();
|
|
|
|
strip.setMode(effectCurrent);
|
|
|
|
effectUpdated = true;
|
|
|
|
}
|
2016-12-14 21:40:09 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set effect speed
|
2016-12-31 00:38:51 +01:00
|
|
|
pos = req.indexOf("SX=");
|
2016-12-14 21:40:09 +01:00
|
|
|
if (pos > 0) {
|
2016-12-17 23:43:07 +01:00
|
|
|
if (effectSpeed != req.substring(pos + 3).toInt())
|
|
|
|
{
|
|
|
|
effectSpeed = req.substring(pos + 3).toInt();
|
|
|
|
strip.setSpeed(effectSpeed);
|
|
|
|
effectUpdated = true;
|
|
|
|
}
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
//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;
|
|
|
|
}
|
|
|
|
}
|
2018-02-28 00:27:10 +01:00
|
|
|
|
|
|
|
//set hue polling light: 0 -off
|
|
|
|
pos = req.indexOf("HP=");
|
|
|
|
if (pos > 0) {
|
|
|
|
int id = req.substring(pos + 3).toInt();
|
|
|
|
if (id > 0)
|
|
|
|
{
|
|
|
|
if (id < 100) huePollLightId = id;
|
|
|
|
setupHue();
|
|
|
|
} else {
|
|
|
|
huePollingEnabled = false;
|
|
|
|
}
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2017-11-19 15:31:17 +01:00
|
|
|
//set default control mode (0 - RGB, 1 - HSB)
|
2017-05-07 23:51:42 +02:00
|
|
|
pos = req.indexOf("MD=");
|
|
|
|
if (pos > 0) {
|
|
|
|
useHSB = req.substring(pos + 3).toInt();
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set advanced overlay
|
2016-12-31 21:10:33 +01:00
|
|
|
pos = req.indexOf("OL=");
|
|
|
|
if (pos > 0) {
|
|
|
|
overlayCurrent = req.substring(pos + 3).toInt();
|
|
|
|
strip.unlockAll();
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//set individual pixel (range) to current color
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&I=");
|
2016-12-17 23:43:07 +01:00
|
|
|
if (pos > 0){
|
2017-12-11 23:59:12 +01:00
|
|
|
int index = req.substring(pos + 3).toInt();
|
2016-12-17 23:43:07 +01:00
|
|
|
pos = req.indexOf("I2=");
|
|
|
|
if (pos > 0){
|
|
|
|
int index2 = req.substring(pos + 3).toInt();
|
|
|
|
strip.setRange(index, index2);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
strip.setIndividual(index);
|
|
|
|
}
|
2016-12-14 21:40:09 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//(un)lock pixel (ranges)
|
2017-11-29 23:56:02 +01:00
|
|
|
pos = req.indexOf("&L=");
|
2017-11-19 15:31:17 +01:00
|
|
|
if (pos > 0){
|
2017-11-29 23:56:02 +01:00
|
|
|
int index = req.substring(pos + 3).toInt();
|
2017-11-19 15:31:17 +01:00
|
|
|
pos = req.indexOf("L2=");
|
|
|
|
if (pos > 0){
|
|
|
|
int index2 = req.substring(pos + 3).toInt();
|
2017-12-12 15:54:23 +01:00
|
|
|
if (req.indexOf("UL") > 0)
|
2017-11-19 15:31:17 +01:00
|
|
|
{
|
|
|
|
strip.unlockRange(index, index2);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
strip.lockRange(index, index2);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
2017-12-12 15:54:23 +01:00
|
|
|
if (req.indexOf("UL") > 0)
|
2017-11-19 15:31:17 +01:00
|
|
|
{
|
|
|
|
strip.unlock(index);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
strip.lock(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-28 00:37:13 +01:00
|
|
|
//apply macro
|
|
|
|
pos = req.indexOf("&M=");
|
|
|
|
if (pos > 0) {
|
|
|
|
applyMacro(req.substring(pos + 3).toInt());
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//toggle send UDP direct notifications
|
2017-05-07 23:51:42 +02:00
|
|
|
if (req.indexOf("SN=") > 0)
|
2016-12-14 21:40:09 +01:00
|
|
|
{
|
2017-05-08 21:46:04 +02:00
|
|
|
notifyDirect = true;
|
2017-05-07 23:51:42 +02:00
|
|
|
if (req.indexOf("SN=0") > 0)
|
2016-12-14 21:40:09 +01:00
|
|
|
{
|
2017-05-08 21:46:04 +02:00
|
|
|
notifyDirect = false;
|
2016-12-14 21:40:09 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//toggle receive UDP direct notifications
|
2017-05-07 23:51:42 +02:00
|
|
|
if (req.indexOf("RN=") > 0)
|
2016-12-14 21:40:09 +01:00
|
|
|
{
|
|
|
|
receiveNotifications = true;
|
2017-05-07 23:51:42 +02:00
|
|
|
if (req.indexOf("RN=0") > 0)
|
2016-12-14 21:40:09 +01:00
|
|
|
{
|
|
|
|
receiveNotifications = false;
|
|
|
|
}
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//toggle nightlight mode
|
2018-02-23 01:33:32 +01:00
|
|
|
pos = req.indexOf("NL=");
|
|
|
|
if (pos > 0)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
|
|
|
if (req.indexOf("NL=0") > 0)
|
|
|
|
{
|
|
|
|
nightlightActive = false;
|
2018-03-14 13:16:28 +01:00
|
|
|
bri = briT;
|
2016-11-19 19:39:17 +01:00
|
|
|
} else {
|
|
|
|
nightlightActive = true;
|
2018-04-11 23:50:35 +02:00
|
|
|
if (req.indexOf("&ND") <= 0) nightlightDelayMins = req.substring(pos + 3).toInt();
|
2016-11-19 19:39:17 +01:00
|
|
|
nightlightStartTime = millis();
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 16:12:51 +01:00
|
|
|
//set nightlight target brightness
|
|
|
|
pos = req.indexOf("NT=");
|
|
|
|
if (pos > 0) {
|
2018-02-20 22:29:48 +01:00
|
|
|
nightlightTargetBri = req.substring(pos + 3).toInt();
|
2018-03-14 13:16:28 +01:00
|
|
|
nightlightActiveOld = false; //re-init
|
2017-12-19 16:12:51 +01:00
|
|
|
}
|
|
|
|
//toggle nightlight fade
|
|
|
|
if (req.indexOf("NF=") > 0)
|
|
|
|
{
|
|
|
|
if (req.indexOf("NF=0") > 0)
|
|
|
|
{
|
|
|
|
nightlightFade = false;
|
|
|
|
} else {
|
|
|
|
nightlightFade = true;
|
|
|
|
}
|
2018-03-14 13:16:28 +01:00
|
|
|
nightlightActiveOld = false; //re-init
|
2017-12-19 16:12:51 +01:00
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//toggle general purpose output
|
2017-01-27 22:59:01 +01:00
|
|
|
pos = req.indexOf("AX=");
|
|
|
|
if (pos > 0) {
|
2017-02-07 13:00:33 +01:00
|
|
|
auxTime = req.substring(pos + 3).toInt();
|
|
|
|
auxActive = true;
|
|
|
|
if (auxTime == 0) auxActive = false;
|
|
|
|
}
|
2018-04-11 23:50:35 +02:00
|
|
|
pos = req.indexOf("TT=");
|
|
|
|
if (pos > 0) {
|
|
|
|
transitionDelay = req.substring(pos + 3).toInt();
|
|
|
|
}
|
2017-11-19 15:31:17 +01:00
|
|
|
//main toggle on/off
|
2017-12-11 23:59:12 +01:00
|
|
|
pos = req.indexOf("&T=");
|
2017-02-07 13:00:33 +01:00
|
|
|
if (pos > 0) {
|
2017-12-11 23:59:12 +01:00
|
|
|
switch (req.substring(pos + 3).toInt())
|
2017-02-07 13:00:33 +01:00
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
case 0: if (bri != 0){briLast = bri; bri = 0;} break; //off
|
|
|
|
case 1: bri = briLast; break; //on
|
2017-02-07 13:00:33 +01:00
|
|
|
default: if (bri == 0) //toggle
|
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
bri = briLast;
|
2017-02-07 13:00:33 +01:00
|
|
|
} else
|
|
|
|
{
|
2018-03-14 13:16:28 +01:00
|
|
|
briLast = bri;
|
2017-02-07 13:00:33 +01:00
|
|
|
bri = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-01-27 22:59:01 +01:00
|
|
|
}
|
2017-12-11 23:59:12 +01:00
|
|
|
//set time (unix timestamp)
|
|
|
|
pos = req.indexOf("ST=");
|
|
|
|
if (pos > 0) {
|
|
|
|
setTime(req.substring(pos+3).toInt());
|
|
|
|
}
|
2017-12-28 00:37:13 +01:00
|
|
|
//set countdown goal (unix timestamp)
|
|
|
|
pos = req.indexOf("CT=");
|
|
|
|
if (pos > 0) {
|
|
|
|
countdownTime = req.substring(pos+3).toInt();
|
2018-01-14 00:53:16 +01:00
|
|
|
if (countdownTime - now() > 0) countdownOverTriggered = false;
|
2017-12-28 00:37:13 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2017-11-30 23:35:22 +01:00
|
|
|
//set custom chase data
|
|
|
|
bool _cc_updated = false;
|
2018-03-14 13:16:28 +01:00
|
|
|
pos = req.indexOf("C0="); if (pos > 0) {ccStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("C1="); if (pos > 0) {ccIndex1 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("C2="); if (pos > 0) {ccIndex2 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CP="); if (pos > 0) {ccNumPrimary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CS="); if (pos > 0) {ccNumSecondary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CM="); if (pos > 0) {ccStep = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CF="); if (pos > 0) {ccFromStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CE="); if (pos > 0) {ccFromEnd = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
if (_cc_updated) strip.setCustomChase(ccIndex1, ccIndex2, ccStart, ccNumPrimary, ccNumSecondary, ccStep, ccFromStart, ccFromEnd);
|
2017-12-02 23:58:22 +01:00
|
|
|
|
2017-11-30 23:35:22 +01:00
|
|
|
//set presets
|
2018-04-11 23:50:35 +02:00
|
|
|
if (req.indexOf("CY=") > 0) //preset cycle
|
|
|
|
{
|
|
|
|
presetCyclingEnabled = true;
|
|
|
|
if (req.indexOf("CY=0") > 0)
|
|
|
|
{
|
|
|
|
presetCyclingEnabled = false;
|
|
|
|
}
|
|
|
|
bool all = true;
|
|
|
|
if (req.indexOf("&PA") > 0)
|
|
|
|
{
|
|
|
|
presetCycleBri = true;
|
|
|
|
all = false;
|
|
|
|
}
|
|
|
|
if (req.indexOf("&PC") > 0)
|
|
|
|
{
|
|
|
|
presetCycleCol = true;
|
|
|
|
all = false;
|
|
|
|
}
|
|
|
|
if (req.indexOf("&PX") > 0)
|
|
|
|
{
|
|
|
|
presetCycleFx = true;
|
|
|
|
all = false;
|
|
|
|
}
|
|
|
|
if (all)
|
|
|
|
{
|
|
|
|
presetCycleBri = true;
|
|
|
|
presetCycleCol = true;
|
|
|
|
presetCycleFx = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos = req.indexOf("PT="); //sets cycle time in ms
|
|
|
|
if (pos > 0) {
|
|
|
|
int v = req.substring(pos + 3).toInt();
|
|
|
|
if (v > 49) presetCycleTime = v;
|
|
|
|
}
|
|
|
|
pos = req.indexOf("P1="); //sets first preset for cycle
|
|
|
|
if (pos > 0) presetCycleMin = req.substring(pos + 3).toInt();
|
|
|
|
|
|
|
|
pos = req.indexOf("P2="); //sets last preset for cycle
|
|
|
|
if (pos > 0) presetCycleMax = req.substring(pos + 3).toInt();
|
|
|
|
|
2017-11-30 23:35:22 +01:00
|
|
|
pos = req.indexOf("PS="); //saves current in preset
|
|
|
|
if (pos > 0) {
|
2017-12-02 23:58:22 +01:00
|
|
|
savePreset(req.substring(pos + 3).toInt());
|
|
|
|
}
|
|
|
|
pos = req.indexOf("PL="); //applies entire preset
|
|
|
|
if (pos > 0) {
|
|
|
|
applyPreset(req.substring(pos + 3).toInt(), true, true, true);
|
|
|
|
effectUpdated = true;
|
|
|
|
}
|
|
|
|
pos = req.indexOf("PA="); //applies brightness from preset
|
|
|
|
if (pos > 0) {
|
|
|
|
applyPreset(req.substring(pos + 3).toInt(), true, false, false);
|
|
|
|
}
|
|
|
|
pos = req.indexOf("PC="); //applies color from preset
|
|
|
|
if (pos > 0) {
|
|
|
|
applyPreset(req.substring(pos + 3).toInt(), false, true, false);
|
2017-11-30 23:35:22 +01:00
|
|
|
}
|
2017-12-02 23:58:22 +01:00
|
|
|
pos = req.indexOf("PX="); //applies effects from preset
|
2017-11-30 23:35:22 +01:00
|
|
|
if (pos > 0) {
|
2017-12-02 23:58:22 +01:00
|
|
|
applyPreset(req.substring(pos + 3).toInt(), false, false, true);
|
|
|
|
effectUpdated = true;
|
2017-11-30 23:35:22 +01:00
|
|
|
}
|
2018-03-06 23:47:08 +01:00
|
|
|
|
|
|
|
//cronixie
|
2017-12-16 00:04:04 +01:00
|
|
|
pos = req.indexOf("NX="); //sets digits to code
|
|
|
|
if (pos > 0) {
|
2018-03-06 23:47:08 +01:00
|
|
|
cronixieDisplay = req.substring(pos + 3, pos + 9);
|
|
|
|
setCronixie();
|
2017-12-16 00:04:04 +01:00
|
|
|
}
|
2017-12-28 00:37:13 +01:00
|
|
|
pos = req.indexOf("NM="); //mode, 1 countdown
|
2017-12-19 16:12:51 +01:00
|
|
|
if (pos > 0) {
|
2018-03-14 00:25:54 +01:00
|
|
|
countdownMode = true;
|
2017-12-28 00:37:13 +01:00
|
|
|
if (req.indexOf("NM=0") > 0)
|
|
|
|
{
|
2018-03-14 00:25:54 +01:00
|
|
|
countdownMode = false;
|
2017-12-28 00:37:13 +01:00
|
|
|
}
|
2017-12-19 16:12:51 +01:00
|
|
|
}
|
|
|
|
if (req.indexOf("NB=") > 0) //sets backlight
|
|
|
|
{
|
|
|
|
cronixieBacklight = true;
|
|
|
|
if (req.indexOf("NB=0") > 0)
|
|
|
|
{
|
|
|
|
cronixieBacklight = false;
|
|
|
|
}
|
2018-03-06 23:47:08 +01:00
|
|
|
if (overlayCurrent == 4) strip.setCronixieBacklight(cronixieBacklight);
|
|
|
|
overlayRefreshedTime = 0;
|
2017-12-19 16:12:51 +01:00
|
|
|
}
|
2018-03-06 23:47:08 +01:00
|
|
|
|
2017-11-19 15:31:17 +01:00
|
|
|
//internal call, does not send XML response
|
2017-02-21 23:59:47 +01:00
|
|
|
pos = req.indexOf("IN");
|
2017-12-28 00:37:13 +01:00
|
|
|
if (pos < 1) XML_response();
|
2017-11-19 15:31:17 +01:00
|
|
|
//do not send UDP notifications this time
|
2017-02-21 23:59:47 +01:00
|
|
|
pos = req.indexOf("NN");
|
|
|
|
if (pos > 0)
|
|
|
|
{
|
|
|
|
colorUpdated(5);
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-14 23:40:47 +01:00
|
|
|
if (effectUpdated)
|
|
|
|
{
|
|
|
|
colorUpdated(6);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
colorUpdated(1);
|
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
return true;
|
|
|
|
}
|