2016-12-31 00:38:51 +01:00
|
|
|
/*
|
|
|
|
* Receives client input
|
|
|
|
*/
|
|
|
|
|
2017-12-11 23:59:12 +01:00
|
|
|
void _setRandomColor(bool _sec)
|
|
|
|
{
|
|
|
|
lastRandomIndex = strip.get_random_wheel_index(lastRandomIndex);
|
|
|
|
uint32_t _color = strip.color_wheel(lastRandomIndex);
|
|
|
|
if (_sec){
|
|
|
|
white_sec = ((_color >> 24) & 0xFF);
|
|
|
|
col_sec[0] = ((_color >> 16) & 0xFF);
|
|
|
|
col_sec[1] = ((_color >> 8) & 0xFF);
|
|
|
|
col_sec[2] = (_color & 0xFF);
|
|
|
|
} else {
|
|
|
|
white = ((_color >> 24) & 0xFF);
|
|
|
|
col[0] = ((_color >> 16) & 0xFF);
|
|
|
|
col[1] = ((_color >> 8) & 0xFF);
|
|
|
|
col[2] = (_color & 0xFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-20 22:29:48 +01:00
|
|
|
void handleSettingsSet(uint8_t 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-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSSID")) clientssid = server.arg("CSSID");
|
|
|
|
if (server.hasArg("CPASS"))
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
if (!server.arg("CPASS").indexOf('*') == 0)
|
|
|
|
{
|
|
|
|
DEBUG_PRINTLN("Setting pass");
|
|
|
|
clientpass = server.arg("CPASS");
|
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CMDNS")) cmdns = server.arg("CMDNS");
|
|
|
|
if (server.hasArg("APWTM"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("APWTM").toInt();
|
|
|
|
if (i >= 0 && i <= 255) apWaitTimeSecs = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("APSSID")) apssid = server.arg("APSSID");
|
|
|
|
aphide = server.hasArg("APHSSID");
|
|
|
|
if (server.hasArg("APPASS"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
if (!server.arg("APPASS").indexOf('*') == 0) appass = server.arg("APPASS");
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("APCHAN"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int chan = server.arg("APCHAN").toInt();
|
|
|
|
if (chan > 0 && chan < 14) apchannel = chan;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSIP0"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSIP0").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticip[0] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSIP1"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSIP1").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticip[1] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSIP2"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSIP2").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticip[2] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSIP3"))
|
2018-01-27 23:28:20 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSIP3").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticip[3] = i;
|
2018-01-27 23:28:20 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSGW0"))
|
2017-10-12 17:09:59 +02:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSGW0").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticgateway[0] = i;
|
2017-10-12 17:09:59 +02:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSGW1"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSGW1").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticgateway[1] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSGW2"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSGW2").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticgateway[2] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("CSGW3"))
|
2016-12-29 00:03:58 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
int i = server.arg("CSGW3").toInt();
|
|
|
|
if (i >= 0 && i <= 255) staticgateway[3] = i;
|
2016-12-29 00:03:58 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
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;
|
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-02-20 22:29:48 +01:00
|
|
|
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;
|
|
|
|
}
|
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-02-20 22:29:48 +01:00
|
|
|
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();
|
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-02-20 22:29:48 +01:00
|
|
|
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");
|
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-02-20 22:29:48 +01:00
|
|
|
ntpEnabled = server.hasArg("NTPON");
|
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-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("RESET"))
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
clearEEPROM();
|
|
|
|
serveMessage(200, "All Settings erased.", "Rebooting...");
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (server.hasArg("OPASS"))
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
if (!otaLock)
|
|
|
|
{
|
|
|
|
if (server.arg("OPASS").length() > 0)
|
|
|
|
otapass = server.arg("OPASS");
|
|
|
|
} else if (!server.hasArg("NOOTA"))
|
2016-11-20 01:47:15 +01:00
|
|
|
{
|
2018-02-20 22:29:48 +01:00
|
|
|
if (otapass.equals(server.arg("OPASS")))
|
|
|
|
{
|
|
|
|
otaLock = false;
|
|
|
|
}
|
2016-11-20 01:47:15 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
if (server.hasArg("NOOTA")) otaLock = true;
|
|
|
|
if (!otaLock)
|
|
|
|
{
|
|
|
|
recoveryAPDisabled = server.hasArg("NORAP");
|
|
|
|
aOtaEnabled = server.hasArg("AROTA");
|
|
|
|
}
|
2016-11-20 01:47:15 +01:00
|
|
|
}
|
2018-02-20 22:29:48 +01:00
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
saveSettingsToEEPROM();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean handleSet(String req)
|
|
|
|
{
|
2016-12-14 23:40:47 +01:00
|
|
|
boolean 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
|
|
|
}
|
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) {
|
|
|
|
col_sec[0] = req.substring(pos + 3).toInt();
|
|
|
|
}
|
|
|
|
//set 2nd green value
|
|
|
|
pos = req.indexOf("G2=");
|
|
|
|
if (pos > 0) {
|
|
|
|
col_sec[1] = req.substring(pos + 3).toInt();
|
|
|
|
}
|
|
|
|
//set 2nd blue value
|
|
|
|
pos = req.indexOf("B2=");
|
|
|
|
if (pos > 0) {
|
|
|
|
col_sec[2] = req.substring(pos + 3).toInt();
|
|
|
|
}
|
|
|
|
//set 2nd white value
|
|
|
|
pos = req.indexOf("W2=");
|
|
|
|
if (pos > 0) {
|
|
|
|
white_sec = req.substring(pos + 3).toInt();
|
|
|
|
}
|
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) {
|
|
|
|
white_sec = 255;
|
|
|
|
col_sec[0] = 0;
|
|
|
|
col_sec[1] = 0;
|
|
|
|
col_sec[2] = 0;
|
|
|
|
} else {
|
|
|
|
col_sec[0] = 255;
|
|
|
|
col_sec[1] = 255;
|
|
|
|
col_sec[2] = 255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//set 2nd to black
|
|
|
|
pos = req.indexOf("SB");
|
|
|
|
if (pos > 0) {
|
|
|
|
white_sec = 0;
|
|
|
|
col_sec[0] = 0;
|
|
|
|
col_sec[1] = 0;
|
|
|
|
col_sec[2] = 0;
|
|
|
|
}
|
|
|
|
//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) {
|
|
|
|
col_sec[0] = col[0];
|
|
|
|
col_sec[1] = col[1];
|
|
|
|
col_sec[2] = col[2];
|
|
|
|
white_sec = white;
|
|
|
|
}
|
|
|
|
//swap 2nd & 1st
|
|
|
|
pos = req.indexOf("SC");
|
|
|
|
if (pos > 0) {
|
|
|
|
uint8_t _temp[4];
|
|
|
|
for (int i = 0; i<3; i++)
|
|
|
|
{
|
|
|
|
_temp[i] = col[i];
|
|
|
|
col[i] = col_sec[i];
|
|
|
|
col_sec[i] = _temp[i];
|
|
|
|
}
|
|
|
|
_temp[3] = white;
|
|
|
|
white = white_sec;
|
|
|
|
white_sec = _temp[3];
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2016-11-19 19:39:17 +01:00
|
|
|
if (req.indexOf("NL=") > 0)
|
|
|
|
{
|
|
|
|
if (req.indexOf("NL=0") > 0)
|
|
|
|
{
|
|
|
|
nightlightActive = false;
|
2016-12-11 20:11:14 +01:00
|
|
|
bri = bri_t;
|
2016-11-19 19:39:17 +01:00
|
|
|
} else {
|
|
|
|
nightlightActive = true;
|
|
|
|
nightlightStartTime = millis();
|
|
|
|
}
|
|
|
|
}
|
2017-12-19 16:12:51 +01:00
|
|
|
//set nightlight delay
|
|
|
|
pos = req.indexOf("ND=");
|
|
|
|
if (pos > 0) {
|
|
|
|
nightlightDelayMins = req.substring(pos + 3).toInt();
|
|
|
|
nightlightActive_old = false; //re-init
|
|
|
|
}
|
|
|
|
//set nightlight target brightness
|
|
|
|
pos = req.indexOf("NT=");
|
|
|
|
if (pos > 0) {
|
2018-02-20 22:29:48 +01:00
|
|
|
nightlightTargetBri = req.substring(pos + 3).toInt();
|
2017-12-19 16:12:51 +01:00
|
|
|
nightlightActive_old = false; //re-init
|
|
|
|
}
|
|
|
|
//toggle nightlight fade
|
|
|
|
if (req.indexOf("NF=") > 0)
|
|
|
|
{
|
|
|
|
if (req.indexOf("NF=0") > 0)
|
|
|
|
{
|
|
|
|
nightlightFade = false;
|
|
|
|
} else {
|
|
|
|
nightlightFade = true;
|
|
|
|
}
|
|
|
|
nightlightActive_old = false; //re-init
|
|
|
|
}
|
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;
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
case 0: if (bri != 0){bri_last = bri; bri = 0;} break; //off
|
|
|
|
case 1: bri = bri_last; break; //on
|
|
|
|
default: if (bri == 0) //toggle
|
|
|
|
{
|
|
|
|
bri = bri_last;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
bri_last = bri;
|
|
|
|
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;
|
|
|
|
pos = req.indexOf("C0="); if (pos > 0) {cc_start = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("C1="); if (pos > 0) {cc_index1 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("C2="); if (pos > 0) {cc_index2 = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CP="); if (pos > 0) {cc_numPrimary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CS="); if (pos > 0) {cc_numSecondary = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CM="); if (pos > 0) {cc_step = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CF="); if (pos > 0) {cc_fromStart = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
pos = req.indexOf("CE="); if (pos > 0) {cc_fromEnd = (req.substring(pos + 3).toInt()); _cc_updated = true;}
|
|
|
|
if (_cc_updated) strip.setCustomChase(cc_index1, cc_index2, cc_start, cc_numPrimary, cc_numSecondary, cc_step, cc_fromStart, cc_fromEnd);
|
2017-12-02 23:58:22 +01:00
|
|
|
|
2017-11-30 23:35:22 +01:00
|
|
|
//set presets
|
|
|
|
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
|
|
|
}
|
2017-12-16 00:04:04 +01:00
|
|
|
#ifdef CRONIXIE
|
|
|
|
pos = req.indexOf("NX="); //sets digits to code
|
|
|
|
if (pos > 0) {
|
|
|
|
setCronixie(req.substring(pos + 3, pos + 9).c_str());
|
|
|
|
}
|
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) {
|
2017-12-28 00:37:13 +01:00
|
|
|
cronixieCountdown = true;
|
|
|
|
if (req.indexOf("NM=0") > 0)
|
|
|
|
{
|
|
|
|
cronixieCountdown = false;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
strip.setCronixieBacklight(cronixieBacklight);
|
|
|
|
cronixieRefreshedTime = 0;
|
|
|
|
}
|
2017-12-16 00:04:04 +01:00
|
|
|
#endif
|
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;
|
|
|
|
}
|