From e2cdd017e34baf30b3410f284d92234efcf680be Mon Sep 17 00:00:00 2001 From: Kuba Birecki Date: Sun, 30 Jan 2022 14:01:47 +0100 Subject: [PATCH] Put animation control settings code behind config flags --- app/src/animation/animation_control.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/animation/animation_control.c b/app/src/animation/animation_control.c index ae9a1075..a6311074 100644 --- a/app/src/animation/animation_control.c +++ b/app/src/animation/animation_control.c @@ -46,6 +46,7 @@ struct animation_control_data { static int animation_control_load_settings(const struct device *dev, const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) { +#if IS_ENABLED(CONFIG_SETTINGS) const char *next; int rc; @@ -63,8 +64,12 @@ static int animation_control_load_settings(const struct device *dev, const char } return -ENOENT; +#else + return 0; +#endif /* IS_ENABLED(CONFIG_SETTINGS) */ } +#if IS_ENABLED(CONFIG_SETTINGS) static void animation_control_save_work(struct k_work *work) { struct animation_control_work_context *ctx = CONTAINER_OF(work, struct animation_control_work_context, save_work); @@ -84,6 +89,7 @@ static int animation_control_save_settings(const struct device *dev) { return k_delayed_work_submit(&ctx->save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE)); } +#endif /* IS_ENABLED(CONFIG_SETTINGS) */ int animation_control_handle_command(const struct device *dev, uint8_t command, uint8_t param) { const struct animation_control_config *config = dev->config; @@ -145,8 +151,9 @@ int animation_control_handle_command(const struct device *dev, uint8_t command, break; } - // Save the new settings +#if IS_ENABLED(CONFIG_SETTINGS) animation_control_save_settings(dev); +#endif /* IS_ENABLED(CONFIG_SETTINGS) */ // Force refresh zmk_animation_request_frames(1); @@ -197,6 +204,7 @@ static void animation_control_stop(const struct device *dev) { } static int animation_control_init(const struct device *dev) { +#if IS_ENABLED(CONFIG_SETTINGS) const struct animation_control_config *config = dev->config; settings_subsys_init(); @@ -206,6 +214,7 @@ static int animation_control_init(const struct device *dev) { k_delayed_work_init(&config->work->save_work, animation_control_save_work); settings_load_subtree(dev->name); +#endif /* IS_ENABLED(CONFIG_SETTINGS) */ return 0; }