Prevent boot buttons from hiding recoverable Tubes - #68
Conversation
| bool available = false; | ||
| bool stuck = false; | ||
| const unsigned long now = millis(); | ||
| for (size_t b = 0; b < WLED_MAX_BUTTONS; b++) { |
There was a problem hiding this comment.
This diagnostic is called on every main-loop iteration in every WLED build, and this loop scans all WLED_MAX_BUTTONS slots even when only one button is configured. The unused-slot branch also rewrites four static arrays on every pass, so ESP32 builds can do 31 unused iterations per loop while ESP8266 builds pay the RAM and flash cost even though their rescue window is disabled. Please compile-gate the diagnostic to builds where it applies, iterate only over configured buttons, and throttle sampling to a modest interval such as 100 ms; a ten-second detector does not need hot-loop polling.
| } | ||
| return; | ||
| } | ||
| reportedStatus = false; |
There was a problem hiding this comment.
This resets reportedStatus after the button recovers, but reportedHealthy remains true from the initial AVAILABLE/INACTIVE report. The sequence AVAILABLE -> STUCK_BUTTON -> inactive therefore emits no recovered or healthy state, leaving the last reported state as STUCK_BUTTON. Please model the status as an explicit transition, or at minimum re-arm the healthy report when entering the stuck state, and add a behavioral test for the complete inactive -> stuck -> recovered sequence.
What this fixes
Some Tubes can look completely dead—no LEDs and no network—even though the controller is still alive. A dirty, worn, or stuck hardware button can be read during power-on as a request for rescue mode, which intentionally disables those visible signs of life. In dusty field conditions, that can make usable hardware look disposable.
This change keeps the useful USB-serial rescue path but stops any button state during power-on from entering rescue mode. Normal button behavior after startup, including existing Wi-Fi/reset gestures, remains intact.
It also reports when a configured momentary button stays active for 10 seconds, so diagnostic tools can explain that the button may be stuck instead of calling the device dead.
Technical details
rescuecommand;AVAILABLE/INACTIVE,STUCK_BUTTON, and explicit disabled states;WLED_DISABLE_STUCK_BUTTON_DIAGNOSTICSfor test builds that should opt out;platformio.ini, packet contracts, normal button handling, or physical-device state.Verification
./test/tubes_mesh/run.sh: pass./test/tubes_upgrade/run.sh: passnpm test: 16/16 passgit diff --check: passNo devices were accessed or flashed.