diff options
author | Joel Spadin <[email protected]> | 2023-11-26 12:28:27 -0600 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-03-18 09:48:19 -0700 |
commit | 1dfcfc7d3f074e538900a6df684cc99e92c60a21 (patch) | |
tree | fa3573232e9932be07c9b2f4b4f50d5f1fa4d689 /app | |
parent | 610a806c848ba53a454bbc66631fa3f3faaef19f (diff) | |
download | zmk-1dfcfc7d3f074e538900a6df684cc99e92c60a21.tar.gz zmk-1dfcfc7d3f074e538900a6df684cc99e92c60a21.zip |
feat(shields): Make settings_reset shield reset all settings
Added a new CONFIG_ZMK_SETTINGS_RESET_ON_START option which enables init
code to call zmk_settings_erase(), and changed the settings_reset shield
to use it instead of CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START, so it now
resets all settings instead of just clearing BLE bonds.
CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START is left in place for now in case
someone still needs it. It may be replaced in the future once we find a
better way to repair a broken split connection.
Diffstat (limited to 'app')
-rw-r--r-- | app/Kconfig | 3 | ||||
-rw-r--r-- | app/boards/shields/settings_reset/settings_reset.conf | 5 | ||||
-rw-r--r-- | app/src/settings/CMakeLists.txt | 2 | ||||
-rw-r--r-- | app/src/settings/reset_settings_on_start.c | 19 |
4 files changed, 28 insertions, 1 deletions
diff --git a/app/Kconfig b/app/Kconfig index bb6997a43a..3f797abd41 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -565,6 +565,9 @@ endmenu if SETTINGS +config ZMK_SETTINGS_RESET_ON_START + bool "Delete all persistent settings when the keyboard boots" + config ZMK_SETTINGS_SAVE_DEBOUNCE int "Milliseconds to debounce settings saves" default 60000 diff --git a/app/boards/shields/settings_reset/settings_reset.conf b/app/boards/shields/settings_reset/settings_reset.conf index 8052a6cf25..4ed84df856 100644 --- a/app/boards/shields/settings_reset/settings_reset.conf +++ b/app/boards/shields/settings_reset/settings_reset.conf @@ -1 +1,4 @@ -CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y +CONFIG_SETTINGS=y +CONFIG_ZMK_SETTINGS_RESET_ON_START=y +# Disable BLE so splits don't try to re-pair until normal firmware is flashed. +CONFIG_ZMK_BLE=n diff --git a/app/src/settings/CMakeLists.txt b/app/src/settings/CMakeLists.txt index 63bcd7f952..28664a4ef1 100644 --- a/app/src/settings/CMakeLists.txt +++ b/app/src/settings/CMakeLists.txt @@ -5,3 +5,5 @@ target_sources_ifdef(CONFIG_SETTINGS_NONE app PRIVATE reset_settings_none.c) target_sources_ifdef(CONFIG_SETTINGS_FCB app PRIVATE reset_settings_fcb.c) target_sources_ifdef(CONFIG_SETTINGS_FILE app PRIVATE reset_settings_file.c) target_sources_ifdef(CONFIG_SETTINGS_NVS app PRIVATE reset_settings_nvs.c) + +target_sources_ifdef(CONFIG_ZMK_SETTINGS_RESET_ON_START app PRIVATE reset_settings_on_start.c) diff --git a/app/src/settings/reset_settings_on_start.c b/app/src/settings/reset_settings_on_start.c new file mode 100644 index 0000000000..3b3890f469 --- /dev/null +++ b/app/src/settings/reset_settings_on_start.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include <zephyr/device.h> +#include <zephyr/init.h> + +#include <zmk/settings.h> + +static int reset_settings_init(const struct device *dev) { + ARG_UNUSED(dev); + return zmk_settings_erase(); +} + +// Reset after the kernel is initialized but before any application code to +// ensure settings are cleared before anything tries to use them. +SYS_INIT(reset_settings_init, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY); |