|
TB2026-YDS Firmware
|
Debounce + press-edge detection + button->ui_event mapping, no hardware. More...

Files | |
| file | components/services/input/input_logic.c |
| Pure debounce + press-edge detection + button->ui_event mapping (no hardware). | |
Data Structures | |
| struct | input_debounce_t |
| Debounce/edge state. Zero-initialise before the first call (memset or {0}). More... | |
Macros | |
| #define | INPUT_BTN_COUNT 6 |
| Number of physical buttons handled (5 expander + A). | |
| #define | INPUT_DEBOUNCE_MS 30 |
| Leading-edge lockout in ms: a button's press is accepted only this long after the previous accepted press, which swallows contact bounce (must exceed the bounce duration). | |
Functions | |
| int | input_logic_update (input_debounce_t *st, uint8_t exp_port, bool a_pressed, uint32_t now_ms, ui_event_t *out, int out_cap) |
| Fold one button sample into the debounce state, emitting just-pressed UI events. | |
Debounce + press-edge detection + button->ui_event mapping, no hardware.
| #define INPUT_BTN_COUNT 6 |
Number of physical buttons handled (5 expander + A).
| #define INPUT_DEBOUNCE_MS 30 |
Leading-edge lockout in ms: a button's press is accepted only this long after the previous accepted press, which swallows contact bounce (must exceed the bounce duration).
| int input_logic_update | ( | input_debounce_t * | st, |
| uint8_t | exp_port, | ||
| bool | a_pressed, | ||
| uint32_t | now_ms, | ||
| ui_event_t * | out, | ||
| int | out_cap ) |
Fold one button sample into the debounce state, emitting just-pressed UI events.
Detects the rising edge (released -> pressed) of each button and, if it clears the INPUT_DEBOUNCE_MS lockout, appends that button's ui_event_t to out. Releases and holds emit nothing; the expander's IO7 (charger INOKB) is never a button and is ignored.
| st | Debounce state, carried across calls (zero-initialised on first use). | |
| exp_port | Raw expander input port byte (bit n = channel n; buttons are active-low). | |
| a_pressed | A button pressed (true when GPIO39 reads high — A is active-high). | |
| now_ms | Monotonic timestamp in ms (e.g. esp_timer_get_time()/1000). | |
| [out] | out | Receives the events for newly pressed buttons. |
| out_cap | Capacity of out (use INPUT_BTN_COUNT to never truncate). |
out (0..out_cap).