From 652e6f3db8a5568c81be506401526c54c6dc4358 Mon Sep 17 00:00:00 2001 From: lokher Date: Fri, 26 Aug 2022 09:48:51 +0800 Subject: Fix indicator issue --- keyboards/keychron/bluetooth/indicator.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'keyboards/keychron') diff --git a/keyboards/keychron/bluetooth/indicator.c b/keyboards/keychron/bluetooth/indicator.c index 38e35cceeb..fa9c9fc6e4 100644 --- a/keyboards/keychron/bluetooth/indicator.c +++ b/keyboards/keychron/bluetooth/indicator.c @@ -213,8 +213,9 @@ static void indicator_timer_cb(void *arg) { if ((indicator_config.duration == 0 || indicator_config.elapsed <= indicator_config.duration) && next_period != 0) { indicator_config.elapsed += next_period; - } else + } else { time_up = true; + } } break; default: @@ -224,6 +225,21 @@ static void indicator_timer_cb(void *arg) { break; } +#ifdef HOST_LED_PIN_LIST + if (indicator_config.value) + { + uint8_t idx = (indicator_config.value & 0x0F) - 1; + + if (idx < HOST_DEVICES_COUNT) { + if ((indicator_config.value & 0x80) && !time_up) { + writePin(host_led_pin_list[idx], HOST_LED_PIN_ON_STATE); + } else { + writePin(host_led_pin_list[idx], !HOST_LED_PIN_ON_STATE); + } + } + } +#endif + if (time_up) { /* Set indicator to off on timeup, avoid keeping light up until next update in raindrop effect */ indicator_config.value = indicator_config.value & 0x0F; @@ -236,20 +252,6 @@ static void indicator_timer_cb(void *arg) { indicator_config.value = 0; } -#ifdef HOST_LED_PIN_LIST - if (indicator_config.value) - { - uint8_t idx = (indicator_config.value & 0x0F) - 1; - chDbgAssert(idx < HOST_DEVICES_COUNT, "array out of bounds"); - - if (indicator_config.value & 0x80) { - writePin(host_led_pin_list[idx], HOST_LED_PIN_ON_STATE); - } else { - writePin(host_led_pin_list[idx], !HOST_LED_PIN_ON_STATE); - } - } -#endif - if (indicator_config.value == 0 && !indicator_is_backlit_enabled_eeprom()) { indicator_disable(); } -- cgit v1.2.3