feat: override disable_pico_led for low-battery blink

The low-battery indicator is critical info — keep blinking even when
the user has the LED disabled (Speaker mute toggle). Steady-state
LED still respects the flag: when battery recovers or charging
starts, the LED returns to off if the flag is set, otherwise to the
existing connected = solid-on state.

(cherry picked from commit 775346cd29d9a3c566309ec7d29db80f0b6979f1)
This commit is contained in:
Thierry Perraut
2026-05-13 18:09:32 +08:00
committed by awalol
parent 63c62081eb
commit e969aa6e2d
2 changed files with 5 additions and 9 deletions
+4 -8
View File
@@ -38,11 +38,6 @@ void battery_led_note_report(void) {
}
void battery_led_tick(void) {
if (get_config().disable_pico_led) {
blinking = false;
return;
}
const uint64_t now = time_us_64();
if (last_report_us == 0 || (now - last_report_us) >= REPORT_STALE_US) {
// No fresh data — bt.cpp owns the LED while disconnected.
@@ -56,6 +51,7 @@ void battery_led_tick(void) {
const bool low = (st == POWER_STATE_DISCHARGING) && (pct <= THRESHOLD_LEVEL);
if (low) {
// Critical warning: override disable_pico_led so the user always sees it.
if (!blinking) {
blinking = true;
led_state = true;
@@ -70,8 +66,8 @@ void battery_led_tick(void) {
}
} else if (blinking) {
blinking = false;
// We were blinking and are still receiving fresh reports => still connected.
// Restore the LED to the bt.cpp "connected = solid on" state.
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
// Battery recovered or now charging — restore steady-state LED per the user
// preference flag (LED off when disabled, otherwise the bt.cpp connected = on state).
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, !get_config().disable_pico_led);
}
}