Add "np" API option to not commit

Re-add IRremote flags to platformio.ini
This commit is contained in:
cschwinne 2020-03-03 17:53:47 +01:00
parent f28502514f
commit 89fa053310
5 changed files with 26 additions and 8 deletions

View File

@ -102,6 +102,14 @@ debug_flags = -D DEBUG=1 -D WLED_DEBUG -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT
# ------------------------------------------------------------------------------
build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=1024 -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
-DSECURE_CLIENT=SECURE_CLIENT_BEARSSL -DBEARSSL_SSL_BASIC
#build_flags for the IRremoteESP8266 library (enabled decoders have to appear here)
-D _IR_ENABLE_DEFAULT_=false
-D DECODE_HASH=true
-D DECODE_NEC=true
-D DECODE_SONY=true
-D DECODE_SAMSUNG=true
-D DECODE_LG=true
build_flags_esp8266 = ${common.build_flags} -DESP8266
build_flags_esp32 = ${common.build_flags} -DARDUINO_ARCH_ESP32

View File

@ -119,7 +119,7 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2002292
#define VERSION 2003031
char versionString[] = "0.9.1";

View File

@ -621,7 +621,7 @@ bool applyPreset(byte index, bool loadBri = true)
return true;
}
void savePreset(byte index)
void savePreset(byte index, bool persist = true)
{
if (index > 16) return;
if (index < 1) {saveSettingsToEEPROM();return;}
@ -653,7 +653,7 @@ void savePreset(byte index)
memcpy(EEPROM.getDataPtr() +i+2, seg, 240);
}
commit();
if (persist) commit();
savedToPresets();
currentPreset = index;
isPreset = true;
@ -689,7 +689,7 @@ void applyMacro(byte index)
}
void saveMacro(byte index, String mc, bool sing=true) //only commit on single save, not in settings
void saveMacro(byte index, String mc, bool persist = true) //only commit on single save, not in settings
{
index-=1;
if (index > 15) return;
@ -698,5 +698,5 @@ void saveMacro(byte index, String mc, bool sing=true) //only commit on single sa
{
EEPROM.write(i, mc.charAt(i-s));
}
if (sing) commit();
if (persist) commit();
}

View File

@ -372,6 +372,13 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
DEBUG_PRINT("API req: ");
DEBUG_PRINTLN(req);
//write presets and macros saved to flash directly?
bool persistSaves = true;
pos = req.indexOf("NP");
if (pos > 0) {
persistSaves = false;
}
//save macro, requires &MS=<slot>(<macro>) format
pos = req.indexOf("&MS=");
if (pos > 0) {
@ -381,7 +388,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
int en = req.indexOf(')');
String mc = req.substring(pos);
if (en > 0) mc = req.substring(pos, en);
saveMacro(i, mc);
saveMacro(i, mc, persistSaves);
}
pos = req.indexOf("IN");
@ -461,7 +468,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
if (pos > 0) presetApplyBri = (req.charAt(pos+3) != '0');
pos = req.indexOf("PS="); //saves current in preset
if (pos > 0) savePreset(getNumVal(&req, pos));
if (pos > 0) savePreset(getNumVal(&req, pos), persistSaves);
//apply preset
if (updateVal(&req, "PL=", &presetCycCurr, presetCycleMin, presetCycleMax)) {

View File

@ -156,8 +156,11 @@ bool deserializeState(JsonObject root)
colorUpdated(noNotification ? NOTIFIER_CALL_MODE_NO_NOTIFY : NOTIFIER_CALL_MODE_DIRECT_CHANGE);
//write presets to flash directly?
bool persistSaves = !(root["np"] | false);
ps = root["psave"] | -1;
if (ps >= 0) savePreset(ps);
if (ps >= 0) savePreset(ps, persistSaves);
return stateResponse;
}