From 503835d47ef23be24c0bbe3a4976e07ddac8c3ea Mon Sep 17 00:00:00 2001 From: ingDIY <10012263+ingDIY@users.noreply.github.com> Date: Sun, 2 Oct 2022 23:23:24 +0200 Subject: [PATCH] submitting PR Here they are the PR #2776, #2803 and #2804 rebased for 0_14 branch, I hope that now they are OK! --- usermods/usermod_v2_auto_save/readme.md | 30 ++++++++++++------- .../usermod_v2_auto_save.h | 14 +++++++++ .../usermod_v2_rotary_encoder_ui/readme.md | 13 ++++---- .../usermod_v2_rotary_encoder_ui.h | 10 +++++-- .../usermod_v2_rotary_encoder_ui_ALT.h | 10 +++++-- wled00/const.h | 1 + wled00/wled.h | 16 +++++++--- 7 files changed, 68 insertions(+), 26 deletions(-) diff --git a/usermods/usermod_v2_auto_save/readme.md b/usermods/usermod_v2_auto_save/readme.md index 7cf81085..8d00fcca 100644 --- a/usermods/usermod_v2_auto_save/readme.md +++ b/usermods/usermod_v2_auto_save/readme.md @@ -1,20 +1,17 @@ # Auto Save -v2 Usermod to automatically save settings -to preset number AUTOSAVE_PRESET_NUM after a change to any of - +v2 Usermod to automatically save settings +to preset number AUTOSAVE_PRESET_NUM after a change to any of: * brightness * effect speed * effect intensity * mode (effect) * palette -but it will wait for AUTOSAVE_SETTLE_MS milliseconds, a "settle" -period in case there are other changes (any change will -extend the "settle" window). +but it will wait for AUTOSAVE_AFTER_SEC seconds, +a "settle" period in case there are other changes (any change will extend the "settle" window). -It will additionally load preset AUTOSAVE_PRESET_NUM at startup. -during the first `loop()`. Reasoning below. +It will additionally load preset AUTOSAVE_PRESET_NUM at startup during the first `loop()`. AutoSaveUsermod is standalone, but if FourLineDisplayUsermod is installed, it will notify the user of the saved changes. @@ -28,10 +25,21 @@ This file should be placed in the same directory as `platformio.ini`. ### Define Your Options -* `USERMOD_AUTO_SAVE` - define this to have this the Auto Save usermod included wled00\usermods_list.cpp -* `USERMOD_FOUR_LINE_DISPLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp - also tells this usermod that the display is available (see the Four Line Display usermod `readme.md` for more details) +* `USERMOD_AUTO_SAVE` - define this to have this the Auto Save usermod included wled00\usermods_list.cpp +* `AUTOSAVE_AFTER_SEC` - define the delay time after the settings auto-saving routine should be executed +* `AUTOSAVE_PRESET_NUM` - define the preset number used by autosave usermod +* `USERMOD_AUTO_SAVE_ON_BOOT` - define if autosave should be enabled on boot +* `USERMOD_FOUR_LINE_DISPLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp + also tells this usermod that the display is available + (see the Four Line Display usermod `readme.md` for more details) -You can configure auto-save parameters using Usermods settings page. +Example to add in platformio_override: + -D USERMOD_AUTO_SAVE + -D AUTOSAVE_AFTER_SEC=10 + -D AUTOSAVE_PRESET_NUM=100 + -D USERMOD_AUTO_SAVE_ON_BOOT=true + +You can also configure auto-save parameters using Usermods settings page. ### PlatformIO requirements 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 4cd728d8..41e0a7ec 100644 --- a/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h +++ b/usermods/usermod_v2_auto_save/usermod_v2_auto_save.h @@ -33,9 +33,23 @@ class AutoSaveUsermod : public Usermod { bool enabled = true; // configurable parameters + #ifdef AUTOSAVE_AFTER_SEC + uint16_t autoSaveAfterSec = AUTOSAVE_AFTER_SEC; + #else uint16_t autoSaveAfterSec = 15; // 15s by default + #endif + + #ifdef AUTOSAVE_PRESET_NUM + uint8_t autoSavePreset = AUTOSAVE_PRESET_NUM; + #else uint8_t autoSavePreset = 250; // last possible preset + #endif + + #ifdef USERMOD_AUTO_SAVE_ON_BOOT + bool applyAutoSaveOnBoot = USERMOD_AUTO_SAVE_ON_BOOT; + #else bool applyAutoSaveOnBoot = false; // do we load auto-saved preset on boot? + #endif // If we've detected the need to auto save, this will be non zero. unsigned long autoSaveAfter = 0; diff --git a/usermods/usermod_v2_rotary_encoder_ui/readme.md b/usermods/usermod_v2_rotary_encoder_ui/readme.md index 9bbcd6a6..c303743e 100644 --- a/usermods/usermod_v2_rotary_encoder_ui/readme.md +++ b/usermods/usermod_v2_rotary_encoder_ui/readme.md @@ -15,11 +15,14 @@ This file should be placed in the same directory as `platformio.ini`. ### Define Your Options -* `USERMOD_ROTARY_ENCODER_UI` - define this to have this user mod included wled00\usermods_list.cpp -* `USERMOD_FOUR_LINE_DISPLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp - also tells this usermod that the display is available (see the Four Line Display usermod `readme.md` for more details) -* `ENCODER_DT_PIN` - The encoders DT pin, defaults to 12 -* `ENCODER_CLK_PIN` - The encoders CLK pin, defaults to 14 -* `ENCODER_SW_PIN` - The encoders SW pin, defaults to 13 +* `USERMOD_ROTARY_ENCODER_UI` - define this to have this user mod included wled00\usermods_list.cpp +* `USERMOD_ROTARY_ENCODER_GPIO` - define the GPIO function (INPUT, INPUT_PULLUP, etc...) +* `USERMOD_FOUR_LINE_DISPLAY` - define this to have this the Four Line Display mod included wled00\usermods_list.cpp + also tells this usermod that the display is available + (see the Four Line Display usermod `readme.md` for more details) +* `ENCODER_DT_PIN` - The encoders DT pin, defaults to 12 +* `ENCODER_CLK_PIN` - The encoders CLK pin, defaults to 14 +* `ENCODER_SW_PIN` - The encoders SW pin, defaults to 13 ### PlatformIO requirements diff --git a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h index 96a09a09..02bc0ccd 100644 --- a/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h +++ b/usermods/usermod_v2_rotary_encoder_ui/usermod_v2_rotary_encoder_ui.h @@ -110,9 +110,13 @@ public: return; } - pinMode(pinA, INPUT_PULLUP); - pinMode(pinB, INPUT_PULLUP); - pinMode(pinC, INPUT_PULLUP); + #ifndef USERMOD_ROTARY_ENCODER_GPIO + #define USERMOD_ROTARY_ENCODER_GPIO INPUT_PULLUP + #endif + pinMode(pinA, USERMOD_ROTARY_ENCODER_GPIO); + pinMode(pinB, USERMOD_ROTARY_ENCODER_GPIO); + pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); + currentTime = millis(); loopTime = currentTime; diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h index 85ed7ff3..ecc994e6 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/usermod_v2_rotary_encoder_ui_ALT.h @@ -278,9 +278,13 @@ public: return; } - pinMode(pinA, INPUT_PULLUP); - pinMode(pinB, INPUT_PULLUP); - pinMode(pinC, INPUT_PULLUP); + #ifndef USERMOD_ROTARY_ENCODER_GPIO + #define USERMOD_ROTARY_ENCODER_GPIO INPUT_PULLUP + #endif + pinMode(pinA, USERMOD_ROTARY_ENCODER_GPIO); + pinMode(pinB, USERMOD_ROTARY_ENCODER_GPIO); + pinMode(pinC, USERMOD_ROTARY_ENCODER_GPIO); + loopTime = millis(); currentCCT = (approximateKelvinFromRGB(RGBW32(col[0], col[1], col[2], col[3])) - 1900) >> 5; diff --git a/wled00/const.h b/wled00/const.h index 2830746a..43a27225 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -319,6 +319,7 @@ #define ABL_MILLIAMPS_DEFAULT 850 // auto lower brightness to stay close to milliampere limit #else #if ABL_MILLIAMPS_DEFAULT < 250 // make sure value is at least 250 + #warning "make sure value is at least 250" #define ABL_MILLIAMPS_DEFAULT 250 #endif #endif diff --git a/wled00/wled.h b/wled00/wled.h index ada18875..7d8d43b1 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -24,10 +24,18 @@ //#define WLED_DISABLE_OTA // saves 14kb // You can choose some of these features to disable: -//#define WLED_DISABLE_ALEXA // saves 11kb -//#define WLED_DISABLE_BLYNK // saves 6kb -//#define WLED_DISABLE_HUESYNC // saves 4kb -//#define WLED_DISABLE_INFRARED // saves 12kb +#ifndef WLED_ENABLE_ALEXA + #define WLED_DISABLE_ALEXA // saves 11kb +#endif +#ifndef WLED_ENABLE_BLYNK +#define WLED_DISABLE_BLYNK // saves 6kb +#endif +#ifndef WLED_ENABLE_HUESYNC +#define WLED_DISABLE_HUESYNC // saves 4kb +#endif +#ifndef WLED_ENABLE_INFRARED + #define WLED_DISABLE_INFRARED // there is no pin left for this on ESP8266-01, saves 12kb +#endif #ifndef WLED_DISABLE_MQTT #define WLED_ENABLE_MQTT // saves 12kb #endif