From 979a5bffffeac0fed12db00409dedb8ed6c4ad87 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 23 Aug 2020 15:56:18 -0500 Subject: [PATCH] fix(rgb): check if settings enabled --- app/CMakeLists.txt | 2 +- app/src/rgb_underglow.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bb4af555..bbb54b95 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -55,5 +55,5 @@ target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/hid_listener.c) -target_sources(app PRIVATE src/settings.c) +target_sources_ifdef(CONFIG_SETTINGS app PRIVATE src/settings.c) target_sources(app PRIVATE src/main.c) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 3851421b..cb98e8d9 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -51,6 +51,7 @@ struct led_rgb pixels[STRIP_NUM_PIXELS]; struct rgb_underglow_state state; +#if IS_ENABLED(CONFIG_SETTINGS) static int rgb_settings_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) { @@ -77,6 +78,7 @@ struct settings_handler rgb_conf = { .name = "rgb/underglow", .h_set = rgb_settings_set }; +#endif static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { @@ -242,7 +244,9 @@ static int zmk_rgb_underglow_init(struct device *_arg) on: IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_ON_START) }; +#if IS_ENABLED(CONFIG_SETTINGS) settings_register(&rgb_conf); +#endif k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); @@ -251,7 +255,11 @@ static int zmk_rgb_underglow_init(struct device *_arg) int zmk_rgb_underglow_save_state() { +#if IS_ENABLED(CONFIG_SETTINGS) return settings_save_one("rgb/underglow/state", &state, sizeof(state)); +#else + return 0; +#endif } int zmk_rgb_underglow_cycle_effect(int direction)