diff --git a/platformio.ini b/platformio.ini index 63ebc68f5..fbe7dd3b2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -365,5 +365,5 @@ build_flags = ${common.build_flags_esp8266} ${common.debug_flags} ${common.build [env:travis_esp32] extends = env:esp32dev -build_type = debug +; build_type = debug build_flags = ${common.build_flags_esp32} ${common.debug_flags} ${common.build_flags_all_features} diff --git a/wled00/file.cpp b/wled00/file.cpp index f96bf8f97..f4eeef07a 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -4,15 +4,6 @@ * Utility for SPIFFS filesystem */ -//filesystem -#ifndef WLED_DISABLE_FILESYSTEM -#include -#ifdef ARDUINO_ARCH_ESP32 -#include "SPIFFS.h" -#endif -#include "SPIFFSEditor.h" -#endif - #ifndef WLED_DISABLE_FILESYSTEM //find() that reads and buffers data from file stream in 256-byte blocks. @@ -62,7 +53,6 @@ bool bufferedFindSpace(uint16_t targetLen, File f) { #endif if (!f || !f.size()) return false; - DEBUGFS_PRINTF("Filesize %d\n", f.size()); uint16_t index = 0; uint16_t bufsize = 0, count = 0; @@ -94,7 +84,7 @@ bool bufferedFindSpace(uint16_t targetLen, File f) { bool appendObjectToFile(File f, const char* key, JsonDocument* content, uint32_t s) { #ifdef WLED_DEBUG_FS - DEBUG_PRINTLN("Append"); + DEBUGFS_PRINTLN("Append"); uint32_t s1 = millis(); #endif uint32_t pos = 0; @@ -108,6 +98,7 @@ bool appendObjectToFile(File f, const char* key, JsonDocument* content, uint32_t if (f.position() > 2) f.write(','); //add comma if not first object f.print(key); serializeJson(*content, f); + DEBUGFS_PRINTF("Inserted, took %d ms (total %d)", millis() - s1, millis() - s); return true; } @@ -188,7 +179,7 @@ bool writeObjectToFile(const char* file, const char* key, JsonDocument* content) if (!content->isNull() && measureJson(*content) <= oldLen) //replace { - DEBUG_PRINTLN("replace"); + DEBUGFS_PRINTLN("replace"); f.seek(pos); serializeJson(*content, f); //pad rest @@ -196,7 +187,7 @@ bool writeObjectToFile(const char* file, const char* key, JsonDocument* content) f.write(' '); } } else { //delete - DEBUG_PRINTLN("delete"); + DEBUGFS_PRINTLN("delete"); pos -= strlen(key); if (pos > 3) pos--; //also delete leading comma if not first object f.seek(pos); diff --git a/wled00/wled.h b/wled00/wled.h index db0b91d2a..8d8b83766 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -123,7 +123,11 @@ #endif //Filesystem to use for preset and config files. SPIFFS or LittleFS on ESP8266, SPIFFS only on ESP32 -#define WLED_FS LittleFS +#ifdef ESP8266 + #define WLED_FS LittleFS +#else + #define WLED_FS SPIFFS +#endif // remove flicker because PWM signal of RGB channels can become out of phase (part of core as of Arduino core v2.7.0) //#if defined(WLED_USE_ANALOG_LEDS) && defined(ESP8266) diff --git a/wled00/wled_eeprom.cpp b/wled00/wled_eeprom.cpp index 12836f16c..e8c9558b7 100644 --- a/wled00/wled_eeprom.cpp +++ b/wled00/wled_eeprom.cpp @@ -675,15 +675,17 @@ bool applyPreset(byte index, bool loadBri) void savePreset(byte index, bool persist, const char* pname, byte priority, JsonObject saveobj) { StaticJsonDocument<1024> doc; + JsonObject sObj = doc.to(); + if (saveobj.isNull()) { - Serial.println("Save current state"); + DEBUGFS_PRINTLN("Save current state"); serializeState(doc.to(), true); } else { - Serial.println("Save custom"); - doc = saveobj; + DEBUGFS_PRINTLN("Save custom"); + sObj.set(saveobj); } - doc["p"] = priority; - if (pname) doc["n"] = pname; + sObj["p"] = priority; + if (pname) sObj["n"] = pname; //serializeJson(doc, Serial); writeObjectToFileUsingId("/presets.json", index, &doc);