TB2026-YDS Firmware
Loading...
Searching...
No Matches
Input service

Buttons -> ui_event_t queue, interrupt-driven and discrete (one press, one event). More...

Collaboration diagram for Input service:

Files

file  components/services/input/input.c
 Input service: ISR-notified task reads buttons over I2C/GPIO, debounces, queues events.

Data Structures

struct  input_diag_t
 Live button snapshot for the diagnostics screen. More...

Functions

esp_err_t input_init (void)
 Bring up the input service: queue, both ISRs, the input task, and A's wake-ready pin.
bool input_get_event (ui_event_t *out, TickType_t ticks_to_wait)
 Block until the next input event (the UI task's read side of the queue).
void input_get_diag (input_diag_t *out)
 Read the current button state and per-button press counts.
uint32_t input_idle_ms (void)
 Milliseconds since the last button event was emitted.

Deep-sleep wake provisioning for button A (reused as-is by a future sleep service)

#define INPUT_WAKE_GPIO   PIN_BTN_A
 GPIO to arm as the ext0 wake source. A (GPIO39) is input-only and an RTC-IO.
#define INPUT_WAKE_ACTIVE_LEVEL   1
 Active level of A: A is active-HIGH (pressed pulls it high; external pull-down keeps it low at rest), unlike the active-low expander buttons. Wake on 1.

Detailed Description

Buttons -> ui_event_t queue, interrupt-driven and discrete (one press, one event).

Macro Definition Documentation

◆ INPUT_WAKE_ACTIVE_LEVEL

#define INPUT_WAKE_ACTIVE_LEVEL   1

Active level of A: A is active-HIGH (pressed pulls it high; external pull-down keeps it low at rest), unlike the active-low expander buttons. Wake on 1.

◆ INPUT_WAKE_GPIO

#define INPUT_WAKE_GPIO   PIN_BTN_A

GPIO to arm as the ext0 wake source. A (GPIO39) is input-only and an RTC-IO.

Function Documentation

◆ input_get_diag()

void input_get_diag ( input_diag_t * out)

Read the current button state and per-button press counts.

Lock-free read of the input task's debounce state: a value may be momentarily stale, which is fine for a diagnostics display. No-op-safe before input_init() (reports all-released, zero counts).

Parameters
[out]outReceives the snapshot.

◆ input_get_event()

bool input_get_event ( ui_event_t * out,
TickType_t ticks_to_wait )

Block until the next input event (the UI task's read side of the queue).

Parameters
[out]outReceives the next ui_event_t.
ticks_to_waitHow long to wait (portMAX_DELAY to block indefinitely).
Returns
true if an event was dequeued, false on timeout.

◆ input_idle_ms()

uint32_t input_idle_ms ( void )

Milliseconds since the last button event was emitted.

The input service is the single choke point for all button activity, so this is the device-wide user-idle time. Reset to zero each time a debounced press produces an event; the volume potentiometer (a separate analog path) does not count. Consumed by the screen lock (UI task) and the idle auto power-off (maintenance task) – this service applies no timeout itself.

Lock-free single-word read. Returns 0 before input_init().

Returns
Idle time in ms.

◆ input_init()

esp_err_t input_init ( void )

Bring up the input service: queue, both ISRs, the input task, and A's wake-ready pin.

Creates the event queue, configures the expander INT (GPIO35, falling edge) and A (GPIO39, input, no internal pull), installs the GPIO ISR service, registers both handlers, and starts the input task. The expander itself must already be initialised by the bsp. Idempotent.

Returns
ESP_OK; ESP_ERR_NO_MEM if the queue or task cannot be created; otherwise the GPIO error.