TB2026-YDS Firmware
Loading...
Searching...
No Matches
Input logic (pure)

Debounce + press-edge detection + button->ui_event mapping, no hardware. More...

Collaboration diagram for Input logic (pure):

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.

Detailed Description

Debounce + press-edge detection + button->ui_event mapping, no hardware.

Macro Definition Documentation

◆ INPUT_BTN_COUNT

#define INPUT_BTN_COUNT   6

Number of physical buttons handled (5 expander + A).

◆ INPUT_DEBOUNCE_MS

#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).

Function Documentation

◆ input_logic_update()

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.

Parameters
stDebounce state, carried across calls (zero-initialised on first use).
exp_portRaw expander input port byte (bit n = channel n; buttons are active-low).
a_pressedA button pressed (true when GPIO39 reads high — A is active-high).
now_msMonotonic timestamp in ms (e.g. esp_timer_get_time()/1000).
[out]outReceives the events for newly pressed buttons.
out_capCapacity of out (use INPUT_BTN_COUNT to never truncate).
Returns
Number of events written to out (0..out_cap).