From 54527fc0d2873cbece78b6fc35440d5335542015 Mon Sep 17 00:00:00 2001 From: Timoyoungster Date: Thu, 23 May 2024 16:13:03 +0200 Subject: [PATCH 1/3] feat: adding setting to disable autosave for ext-power and output --- app/Kconfig | 10 ++++++++++ app/src/endpoints.c | 2 +- app/src/ext_power_generic.c | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 5aedd9d9..94b1572f 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -635,6 +635,16 @@ config ZMK_SETTINGS_SAVE_DEBOUNCE int "Milliseconds to debounce settings saves" default 60000 +config ZMK_SETTINGS_SAVE_ENDPOINTS + bool "save endpoints configuration" + depends on CONFIG_SETTINGS + default y + +config ZMK_SETTINGS_SAVE_EXT_POWER + bool "save ext power state" + depends on CONFIG_SETTINGS + default y + #SETTINGS endif diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 7c9d15a3..db70401a 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -41,7 +41,7 @@ static struct k_work_delayable endpoints_save_work; #endif static int endpoints_save_preferred(void) { -#if IS_ENABLED(CONFIG_SETTINGS) +#if IS_ENABLED(CONFIG_ZMK_SETTINGS_SAVE_ENDPOINTS) return k_work_reschedule(&endpoints_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE)); #else return 0; diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index 2586f436..b18c7a78 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -47,7 +47,7 @@ static struct k_work_delayable ext_power_save_work; #endif int ext_power_save_state(void) { -#if IS_ENABLED(CONFIG_SETTINGS) +#if IS_ENABLED(CONFIG_ZMK_SETTINGS_SAVE_EXT_POWER) int ret = k_work_reschedule(&ext_power_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE)); return MIN(ret, 0); #else From 3b7428ad856974b492a201475f661ac638cd3030 Mon Sep 17 00:00:00 2001 From: Timoyoungster Date: Thu, 23 May 2024 16:30:28 +0200 Subject: [PATCH 2/3] docs: adding documentation for the auto endpoint/ext_power saving flags --- docs/docs/behaviors/outputs.md | 1 + docs/docs/behaviors/power.md | 1 + docs/docs/config/system.md | 2 ++ 3 files changed, 4 insertions(+) diff --git a/docs/docs/behaviors/outputs.md b/docs/docs/behaviors/outputs.md index de81f695..76197802 100644 --- a/docs/docs/behaviors/outputs.md +++ b/docs/docs/behaviors/outputs.md @@ -47,6 +47,7 @@ The output selection behavior changes the preferred output on press. :::note[Output selection persistence] The endpoint that is selected by the `&out` behavior will be saved to flash storage and hence persist across restarts and firmware flashes. However it will only be saved after [`CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE`](../config/system.md#general) milliseconds in order to reduce potential wear on the flash memory. +This can be disabled by unsetting [`CONFIG_ZMK_SETTINGS_SAVE_ENDPOINTS`](../config/system.md#general) ::: ### Examples diff --git a/docs/docs/behaviors/power.md b/docs/docs/behaviors/power.md index dce7b155..541dd2d8 100644 --- a/docs/docs/behaviors/power.md +++ b/docs/docs/behaviors/power.md @@ -46,6 +46,7 @@ Here is a table describing the command for each define: :::note[External power state persistence] The on/off state that is set by the `&ext_power` behavior will be saved to flash storage and hence persist across restarts and firmware flashes. However it will only be saved after [`CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE`](../config/system.md#general) milliseconds in order to reduce potential wear on the flash memory. +This can be disabled by unsetting [`CONFIG_ZMK_SETTINGS_SAVE_EXT_POWER`](../config/system.md#general) ::: ### Example: diff --git a/docs/docs/config/system.md b/docs/docs/config/system.md index 27923453..159a5366 100644 --- a/docs/docs/config/system.md +++ b/docs/docs/config/system.md @@ -20,6 +20,8 @@ Definition file: [zmk/app/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/ | `CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE` | int | Milliseconds to wait after a setting change before writing it to flash memory | 60000 | | `CONFIG_ZMK_WPM` | bool | Enable calculating words per minute | n | | `CONFIG_HEAP_MEM_POOL_SIZE` | int | Size of the heap memory pool | 8192 | +| `CONFIG_ZMK_SETTINGS_SAVE_ENDPOINTS` | bool | Enable automatic saving of the selected endpoint (USB / BT) | y | +| `CONFIG_ZMK_SETTINGS_SAVE_EXT_POWER` | bool | Enable automatic saving of the selected ext_power persistance state | y | ### HID From db3477cfb13bfb26689a60c20445db08c3feaa4c Mon Sep 17 00:00:00 2001 From: Timoyoungster <53046195+Timoyoungster@users.noreply.github.com> Date: Sun, 26 May 2024 17:48:16 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20removing=20config=20value=E2=80=99s?= =?UTF-8?q?=20dependence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit they are already only defined if SETTINGS is defined --- app/Kconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 94b1572f..35e05a58 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -637,12 +637,10 @@ config ZMK_SETTINGS_SAVE_DEBOUNCE config ZMK_SETTINGS_SAVE_ENDPOINTS bool "save endpoints configuration" - depends on CONFIG_SETTINGS default y config ZMK_SETTINGS_SAVE_EXT_POWER bool "save ext power state" - depends on CONFIG_SETTINGS default y #SETTINGS