Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Functions | Variables
lampda::physical::button Namespace Reference

Handle the button inputs and multiple click detection. More...

Classes

struct  ButtonStateTy
 Store the button status and characteristics. More...
 

Functions

platform::gpio::DigitalPin::GPIO get_button_pin ()
 Return the pin used for the button.
 
int get_button_pin_RAW ()
 get the button pin index in system. USE WITH CAUTION
 
void set_button_pin (const platform::gpio::DigitalPin::GPIO buttonPin)
 Only on system start, set the pin where the button is wired.
 
ButtonStateTy get_button_state ()
 Get a copy of the raw internal button state.
 
bool is_button_pressed ()
 
void button_state_interrupt ()
 
void init (const bool isSystemStartedFromButton)
 
void handle_events (const std::function< void(uint8_t)> &clickSerieCallback, const std::function< void(uint8_t, uint32_t)> &clickHoldSerieCallback)
 handle the button clicked events
 
bool is_system_start_click ()
 Indicates that this click is the one triggered by the system start It is set to false after the click chain stops.
 

Variables

platform::gpio::DigitalPin::GPIO _buttonPin = platform::gpio::DigitalPin::GPIO::gpio3
 
platform::gpio::DigitalPin _buttonGpio (_buttonPin)
 
static ButtonStateTy buttonState = ButtonStateTy()
 
static bool isSystemStartClick = true
 
static volatile bool wasButtonPressedDetected = false
 

Detailed Description

Handle the button inputs and multiple click detection.

Function Documentation

◆ handle_events()

void lampda::physical::button::handle_events ( const std::function< void(uint8_t)> &  clickSerieCallback,
const std::function< void(uint8_t, uint32_t)> &  clickHoldSerieCallback 
)

handle the button clicked events

Parameters
[in]clickSerieCallbackA callback for a seri of clicks. Parameter is the number of consequtive clicks detected
[in]clickHoldSerieCallbackA callback for a seri of clicks followed by a long hold. Parameter is the number of consequtive clicks detected and the time of the old event (in milliseconds). Called at until the button is released