refactor(settings): Add Kconfig option for settings debounce

This commit is contained in:
Nick 2020-12-02 16:09:17 -06:00 committed by Pete Johanson
parent 8b91918352
commit 177b28f01d
3 changed files with 11 additions and 2 deletions

View file

@ -297,6 +297,15 @@ config ZMK_KSCAN_COMPOSITE_DRIVER
#KSCAN Settings #KSCAN Settings
endmenu endmenu
if SETTINGS
config ZMK_SETTINGS_SAVE_DEBOUNCE
int "Milliseconds to debounce settings saves"
default 60000
#SETTINGS
endif
#Advanced #Advanced
endmenu endmenu

View file

@ -49,7 +49,7 @@ static struct k_delayed_work ext_power_save_work;
int ext_power_save_state() { int ext_power_save_state() {
#if IS_ENABLED(CONFIG_SETTINGS) #if IS_ENABLED(CONFIG_SETTINGS)
k_delayed_work_cancel(&ext_power_save_work); k_delayed_work_cancel(&ext_power_save_work);
return k_delayed_work_submit(&ext_power_save_work, K_MINUTES(1)); return k_delayed_work_submit(&ext_power_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE));
#else #else
return 0; return 0;
#endif #endif

View file

@ -279,7 +279,7 @@ static int zmk_rgb_underglow_init(struct device *_arg) {
int zmk_rgb_underglow_save_state() { int zmk_rgb_underglow_save_state() {
#if IS_ENABLED(CONFIG_SETTINGS) #if IS_ENABLED(CONFIG_SETTINGS)
k_delayed_work_cancel(&underglow_save_work); k_delayed_work_cancel(&underglow_save_work);
return k_delayed_work_submit(&underglow_save_work, K_MINUTES(1)); return k_delayed_work_submit(&underglow_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE));
#else #else
return 0; return 0;
#endif #endif