Expand description
User button (GPIO5, active-low): power-up factory reset and runtime click actions.
One pin, two phases. boot_factory_reset runs first, awaited straight
from main before the network task is spawned (but only after a
non-software reset — a reboot we triggered ourselves must never re-enter
the hold while the button is still down):
| Phase | Trigger | Behavior |
|---|---|---|
| Boot hold | held at power-up | LedStatus::Resetting for RESET_HOLD, then storage::clear → solid LED → wait for release → reboot; releasing earlier aborts with LedStatus::Warning |
| Click actions | presses after boot | classified into ButtonEvents, dispatched from Config::button_actions |
Event discriminants are the button_actions map keys (web: ButtonEvent):
0 single click, 1 double click, 2 multiple (3) clicks, 3 long hold. The
action is read from NVS on every event, so the web UI can rebind clicks
without a reboot.
Structs§
- Classifier 🔒
- Debounced press/hold/click state machine, polled at
POLL. - Debouncer 🔒
- Debounced level filter: a raw change must hold for
DEBOUNCEbefore the stable level follows it.
Enums§
- Button
Event - Button event classified at runtime.
- State 🔒
- Phase of the click sequence.
Constants§
- BRIGHTNESS_
LEVELS 🔒 - Brightness ladder of
ButtonAction::ToggleLed(legacy behavior). - CLICK_
GAP 🔒 - Maximum gap between two presses of one click sequence.
- DEBOUNCE 🔒
- A raw level must hold this long before the stable level follows it.
- HOLD_
LOG_ 🔒EVERY - Progress-logging cadence while the boot hold runs.
- LONG_
HOLD 🔒 - Press duration that fires
ButtonEvent::LongHold. - POLL 🔒
- Poll interval of the boot hold check and the click classifier.
- REBOOT_
DELAY 🔒 - Delay before a button-triggered reboot so the last log line drains.
- RESET_
HOLD 🔒 - Power-up hold before the factory reset fires.
Functions§
- boot_
factory_ reset - Power-up factory-reset hold (README: hold while applying power).
- dispatch 🔒
- Runs the configured action for
event, read fresh from NVS. - input
- Configures
pinas the user-button input (pull-up, active low). - next_
brightness 🔒 - Next
BRIGHTNESS_LEVELSstep abovecurrent, wrapping to the dimmest level after the brightest one. - task
- Classifies presses and dispatches the configured actions.
- wait_
release 🔒 - Polls until the button reads released (debounced).