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:
@@ -40,6 +40,12 @@ if(ENABLE_VERBOSE)
|
||||
else()
|
||||
set(ENABLE_VERBOSE_VALUE 0)
|
||||
endif ()
|
||||
option(ENABLE_BATT_LED "Blink Pico LED when DualSense battery is low (<=10%)" ON)
|
||||
if (ENABLE_BATT_LED)
|
||||
set(ENABLE_BATT_LED_VALUE 1)
|
||||
else ()
|
||||
set(ENABLE_BATT_LED_VALUE 0)
|
||||
endif ()
|
||||
|
||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||
include(pico_sdk_import.cmake)
|
||||
@@ -61,6 +67,10 @@ add_executable(ds5-bridge
|
||||
src/cmd.cpp
|
||||
)
|
||||
|
||||
if (ENABLE_BATT_LED)
|
||||
target_sources(ds5-bridge PRIVATE src/battery_led.cpp)
|
||||
endif ()
|
||||
|
||||
# Cockos WDLResampler
|
||||
add_library(wdl_resampler STATIC
|
||||
lib/WDL/WDL/resample.cpp
|
||||
@@ -88,6 +98,7 @@ target_compile_definitions(ds5-bridge PRIVATE
|
||||
PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE=0
|
||||
PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE=0
|
||||
ENABLE_VERBOSE=${ENABLE_VERBOSE_VALUE}
|
||||
ENABLE_BATT_LED=${ENABLE_BATT_LED_VALUE}
|
||||
)
|
||||
|
||||
pico_set_program_name(ds5-bridge "ds5-bridge")
|
||||
|
||||
Reference in New Issue
Block a user