From 80173f8ea33e592bba2aa59ae08f036ec44f4e81 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Wed, 3 Jul 2024 02:33:26 -0600 Subject: 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. --- app/src/endpoints.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'app/src/endpoints.c') 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(); -- cgit v1.2.3