Fixed interaction of T and NL HTTP API commands (#1214)

This commit is contained in:
cschwinne 2020-10-02 12:30:17 +02:00
parent bf9360f374
commit 3107943af8
6 changed files with 21 additions and 17 deletions

View File

@ -2,6 +2,11 @@
### Development versions after the 0.10.2 release
#### Build 2010020
- Fixed interaction of `T` and `NL` HTTP API commands (#1214)
- Fixed an issue where Sunrise mode nightlight does not activate if toggled on simultaneously
#### Build 2009291
- Fixed MQTT bootloop (no F() macro, #1199)

View File

@ -180,7 +180,7 @@ bool deserializeState(JsonObject root)
if (tr >= 2) presetCycleTime = tr;
JsonObject nl = root[F("nl")];
nightlightActive = nl["on"] | nightlightActive;
nightlightActive = nl["on"] | nightlightActive;
nightlightDelayMins = nl[F("dur")] | nightlightDelayMins;
nightlightMode = nl[F("fade")] | nightlightMode; //deprecated
nightlightMode = nl[F("mode")] | nightlightMode;

View File

@ -134,7 +134,7 @@ void colorUpdated(int callMode)
if (bri > 0) briLast = bri;
//deactivate nightlight if target brightness is reached
if (bri == nightlightTargetBri && callMode != NOTIFIER_CALL_MODE_NO_NOTIFY) nightlightActive = false;
if (bri == nightlightTargetBri && callMode != NOTIFIER_CALL_MODE_NO_NOTIFY && nightlightMode != NL_MODE_SUN) nightlightActive = false;
if (fadeTransition)
{

View File

@ -613,6 +613,18 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf(F("RD="));
if (pos > 0) receiveDirect = (req.charAt(pos+3) != '0');
//main toggle on/off (parse before nightlight, #1214)
pos = req.indexOf(F("&T="));
if (pos > 0) {
nightlightActive = false; //always disable nightlight when toggling
switch (getNumVal(&req, pos))
{
case 0: if (bri != 0){briLast = bri; bri = 0;} break; //off, only if it was previously on
case 1: if (bri == 0) bri = briLast; break; //on, only if it was previously off
default: toggleOnOff(); //toggle
}
}
//toggle nightlight mode
bool aNlDef = false;
if (req.indexOf(F("&ND")) > 0) aNlDef = true;
@ -622,7 +634,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
if (req.charAt(pos+3) == '0')
{
nightlightActive = false;
bri = briT;
} else {
nightlightActive = true;
if (!aNlDef) nightlightDelayMins = getNumVal(&req, pos);
@ -664,18 +675,6 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
pos = req.indexOf(F("TT="));
if (pos > 0) transitionDelay = getNumVal(&req, pos);
//main toggle on/off
pos = req.indexOf(F("&T="));
if (pos > 0) {
nightlightActive = false; //always disable nightlight when toggling
switch (getNumVal(&req, pos))
{
case 0: if (bri != 0){briLast = bri; bri = 0;} break; //off, only if it was previously on
case 1: if (bri == 0) bri = briLast; break; //on, only if it was previously off
default: toggleOnOff(); //toggle
}
}
//Segment reverse
pos = req.indexOf(F("RV="));
if (pos > 0) strip.getSegment(main).setOption(SEG_OPTION_REVERSED, req.charAt(pos+3) != '0');

View File

@ -29,7 +29,7 @@ void WLED::reset()
bool oappendi(int i)
{
char s[11];
sprintf(s, "%ld", i);
sprintf(s, "%d", i);
return oappend(s);
}

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2009291
#define VERSION 2010020
// ESP8266-01 (blue) got too little storage space to work with all features of WLED. To use it, you must use ESP8266 Arduino Core v2.4.2 and the setting 512K(No SPIFFS).