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:
@@ -59,7 +59,7 @@ Some behaviors depend on reconnection cycles to take effect
|
||||
|
||||
### Low-battery LED indicator
|
||||
|
||||
When the connected DualSense reports its battery at or below 10% (and it is not charging), the Pico onboard LED switches from solid-on to a 1 Hz blink so you can see the warning at a glance. The LED returns to solid-on as soon as the controller is plugged in or its reported level rises again. The indicator respects the existing `disable_pico_led` setting (Speaker mute toggle).
|
||||
When the connected DualSense reports its battery at or below 10% (and it is not charging), the Pico onboard LED switches from solid-on to a 1 Hz blink so you can see the warning at a glance. The LED returns to solid-on as soon as the controller is plugged in or its reported level rises again. The blink also fires when `disable_pico_led` is set — the warning is treated as critical and overrides the LED-off preference; the LED returns to its disabled (off) state once the battery recovers or the controller starts charging.
|
||||
|
||||
To opt out at build time, configure with `-DENABLE_BATT_LED=OFF`. Default is ON.
|
||||
|
||||
|
||||
+4
-8
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user