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 handle_events ()
 
void button_thread ()
 
void init (const bool isSystemStartedFromButton)
 Start the button handler.
 

Variables

platform::gpio::DigitalPin::GPIO _buttonPin = platform::gpio::DigitalPin::GPIO::gpio3
 
platform::gpio::DigitalPin _buttonGpio (_buttonPin)
 
static ButtonStateTy buttonState = ButtonStateTy()
 
static volatile bool wasButtonPressedDetected = false
 
static constexpr uint32_t thread_throttle_time_ms = 5
 thread run frequency timing
 
static constexpr uint32_t RELEASE_BETWEEN_CLICKS = 50
 minimum release timing (debounce)
 
static constexpr uint32_t RELEASE_TIMING_CLICKS_MS = 250
 time to release the button after clicks stops
 
static constexpr uint32_t RELEASE_TIMING_HOLDS_MS = 125
 time to release the button after hold stops
 
static constexpr uint32_t HOLD_BUTTON_MIN_MS = 500
 press and hold delay (ms)
 

Detailed Description

Handle the button inputs and multiple click detection.

Function Documentation

◆ init()

void lampda::physical::button::init ( const bool  isSystemStartedFromButton)

Start the button handler.

Parameters
[in]isSystemStartedFromButtonSignal to the button that the system was started by a button click