From b73aaecd22f1e2d70e03e3b33adb0c58833b2488 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 21 Jun 2021 13:22:14 +0200 Subject: [PATCH 1/5] Fix 4MB 1MB FS partition table --- CHANGELOG.md | 4 ++++ tools/WLED_ESP32_4MB_1MB_FS.csv | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2321c9a0..2c2bb00c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Builds after release 0.12.0 +#### Build 2106200 + +- Added 2 Ethernet boards and split Ethernet configs into separate file + #### Build 2106180 - Fixed DOS on Chrome tab restore causing reboot diff --git a/tools/WLED_ESP32_4MB_1MB_FS.csv b/tools/WLED_ESP32_4MB_1MB_FS.csv index 09455c6a..5dec3c06 100644 --- a/tools/WLED_ESP32_4MB_1MB_FS.csv +++ b/tools/WLED_ESP32_4MB_1MB_FS.csv @@ -1,6 +1,6 @@ # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, otadata, data, ota, 0xe000, 0x2000, -app0, app, ota_0, 0x10000, 0x17B000, -app1, app, ota_1, 0x18B000,0x17B000, -spiffs, data, spiffs, 0x306000,0x0FA000, \ No newline at end of file +app0, app, ota_0, 0x10000, 0x180000, +app1, app, ota_1, 0x190000,0x180000, +spiffs, data, spiffs, 0x310000,0xF0000, \ No newline at end of file From 660de0b4e573d8364ee4e4cd044e330dda71fc1f Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 24 Jun 2021 02:29:14 +0200 Subject: [PATCH 2/5] Auto-create segments based on configured busses --- tools/WLED_ESP32_16MB.csv | 6 ++++ usermods/EXAMPLE_v2/usermod_v2_example.h | 4 ++- wled00/FX.h | 2 +- wled00/FX_fcn.cpp | 41 +++++++++++++++++++----- wled00/wled.h | 2 +- 5 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 tools/WLED_ESP32_16MB.csv diff --git a/tools/WLED_ESP32_16MB.csv b/tools/WLED_ESP32_16MB.csv new file mode 100644 index 00000000..de78209d --- /dev/null +++ b/tools/WLED_ESP32_16MB.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x200000, +app1, app, ota_1, 0x210000,0x200000, +spiffs, data, spiffs, 0x410000,0xBE0000, \ No newline at end of file diff --git a/usermods/EXAMPLE_v2/usermod_v2_example.h b/usermods/EXAMPLE_v2/usermod_v2_example.h index ef68e907..db582a24 100644 --- a/usermods/EXAMPLE_v2/usermod_v2_example.h +++ b/usermods/EXAMPLE_v2/usermod_v2_example.h @@ -137,7 +137,9 @@ class MyExampleUsermod : public Usermod { void readFromConfig(JsonObject& root) { JsonObject top = root["top"]; - userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot) + if (!top.isNull()) { + userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot) + } } diff --git a/wled00/FX.h b/wled00/FX.h index 77638aed..541c8e4a 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -801,7 +801,7 @@ class WS2812FX { CRGBPalette16 currentPalette; CRGBPalette16 targetPalette; - uint16_t _length, _lengthRaw, _virtualSegmentLength; + uint16_t _length, _virtualSegmentLength; uint16_t _rand16seed; uint8_t _brightness; uint16_t _usedSegmentData = 0; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 075988cd..81f9f689 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -60,12 +60,15 @@ #define DEFAULT_LED_TYPE TYPE_WS2812_RGB #endif +#if MAX_NUM_SEGMENTS < WLED_MAX_BUSSES + #error "Max segments must be at least max number of busses!" +#endif + //do not call this method from system context (network callback) void WS2812FX::finalizeInit(uint16_t countPixels) { RESET_RUNTIME; _length = countPixels; - _lengthRaw = _length; //if busses failed to load, add default (FS issue...) if (busses.getNumBusses() == 0) { @@ -77,7 +80,7 @@ void WS2812FX::finalizeInit(uint16_t countPixels) for (uint8_t i = 0; i < defNumBusses; i++) { uint8_t defPin[] = {defDataPins[i]}; uint16_t start = prevLen; - uint16_t count = _lengthRaw; + uint16_t count = _length; if (defNumBusses > 1 && defNumCounts) { count = defCounts[(i < defNumCounts) ? i : defNumCounts -1]; } @@ -89,22 +92,44 @@ void WS2812FX::finalizeInit(uint16_t countPixels) deserializeMap(); - //make segment 0 cover the entire strip - _segments[0].start = 0; - _segments[0].stop = _length; + uint16_t segStarts[MAX_NUM_SEGMENTS] = {0}; + uint16_t segStops [MAX_NUM_SEGMENTS] = {0}; setBrightness(_brightness); - #ifdef ESP8266 + //TODO make sure segments are only refreshed when bus config actually changed (new settings page) + //make one segment per bus + uint8_t s = 0; for (uint8_t i = 0; i < busses.getNumBusses(); i++) { Bus* b = busses.getBus(i); + + segStarts[s] = b->getStart(); + segStops[s] = segStarts[s] + b->getLength(); + + //check for overlap with previous segments + for (uint8_t j = 0; j < s; j++) { + if (segStops[j] > segStarts[s] && segStarts[j] < segStops[s]) { + //segments overlap, merge + segStarts[j] = min(segStarts[s],segStarts[j]); + segStops [j] = max(segStops [s],segStops [j]); segStops[s] = 0; + s--; + } + } + s++; + + #ifdef ESP8266 if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue; uint8_t pins[5]; b->getPins(pins); BusDigital* bd = static_cast(b); if (pins[0] == 3) bd->reinit(); + #endif + } + + for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { + _segments[i].start = segStarts[i]; + _segments[i].stop = segStops [i]; } - #endif } void WS2812FX::service() { @@ -503,7 +528,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i) if (i < customMappingSize) i = customMappingTable[i]; - if (i >= _lengthRaw) return 0; + if (i >= _length) return 0; return busses.getPixelColor(i); } diff --git a/wled00/wled.h b/wled00/wled.h index a04a9d61..b562f452 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2106200 +#define VERSION 2106240 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG From 1e5420e6a7582adb34f9953ae293e8907d3cdd59 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 25 Jun 2021 01:26:15 +0200 Subject: [PATCH 3/5] readFromConfig() update --- CHANGELOG.md | 6 ++++++ .../Animated_Staircase/Animated_Staircase.h | 6 +++++- usermods/EXAMPLE_v2/usermod_v2_example.h | 21 ++++++++++++++++--- .../usermod_Fix_unreachable_netservices.h | 4 +++- .../usermod_PIR_sensor_switch.h | 6 ++++-- .../usermod_sn_photoresistor.h | 4 +++- usermods/Temperature/usermod_temperature.h | 8 +++++-- usermods/multi_relay/usermod_multi_relay.h | 5 +++-- .../stairway-wipe-usermod-v2.h | 12 ----------- .../usermod_v2_auto_save.h | 5 +++-- .../usermod_v2_four_line_display.h | 7 ++++++- wled00/cfg.cpp | 10 +++++---- wled00/data/welcome.htm | 1 - wled00/fcn_declare.h | 4 ++-- wled00/html_other.h | 2 +- wled00/um_manager.cpp | 8 ++++++- wled00/usermods_list.cpp | 5 +++-- wled00/wled_eeprom.cpp | 4 ++++ 18 files changed, 80 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c2bb00c..8e6864f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ### Builds after release 0.12.0 +#### Build 2106241 + +- BREAKING: Added ability for usermods to force a config save if config incomplete. `readFromConfig()` needs to return a `bool` to indicate if the config is complete +- Updated usermods implementing `readFromConfig()` +- Auto-create segments based on configured busses + #### Build 2106200 - Added 2 Ethernet boards and split Ethernet configs into separate file diff --git a/usermods/Animated_Staircase/Animated_Staircase.h b/usermods/Animated_Staircase/Animated_Staircase.h index 696d33f3..e85db95b 100644 --- a/usermods/Animated_Staircase/Animated_Staircase.h +++ b/usermods/Animated_Staircase/Animated_Staircase.h @@ -427,7 +427,7 @@ class Animated_Staircase : public Usermod { /* * Reads the configuration to internal flash memory before setup() is called. */ - void readFromConfig(JsonObject& root) { + bool readFromConfig(JsonObject& root) { bool oldUseUSSensorTop = useUSSensorTop; bool oldUseUSSensorBottom = useUSSensorBottom; int8_t oldTopAPin = topPIRorTriggerPin; @@ -435,6 +435,8 @@ class Animated_Staircase : public Usermod { int8_t oldBottomAPin = bottomPIRorTriggerPin; int8_t oldBottomBPin = bottomEchoPin; + bool configComplete = true; + JsonObject staircase = root[FPSTR(_name)]; if (!staircase.isNull()) { if (staircase[FPSTR(_enabled)].is()) { @@ -468,6 +470,7 @@ class Animated_Staircase : public Usermod { bottomMaxDist = min(150,max(30,staircase[FPSTR(_bottomEchoCm)].as())); // max distance ~1.5m (a lag of 9ms may be expected) } else { DEBUG_PRINTLN(F("No config found. (Using defaults.)")); + configComplete = false; } if (!initDone) { // first run: reading from cfg.json @@ -490,6 +493,7 @@ class Animated_Staircase : public Usermod { } if (changed) setup(); } + return configComplete; } /* diff --git a/usermods/EXAMPLE_v2/usermod_v2_example.h b/usermods/EXAMPLE_v2/usermod_v2_example.h index db582a24..ac466935 100644 --- a/usermods/EXAMPLE_v2/usermod_v2_example.h +++ b/usermods/EXAMPLE_v2/usermod_v2_example.h @@ -133,13 +133,28 @@ class MyExampleUsermod : public Usermod { * readFromConfig() is called BEFORE setup(). This means you can use your persistent values in setup() (e.g. pin assignments, buffer sizes), * but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup. * If you don't know what that is, don't fret. It most likely doesn't affect your use case :) + * + * Return true in case your config was complete, or false if you'd like WLED to save your defaults to disk + * + * This function is guaranteed to be called on boot, but could also be called every time settings are updated */ - void readFromConfig(JsonObject& root) + bool readFromConfig(JsonObject& root) { - JsonObject top = root["top"]; + userVar0 = 42; //set your variables to their boot default value (this can also be done when declaring the variable) + + JsonObject top = root["exampleUsermod"]; if (!top.isNull()) { - userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot) + bool configComplete = true; + + //check if value is there + if (top.containsKey("great")) { + //convert value to the correct type + userVar0 = top["great"].as(); + } else configComplete = false; + + if (configComplete) return true; } + return false; } diff --git a/usermods/Fix_unreachable_netservices_v2/usermod_Fix_unreachable_netservices.h b/usermods/Fix_unreachable_netservices_v2/usermod_Fix_unreachable_netservices.h index cb2f1b0c..2e9f43c6 100644 --- a/usermods/Fix_unreachable_netservices_v2/usermod_Fix_unreachable_netservices.h +++ b/usermods/Fix_unreachable_netservices_v2/usermod_Fix_unreachable_netservices.h @@ -149,11 +149,13 @@ Delay ())); // check bounds @@ -399,6 +399,8 @@ public: DEBUG_PRINTLN(F("PIR config (re)loaded.")); } } + + return true; } /** diff --git a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h index 3fd1fafa..ac86f390 100644 --- a/usermods/SN_Photoresistor/usermod_sn_photoresistor.h +++ b/usermods/SN_Photoresistor/usermod_sn_photoresistor.h @@ -169,7 +169,7 @@ public: /** * readFromConfig() is called before setup() to populate properties from values stored in cfg.json */ - void readFromConfig(JsonObject &root) + bool readFromConfig(JsonObject &root) { // we look for JSON object. JsonObject top = root[FPSTR(_name)]; @@ -196,7 +196,9 @@ public: else { DEBUG_PRINTLN(F("No config found. (Using defaults.)")); + return false; } + return true; } }; diff --git a/usermods/Temperature/usermod_temperature.h b/usermods/Temperature/usermod_temperature.h index 3a6bbfc4..8b418dc4 100644 --- a/usermods/Temperature/usermod_temperature.h +++ b/usermods/Temperature/usermod_temperature.h @@ -249,11 +249,13 @@ class UsermodTemperature : public Usermod { /** * readFromConfig() is called before setup() to populate properties from values stored in cfg.json */ - void readFromConfig(JsonObject &root) { + bool readFromConfig(JsonObject &root) { // we look for JSON object: {"Temperature": {"pin": 0, "degC": true}} JsonObject top = root[FPSTR(_name)]; int8_t newTemperaturePin = temperaturePin; + bool configComplete = true; + if (!top.isNull() && top["pin"] != nullptr) { if (top[FPSTR(_enabled)].is()) { disabled = !top[FPSTR(_enabled)].as(); @@ -274,13 +276,14 @@ class UsermodTemperature : public Usermod { DEBUG_PRINTLN(F("Temperature config (re)loaded.")); } else { DEBUG_PRINTLN(F("No config found. (Using defaults.)")); + configComplete = false; } if (!initDone) { // first run: reading from cfg.json temperaturePin = newTemperaturePin; } else { - // changing paramters from settings page + // changing parameters from settings page if (newTemperaturePin != temperaturePin) { // deallocate pin and release memory delete oneWire; @@ -290,6 +293,7 @@ class UsermodTemperature : public Usermod { setup(); } } + return configComplete; } uint16_t getId() diff --git a/usermods/multi_relay/usermod_multi_relay.h b/usermods/multi_relay/usermod_multi_relay.h index 42fe39e4..36e35ec4 100644 --- a/usermods/multi_relay/usermod_multi_relay.h +++ b/usermods/multi_relay/usermod_multi_relay.h @@ -348,11 +348,11 @@ class MultiRelay : public Usermod { * restore the changeable values * readFromConfig() is called before setup() to populate properties from values stored in cfg.json */ - void readFromConfig(JsonObject &root) { + bool readFromConfig(JsonObject &root) { int8_t oldPin[MULTI_RELAY_MAX_RELAYS]; JsonObject top = root[FPSTR(_name)]; - if (top.isNull()) return; + if (top.isNull()) return false; if (top[FPSTR(_enabled)] != nullptr) { if (top[FPSTR(_enabled)].is()) { @@ -413,6 +413,7 @@ class MultiRelay : public Usermod { } DEBUG_PRINTLN(F("MultiRelay config (re)loaded.")); } + return true; } /** diff --git a/usermods/stairway_wipe_basic/stairway-wipe-usermod-v2.h b/usermods/stairway_wipe_basic/stairway-wipe-usermod-v2.h index 8d8bcf0b..816b6e8d 100644 --- a/usermods/stairway_wipe_basic/stairway-wipe-usermod-v2.h +++ b/usermods/stairway_wipe_basic/stairway-wipe-usermod-v2.h @@ -82,18 +82,6 @@ class StairwayWipeUsermod : public Usermod { //if (root["bri"] == 255) Serial.println(F("Don't burn down your garage!")); } - void addToConfig(JsonObject& root) - { - JsonObject top = root.createNestedObject("exampleUsermod"); - top["great"] = userVar0; //save this var persistently whenever settings are saved - } - - void readFromConfig(JsonObject& root) - { - JsonObject top = root["top"]; - userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot) - } - uint16_t getId() { return USERMOD_ID_EXAMPLE; diff --git a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h index caf542e5..e0f45da4 100644 --- a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h +++ b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h @@ -198,12 +198,12 @@ class AutoSaveUsermod : public Usermod { * but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup. * If you don't know what that is, don't fret. It most likely doesn't affect your use case :) */ - void readFromConfig(JsonObject& root) { + bool readFromConfig(JsonObject& root) { // we look for JSON object: {"Autosave": {"autoSaveAfterSec": 10, "autoSavePreset": 99}} JsonObject top = root[FPSTR(_name)]; if (top.isNull()) { DEBUG_PRINTLN(F("No config found. (Using defaults.)")); - return; + return false; } if (top[FPSTR(_autoSaveEnabled)].is()) { @@ -225,6 +225,7 @@ class AutoSaveUsermod : public Usermod { applyAutoSaveOnBoot = (bool)(str!="off"); // off is guaranteed to be present } DEBUG_PRINTLN(F("Autosave config (re)loaded.")); + return true; } /* diff --git a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h index 999054e5..84593b38 100644 --- a/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h +++ b/usermods/usermod_v2_four_line_display/usermod_v2_four_line_display.h @@ -615,12 +615,14 @@ class FourLineDisplayUsermod : public Usermod { * but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup. * If you don't know what that is, don't fret. It most likely doesn't affect your use case :) */ - void readFromConfig(JsonObject& root) { + bool readFromConfig(JsonObject& root) { bool needsRedraw = false; DisplayType newType = type; int8_t newScl = sclPin; int8_t newSda = sdaPin; + bool configComplete = true; + JsonObject top = root[FPSTR(_name)]; if (!top.isNull() && top["pin"] != nullptr) { newScl = top["pin"][0]; @@ -653,6 +655,7 @@ class FourLineDisplayUsermod : public Usermod { DEBUG_PRINTLN(F("4 Line Display config (re)loaded.")); } else { DEBUG_PRINTLN(F("No config found. (Using defaults.)")); + configComplete = false; } if (!initDone) { @@ -684,6 +687,8 @@ class FourLineDisplayUsermod : public Usermod { setFlipMode(flip); if (needsRedraw && !wakeDisplay()) redraw(true); } + + return configComplete; } /* diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index a65d0434..17047387 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -410,7 +410,10 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { DEBUG_PRINTLN(F("Starting usermod config.")); JsonObject usermods_settings = doc["um"]; - if (!usermods_settings.isNull()) usermods.readFromConfig(usermods_settings); + if (!usermods_settings.isNull()) { + bool allComplete = usermods.readFromConfig(usermods_settings); + if (!allComplete && fromFS) serializeConfig(); + } if (fromFS) return false; doReboot = doc[F("rb")] | doReboot; @@ -418,11 +421,10 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } void deserializeConfigFromFS() { - bool fromeep = false; bool success = deserializeConfigSec(); if (!success) { //if file does not exist, try reading from EEPROM deEEPSettings(); - fromeep = true; + return; } DynamicJsonDocument doc(JSON_BUFFER_SIZE); @@ -431,7 +433,7 @@ void deserializeConfigFromFS() { success = readObjectFromFile("/cfg.json", nullptr, &doc); if (!success) { //if file does not exist, try reading from EEPROM - if (!fromeep) deEEPSettings(); + deEEPSettings(); return; } diff --git a/wled00/data/welcome.htm b/wled00/data/welcome.htm index 1b2bb60f..8d02e665 100644 --- a/wled00/data/welcome.htm +++ b/wled00/data/welcome.htm @@ -27,7 +27,6 @@ color: white; border: 0px solid white; border-radius: 25px; - filter: drop-shadow(0px 0px 1px #000); } img { diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index e624e524..405c14f2 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -189,7 +189,7 @@ class Usermod { virtual void addToJsonInfo(JsonObject& obj) {} virtual void readFromJsonState(JsonObject& obj) {} virtual void addToConfig(JsonObject& obj) {} - virtual void readFromConfig(JsonObject& obj) {} + virtual bool readFromConfig(JsonObject& obj) { return true; } //Heads up! readFromConfig() now needs to return a bool virtual void onMqttConnect(bool sessionPresent) {} virtual bool onMqttMessage(char* topic, char* payload) { return false; } virtual uint16_t getId() {return USERMOD_ID_UNSPECIFIED;} @@ -211,7 +211,7 @@ class UsermodManager { void readFromJsonState(JsonObject& obj); void addToConfig(JsonObject& obj); - void readFromConfig(JsonObject& obj); + bool readFromConfig(JsonObject& obj); void onMqttConnect(bool sessionPresent); bool onMqttMessage(char* topic, char* payload); bool add(Usermod* um); diff --git a/wled00/html_other.h b/wled00/html_other.h index 19d6667e..ecc68af7 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -55,7 +55,7 @@ Please do not close or refresh the page :))====="; const char PAGE_welcome[] PROGMEM = R"=====(Welcome!

Welcome to WLED!

diff --git a/wled00/um_manager.cpp b/wled00/um_manager.cpp index e516be17..040a8450 100644 --- a/wled00/um_manager.cpp +++ b/wled00/um_manager.cpp @@ -13,7 +13,13 @@ void UsermodManager::addToJsonState(JsonObject& obj) { for (byte i = 0; i < n void UsermodManager::addToJsonInfo(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToJsonInfo(obj); } void UsermodManager::readFromJsonState(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->readFromJsonState(obj); } void UsermodManager::addToConfig(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->addToConfig(obj); } -void UsermodManager::readFromConfig(JsonObject& obj) { for (byte i = 0; i < numMods; i++) ums[i]->readFromConfig(obj); } +bool UsermodManager::readFromConfig(JsonObject& obj) { + bool allComplete = true; + for (byte i = 0; i < numMods; i++) { + if (!ums[i]->readFromConfig(obj)) allComplete = false; + } + return allComplete; +} void UsermodManager::onMqttConnect(bool sessionPresent) { for (byte i = 0; i < numMods; i++) ums[i]->onMqttConnect(sessionPresent); } bool UsermodManager::onMqttMessage(char* topic, char* payload) { for (byte i = 0; i < numMods; i++) if (ums[i]->onMqttMessage(topic, payload)) return true; diff --git a/wled00/usermods_list.cpp b/wled00/usermods_list.cpp index e1586a23..4f95dcdd 100644 --- a/wled00/usermods_list.cpp +++ b/wled00/usermods_list.cpp @@ -9,7 +9,8 @@ * || || || * \/ \/ \/ */ -//#include "usermod_v2_example.h" +#include "../usermods/EXAMPLE_v2/usermod_v2_example.h" + #ifdef USERMOD_DALLASTEMPERATURE #include "../usermods/Temperature/usermod_temperature.h" #endif @@ -80,7 +81,7 @@ void registerUsermods() * || || || * \/ \/ \/ */ - //usermods.add(new MyExampleUsermod()); + usermods.add(new MyExampleUsermod()); #ifdef USERMOD_DALLASTEMPERATURE usermods.add(new UsermodTemperature()); diff --git a/wled00/wled_eeprom.cpp b/wled00/wled_eeprom.cpp index f1fd7b5a..bab8d305 100644 --- a/wled00/wled_eeprom.cpp +++ b/wled00/wled_eeprom.cpp @@ -479,5 +479,9 @@ void deEEPSettings() { loadSettingsFromEEPROM(); EEPROM.end(); + //call readFromConfig() with an empty object so that usermods can initialize to defaults prior to saving + JsonObject empty = JsonObject(); + usermods.readFromConfig(empty); + serializeConfig(); } \ No newline at end of file From 4cd3a614decddfe0d8bad879d1e8ba9af7a2c4af Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 25 Jun 2021 10:12:21 +0200 Subject: [PATCH 4/5] Fixed preset only disabling on second effect/color change (fixes #2038 ) --- CHANGELOG.md | 4 ++++ wled00/led.cpp | 3 +-- wled00/presets.cpp | 1 - wled00/wled.h | 3 +-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e6864f9..0877c494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ### Builds after release 0.12.0 +#### Build 2106250 + +- Fixed preset only disabling on second effect/color change + #### Build 2106241 - BREAKING: Added ability for usermods to force a config save if config incomplete. `readFromConfig()` needs to return a `bool` to indicate if the config is complete diff --git a/wled00/led.cpp b/wled00/led.cpp index 2a9daee4..9abe9412 100644 --- a/wled00/led.cpp +++ b/wled00/led.cpp @@ -111,8 +111,7 @@ void colorUpdated(int callMode) { effectChanged = false; if (realtimeTimeout == UINT32_MAX) realtimeTimeout = 0; - if (isPreset) {isPreset = false;} - else {currentPreset = -1;} + currentPreset = -1; //something changed, so we are no longer in the preset notify(callMode); diff --git a/wled00/presets.cpp b/wled00/presets.cpp index 568ff5fc..cdbd82a3 100644 --- a/wled00/presets.cpp +++ b/wled00/presets.cpp @@ -29,7 +29,6 @@ bool applyPreset(byte index) if (!errorFlag) { currentPreset = index; - isPreset = true; return true; } return false; diff --git a/wled00/wled.h b/wled00/wled.h index b562f452..6c989a1d 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2106240 +#define VERSION 2106250 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -562,7 +562,6 @@ WLED_GLOBAL bool doCloseFile _INIT(false); // presets WLED_GLOBAL int16_t currentPreset _INIT(-1); -WLED_GLOBAL bool isPreset _INIT(false); WLED_GLOBAL byte errorFlag _INIT(0); From af9aa7d20127cb1f62ec5f0f60058a408dc62688 Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 25 Jun 2021 12:15:23 +0200 Subject: [PATCH 5/5] Do not compile in example usermod --- wled00/usermods_list.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/usermods_list.cpp b/wled00/usermods_list.cpp index 4f95dcdd..21a7de8d 100644 --- a/wled00/usermods_list.cpp +++ b/wled00/usermods_list.cpp @@ -9,7 +9,7 @@ * || || || * \/ \/ \/ */ -#include "../usermods/EXAMPLE_v2/usermod_v2_example.h" +//#include "../usermods/EXAMPLE_v2/usermod_v2_example.h" #ifdef USERMOD_DALLASTEMPERATURE #include "../usermods/Temperature/usermod_temperature.h" @@ -81,7 +81,7 @@ void registerUsermods() * || || || * \/ \/ \/ */ - usermods.add(new MyExampleUsermod()); + //usermods.add(new MyExampleUsermod()); #ifdef USERMOD_DALLASTEMPERATURE usermods.add(new UsermodTemperature());