diff --git a/src/board/system76/common/include/board/kbled.h b/src/board/system76/common/include/board/kbled.h index c3efd93..1be3acc 100644 --- a/src/board/system76/common/include/board/kbled.h +++ b/src/board/system76/common/include/board/kbled.h @@ -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 diff --git a/src/board/system76/common/kbled.c b/src/board/system76/common/kbled.c index c6cabd5..4281386 100644 --- a/src/board/system76/common/kbled.c +++ b/src/board/system76/common/kbled.c @@ -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]); +} diff --git a/src/board/system76/common/kbscan.c b/src/board/system76/common/kbscan.c index a74671d..6bb46d3 100644 --- a/src/board/system76/common/kbscan.c +++ b/src/board/system76/common/kbscan.c @@ -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)