Edge AI Add-on API 2.2.0
Loading...
Searching...
No Matches

This module provides button control functions with short/long press detection. More...

Macros

#define BUTTON_SHORT_CLICK_MSEC   500
 
#define BUTTON_LONG_CLICK_MSEC   2000
 

Typedefs

typedef void(* button_click_handler_t) (button_click_t click)
 Button click handler type.
 

Enumerations

enum  button_click_t { BUTTON_CLICK_SHORT = 0 , BUTTON_CLICK_LONG }
 Detected button click type. More...
 

Functions

int button_init (void)
 Initialize the button module and its GPIO ISR.
 
void button_reg_click_handler (button_click_handler_t click_handler)
 Register a click handler.
 

Detailed Description

This module provides button control functions with short/long press detection.

The button module uses a GPIO interrupt service routine (ISR) to detect button state changes (press / release) and a delayable work item for debouncing and timing. It distinguishes two types of clicks based on press duration:

Presses released between BUTTON_SHORT_CLICK_MSEC and BUTTON_LONG_CLICK_MSEC are intentionally ignored (no click is reported). This dead band helps prevent accidental activations from presses that are neither a deliberate short tap nor a sustained long press.

A LONG click is reported as soon as the long-press threshold elapses while the button is still held; the subsequent release is then suppressed. A SHORT click is reported on release.