feat: low-battery LED indicator (ENABLE_BATT_LED, default ON)
Blink the Pico onboard LED at 1 Hz when the connected DualSense reports PowerPercent <= 1 (i.e. <= 10%) and PowerState == Discharging. Source data is byte 52 of the BT 0x31 input report, already copied into interrupt_in_data; no new BT parsing required. The new module owns the LED only while it is actively blinking; it detects controller disconnection via stale-report timeout and steps out, so bt.cpp's existing connect/disconnect LED handling stays in charge in all other states. Honors disable_pico_led. Gated by -DENABLE_BATT_LED=ON (default). With the option off, the source file is not compiled and behavior is identical to upstream. CI gains a compile-only check for the OFF flavor. (cherry picked from commit 2f8ea73c9fb695e24e7cc3329db7cb925e82e1c9)
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "cmd.h"
|
||||
#if ENABLE_BATT_LED
|
||||
#include "battery_led.h"
|
||||
#endif
|
||||
|
||||
// Pico SDK speciifically for waiting on conditions
|
||||
#include "pico/critical_section.h"
|
||||
@@ -85,6 +88,9 @@ void on_bt_data(CHANNEL_TYPE channel, uint8_t *data, uint16_t len) {
|
||||
|
||||
if (get_config().polling_rate_mode != 2) {
|
||||
memcpy(interrupt_in_data, data + 3, 63);
|
||||
#if ENABLE_BATT_LED
|
||||
battery_led_note_report();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,6 +104,9 @@ void on_bt_data(CHANNEL_TYPE channel, uint8_t *data, uint16_t len) {
|
||||
memcpy(interrupt_in_data, data + 3, 63);
|
||||
report_dirty = true;
|
||||
critical_section_exit(&report_cs);
|
||||
#if ENABLE_BATT_LED
|
||||
battery_led_note_report();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +213,10 @@ int main() {
|
||||
}
|
||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
|
||||
|
||||
#if ENABLE_BATT_LED
|
||||
battery_led_init();
|
||||
#endif
|
||||
|
||||
#if !ENABLE_SERIAL
|
||||
if (watchdog_caused_reboot()) {
|
||||
printf("Rebooted by Watchdog!\n");
|
||||
@@ -243,5 +256,8 @@ int main() {
|
||||
tud_task();
|
||||
audio_loop();
|
||||
interrupt_loop();
|
||||
#if ENABLE_BATT_LED
|
||||
battery_led_tick();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user