diff options
author | Peter Johanson <[email protected]> | 2024-07-03 02:33:26 -0600 |
---|---|---|
committer | Pete Johanson <[email protected]> | 2024-07-03 16:24:17 -0600 |
commit | 80173f8ea33e592bba2aa59ae08f036ec44f4e81 (patch) | |
tree | 0a3287d06a0dd9878de4084b8b60552ffd0a7201 /app/src/endpoints.c | |
parent | f18974e8c401b139058549dcd95ab7a4cdc7a6e9 (diff) | |
download | zmk-80173f8ea33e592bba2aa59ae08f036ec44f4e81.tar.gz zmk-80173f8ea33e592bba2aa59ae08f036ec44f4e81.zip |
fix: Improve startup time with proper settings loading.
* Avoid doing duplicate calls to setings_load_subtree, which iterates
NVS fully each time under the hood, and instead use on settings_load
later in the lifecycle.
Diffstat (limited to 'app/src/endpoints.c')
-rw-r--r-- | app/src/endpoints.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 7c9d15a31f..652438531f 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -263,7 +263,8 @@ static int endpoints_handle_set(const char *name, size_t len, settings_read_cb r return 0; } -struct settings_handler endpoints_handler = {.name = "endpoints", .h_set = endpoints_handle_set}; +SETTINGS_STATIC_HANDLER_DEFINE(endpoints, "endpoints", NULL, endpoints_handle_set, NULL, NULL); + #endif /* IS_ENABLED(CONFIG_SETTINGS) */ static bool is_usb_ready(void) { @@ -322,17 +323,7 @@ static struct zmk_endpoint_instance get_selected_instance(void) { static int zmk_endpoints_init(void) { #if IS_ENABLED(CONFIG_SETTINGS) - settings_subsys_init(); - - int err = settings_register(&endpoints_handler); - if (err) { - LOG_ERR("Failed to register the endpoints settings handler (err %d)", err); - return err; - } - k_work_init_delayable(&endpoints_save_work, endpoints_save_preferred_work); - - settings_load_subtree("endpoints"); #endif current_instance = get_selected_instance(); |