Skip to main content

Module button

Module button 

Source
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):

PhaseTriggerBehavior
Boot holdheld at power-upLedStatus::Resetting for RESET_HOLD, then storage::clear → solid LED → wait for release → reboot; releasing earlier aborts with LedStatus::Warning
Click actionspresses after bootclassified 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 DEBOUNCE before the stable level follows it.

Enums§

ButtonEvent
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 pin as the user-button input (pull-up, active low).
next_brightness 🔒
Next BRIGHTNESS_LEVELS step above current, 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).