Skip to content

Commit

Permalink
Remove redundant backlight eeconfig init (qmk#22675)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and mechlovin committed Jan 17, 2024
1 parent c03032b commit 3428426
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions quantum/backlight/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion quantum/backlight/backlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3428426

Please sign in to comment.