From e969aa6e2d6ad95e591dfbf992e484ad04288952 Mon Sep 17 00:00:00 2001 From: Thierry Perraut Date: Sun, 10 May 2026 02:09:51 -0700 Subject: [PATCH] feat: override disable_pico_led for low-battery blink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- README.md | 2 +- src/battery_led.cpp | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9430b0f..3e29bbd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/battery_led.cpp b/src/battery_led.cpp index 6bbc586..7e457a2 100644 --- a/src/battery_led.cpp +++ b/src/battery_led.cpp @@ -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); } }