mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-25 01:47:10 +06:00
Remove redundant backlight eeconfig init (#22675)
This commit is contained in:
parent
f165eb5cc9
commit
11be3e7c64
|
@ -42,20 +42,26 @@ backlight_config_t backlight_config;
|
||||||
static uint8_t breathing_period = BREATHING_PERIOD;
|
static uint8_t breathing_period = BREATHING_PERIOD;
|
||||||
#endif
|
#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
|
/** \brief Backlight initialization
|
||||||
*
|
*
|
||||||
* FIXME: needs doc
|
* FIXME: needs doc
|
||||||
*/
|
*/
|
||||||
void backlight_init(void) {
|
void backlight_init(void) {
|
||||||
/* check signature */
|
backlight_config.raw = eeconfig_read_backlight();
|
||||||
if (!eeconfig_is_enabled()) {
|
if (!backlight_config.valid) {
|
||||||
eeconfig_init();
|
dprintf("backlight_init backlight_config.valid = 0. Write default values to EEPROM.\n");
|
||||||
eeconfig_update_backlight_default();
|
eeconfig_update_backlight_default();
|
||||||
}
|
}
|
||||||
backlight_config.raw = eeconfig_read_backlight();
|
backlight_check_config();
|
||||||
if (backlight_config.level > BACKLIGHT_LEVELS) {
|
|
||||||
backlight_config.level = BACKLIGHT_LEVELS;
|
|
||||||
}
|
|
||||||
backlight_set(backlight_config.enable ? backlight_config.level : 0);
|
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) {
|
void eeconfig_update_backlight_default(void) {
|
||||||
|
backlight_config.valid = true;
|
||||||
backlight_config.enable = BACKLIGHT_DEFAULT_ON;
|
backlight_config.enable = BACKLIGHT_DEFAULT_ON;
|
||||||
backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING;
|
backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING;
|
||||||
backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
|
backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef union {
|
||||||
struct {
|
struct {
|
||||||
bool enable : 1;
|
bool enable : 1;
|
||||||
bool breathing : 1;
|
bool breathing : 1;
|
||||||
uint8_t reserved : 1; // Reserved for possible future backlight modes
|
bool valid : 1;
|
||||||
uint8_t level : 5;
|
uint8_t level : 5;
|
||||||
};
|
};
|
||||||
} backlight_config_t;
|
} backlight_config_t;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user