diff options
Diffstat (limited to 'keyboards/keychron/bluetooth/bluetooth.c')
-rw-r--r-- | keyboards/keychron/bluetooth/bluetooth.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/keyboards/keychron/bluetooth/bluetooth.c b/keyboards/keychron/bluetooth/bluetooth.c index 690ddde716..1580138ab0 100644 --- a/keyboards/keychron/bluetooth/bluetooth.c +++ b/keyboards/keychron/bluetooth/bluetooth.c @@ -21,6 +21,7 @@ #include "battery.h" #include "indicator.h" #include "transport.h" +#include "rtc_timer.h" extern uint8_t pairing_indication; extern host_driver_t chibios_driver; @@ -102,6 +103,7 @@ void bluetooth_init(void) { #endif lpm_init(); + rtc_timer_init(); } /* @@ -213,8 +215,11 @@ static void bluetooth_enter_connected(uint8_t host_idx) { #endif bluetooth_enter_connected_kb(host_idx); - - if (battery_is_empty()) indicator_battery_low_enable(true); +#ifdef BAT_LOW_LED_PIN + if (battery_is_empty()) { + indicator_battery_low_enable(true); + } +#endif } /* Enters disconnected state. Upon entering this state we perform the following actions: @@ -236,10 +241,14 @@ static void bluetooth_enter_disconnected(uint8_t host_idx) { #endif retry = 0; bluetooth_enter_disconnected_kb(host_idx); +#ifdef BAT_LOW_LED_PIN indicator_battery_low_enable(false); +#endif +#if defined(LOW_BAT_IND_INDEX) + indicator_battery_low_backlit_enable(false); +#endif } - /* Enter pin code entry state. */ static void bluetooth_enter_pin_code_entry(void) { #if defined(NKRO_ENABLE) @@ -380,7 +389,12 @@ void bluetooth_send_extra(report_extra_t *report) { } void bluetooth_low_battery_shutdown(void) { +#ifdef BAT_LOW_LED_PIN indicator_battery_low_enable(false); +#endif +#if defined(LOW_BAT_IND_INDEX) + indicator_battery_low_backlit_enable(false); +#endif bluetooth_disconnect(); } @@ -446,6 +460,17 @@ __attribute__((weak)) bool process_record_kb_bt(uint16_t keycode, keyrecord_t *r bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (get_transport() == TRANSPORT_BLUETOOTH) { lpm_timer_reset(); + +#if defined(BAT_LOW_LED_PIN) || defined(LOW_BAT_IND_INDEX) + if (battery_is_empty() && bluetooth_get_state() == BLUETOOTH_CONNECTED && record->event.pressed) { +# if defined(BAT_LOW_LED_PIN) + indicator_battery_low_enable(true); +# endif +# if defined(LOW_BAT_IND_INDEX) + indicator_battery_low_backlit_enable(true); +# endif + } +#endif } process_record_kb_bt(keycode, record); return process_record_user(keycode, record); |