diff options
author | Joel Challis <git@zvecr.com> | 2023-12-16 21:15:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-16 21:15:55 +0000 |
commit | 11be3e7c649185f9339158c47f161d48d32f0908 (patch) | |
tree | 7291545f17cba2fbf9edff23e87b0441d110717c /quantum/backlight | |
parent | f165eb5cc96b4b987020ad4cba73a0643525be4f (diff) |
Remove redundant backlight eeconfig init (#22675)
Diffstat (limited to 'quantum/backlight')
-rw-r--r-- | quantum/backlight/backlight.c | 21 | ||||
-rw-r--r-- | quantum/backlight/backlight.h | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index e89b34696c..eb64dd71e8 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c @@ -42,20 +42,26 @@ backlight_config_t backlight_config; static uint8_t breathing_period = BREATHING_PERIOD; #endif +static void backlight_check_config(void) { + /* Add some out of bound checks for backlight config */ + + if (backlight_config.level > BACKLIGHT_LEVELS) { + backlight_config.level = BACKLIGHT_LEVELS; + } +} + /** \brief Backlight initialization * * FIXME: needs doc */ void backlight_init(void) { - /* check signature */ - if (!eeconfig_is_enabled()) { - eeconfig_init(); - eeconfig_update_backlight_default(); - } backlight_config.raw = eeconfig_read_backlight(); - if (backlight_config.level > BACKLIGHT_LEVELS) { - backlight_config.level = BACKLIGHT_LEVELS; + if (!backlight_config.valid) { + dprintf("backlight_init backlight_config.valid = 0. Write default values to EEPROM.\n"); + eeconfig_update_backlight_default(); } + backlight_check_config(); + backlight_set(backlight_config.enable ? backlight_config.level : 0); } @@ -183,6 +189,7 @@ void eeconfig_update_backlight_current(void) { } void eeconfig_update_backlight_default(void) { + backlight_config.valid = true; backlight_config.enable = BACKLIGHT_DEFAULT_ON; backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING; backlight_config.level = BACKLIGHT_DEFAULT_LEVEL; diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index 85812bff3a..c34fb5858d 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h @@ -39,7 +39,7 @@ typedef union { struct { bool enable : 1; bool breathing : 1; - uint8_t reserved : 1; // Reserved for possible future backlight modes + bool valid : 1; uint8_t level : 5; }; } backlight_config_t; |