kbled: Add a "step" function for BKL hotkey
Replace the get+set logic with a step function to change the backlight level for `K_KBD_BKL`. Keyboards using a DAC have a different set of levels due to the brightness difference between the keyboards. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
4c9d3197b8
commit
9ac513128a
@ -26,5 +26,6 @@ void kbled_hotkey_color(void);
|
||||
void kbled_hotkey_down(void);
|
||||
void kbled_hotkey_up(void);
|
||||
void kbled_hotkey_toggle(void);
|
||||
void kbled_hotkey_step(void);
|
||||
|
||||
#endif // _BOARD_KBLED_H
|
||||
|
@ -7,14 +7,26 @@ enum KbledKind kbled_kind = KBLED_NONE;
|
||||
|
||||
// clang-format off
|
||||
static uint8_t LEVEL_I = 1;
|
||||
#ifdef KBLED_DAC
|
||||
// XXX: DAC uses separate levels due to brightness being different.
|
||||
static const uint8_t __code LEVELS[] = {
|
||||
0,
|
||||
128,
|
||||
144,
|
||||
168,
|
||||
192,
|
||||
255,
|
||||
};
|
||||
#else
|
||||
static const uint8_t __code LEVELS[] = {
|
||||
48,
|
||||
72,
|
||||
96,
|
||||
144,
|
||||
192,
|
||||
255
|
||||
255,
|
||||
};
|
||||
#endif
|
||||
|
||||
static uint8_t COLOR_I = 0;
|
||||
static const uint32_t __code COLORS[] = {
|
||||
@ -58,3 +70,13 @@ void kbled_hotkey_toggle(void) {
|
||||
kbled_set(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Change the backlight level to the next value, cycling through "off".
|
||||
void kbled_hotkey_step(void) {
|
||||
if (LEVEL_I < (ARRAY_SIZE(LEVELS) - 1)) {
|
||||
LEVEL_I += 1;
|
||||
} else {
|
||||
LEVEL_I = 0;
|
||||
}
|
||||
kbled_set(LEVELS[LEVEL_I]);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static void hardware_hotkey(uint16_t key) {
|
||||
fan_max = !fan_max;
|
||||
break;
|
||||
case K_KBD_BKL:
|
||||
kbled_set(kbled_get() + 1);
|
||||
kbled_hotkey_step();
|
||||
break;
|
||||
case K_KBD_COLOR:
|
||||
if (acpi_ecos != EC_OS_FULL)
|
||||
|
Reference in New Issue
Block a user