Unified low battery indication of LED/RGB matrix and individual LED; Fixed bluetooth name may not be set correctly after factory reset
This commit is contained in:
@@ -227,20 +227,19 @@ static void wireless_enter_connected(uint8_t host_idx) {
|
||||
#endif
|
||||
|
||||
wireless_enter_connected_kb(host_idx);
|
||||
#ifdef BAT_LOW_LED_PIN
|
||||
if (battery_is_empty()) {
|
||||
indicator_battery_low_enable(true);
|
||||
}
|
||||
#endif
|
||||
if (wireless_transport.update_bat_level) wireless_transport.update_bat_level(battery_get_percentage());
|
||||
lpm_timer_reset();
|
||||
}
|
||||
|
||||
/* Enters disconnected state. Upon entering this state we perform the following actions:
|
||||
* - change state to DISCONNECTED
|
||||
* - set disconnected indication
|
||||
*/
|
||||
static void wireless_enter_disconnected(uint8_t host_idx) {
|
||||
kc_printf("wireless_disconnected %d\n\r", host_idx);
|
||||
static void wireless_enter_disconnected(uint8_t host_idx, uint8_t reason) {
|
||||
kc_printf("wireless_disconnected %d, %d\n\r", host_idx, reason);
|
||||
|
||||
uint8_t previous_state = wireless_state;
|
||||
led_state = 0;
|
||||
@@ -252,20 +251,19 @@ static void wireless_enter_disconnected(uint8_t host_idx) {
|
||||
if (previous_state == WT_CONNECTED) {
|
||||
lpm_timer_reset();
|
||||
indicator_set(WT_SUSPEND, host_idx);
|
||||
} else
|
||||
} else {
|
||||
indicator_set(wireless_state, host_idx);
|
||||
if (reason && (get_transport() & TRANSPORT_WIRELESS))
|
||||
indicator_set_backlit_timeout(DISCONNECTED_BACKLIGHT_DISABLE_TIMEOUT*1000);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_REPORT_BUFFER
|
||||
report_buffer_init();
|
||||
#endif
|
||||
retry = 0;
|
||||
wireless_enter_disconnected_kb(host_idx);
|
||||
#ifdef BAT_LOW_LED_PIN
|
||||
wireless_enter_disconnected_kb(host_idx, reason);
|
||||
|
||||
indicator_battery_low_enable(false);
|
||||
#endif
|
||||
#if defined(LOW_BAT_IND_INDEX)
|
||||
indicator_battery_low_backlit_enable(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Enter pin code entry state. */
|
||||
@@ -294,18 +292,15 @@ static void wireless_enter_sleep(void) {
|
||||
kc_printf("wireless_enter_sleep %d\n\r", wireless_state);
|
||||
|
||||
led_state = 0;
|
||||
if (wireless_state == WT_PARING) {
|
||||
|
||||
if (wireless_state == WT_CONNECTED || wireless_state == WT_PARING) {
|
||||
wireless_state = WT_SUSPEND;
|
||||
kc_printf("WT_SUSPEND\n\r");
|
||||
lpm_timer_reset();
|
||||
|
||||
wireless_enter_sleep_kb();
|
||||
indicator_set(wireless_state, 0);
|
||||
#ifdef BAT_LOW_LED_PIN
|
||||
indicator_battery_low_enable(false);
|
||||
#endif
|
||||
#if defined(LOW_BAT_IND_INDEX)
|
||||
indicator_battery_low_backlit_enable(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +308,7 @@ __attribute__((weak)) void wireless_enter_reset_kb(uint8_t reason) {}
|
||||
__attribute__((weak)) void wireless_enter_discoverable_kb(uint8_t host_idx) {}
|
||||
__attribute__((weak)) void wireless_enter_reconnecting_kb(uint8_t host_idx) {}
|
||||
__attribute__((weak)) void wireless_enter_connected_kb(uint8_t host_idx) {}
|
||||
__attribute__((weak)) void wireless_enter_disconnected_kb(uint8_t host_idx) {}
|
||||
__attribute__((weak)) void wireless_enter_disconnected_kb(uint8_t host_idx, uint8_t reason) {}
|
||||
__attribute__((weak)) void wireless_enter_bluetooth_pin_code_entry_kb(void) {}
|
||||
__attribute__((weak)) void wireless_exit_bluetooth_pin_code_entry_kb(void) {}
|
||||
__attribute__((weak)) void wireless_enter_sleep_kb(void) {}
|
||||
@@ -434,12 +429,8 @@ void wireless_send_extra(report_extra_t *report) {
|
||||
}
|
||||
|
||||
void wireless_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
|
||||
|
||||
|
||||
report_buffer_init();
|
||||
clear_keyboard(); //
|
||||
@@ -483,7 +474,7 @@ void wireless_event_task(void) {
|
||||
wireless_enter_reconnecting(event.params.hostIndex);
|
||||
break;
|
||||
case EVT_DISCONNECTED:
|
||||
wireless_enter_disconnected(event.params.hostIndex);
|
||||
wireless_enter_disconnected(event.params.hostIndex, event.data);
|
||||
break;
|
||||
case EVT_BT_PINCODE_ENTRY:
|
||||
wireless_enter_bluetooth_pin_code_entry();
|
||||
@@ -537,16 +528,9 @@ bool process_record_wireless(uint16_t keycode, keyrecord_t *record) {
|
||||
if (get_transport() & TRANSPORT_WIRELESS) {
|
||||
lpm_timer_reset();
|
||||
|
||||
#if defined(BAT_LOW_LED_PIN) || defined(LOW_BAT_IND_INDEX)
|
||||
if (battery_is_empty() && wireless_get_state() == WT_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
|
||||
}
|
||||
|
||||
if (!process_record_keychron_wireless(keycode, record)) return false;
|
||||
|
||||
Reference in New Issue
Block a user