LSH-Core
Deterministic firmware core for Controllino-based Labo Smart Home nodes
 
Loading...
Searching...
No Matches
Clickable Class Reference

A class that represents a clickable object, like a button, and its associated logic. More...

#include <clickable.hpp>

Collaboration diagram for Clickable:
Collaboration graph

Public Member Functions

LSH_OPTIONAL_CONSTEXPR_CTOR Clickable (uint8_t pin) noexcept
 Construct a new Clickable object, conventional IO version.
 
template<uint8_t Pin>
LSH_OPTIONAL_CONSTEXPR_CTOR Clickable (lsh::core::PinTag< Pin >) noexcept
 Construct a clickable from a compile-time pin tag on the slow-I/O path.
 
auto getState () const -> bool
 Get the state of the clickable if configured as INPUT with its external pulldown resistor (PIN -> BUTTON -> +12v/+5V).
 
void setIndex (uint8_t indexToSet)
 Store the dense runtime index assigned by the generated static profile.
 
auto getIndex () const -> uint8_t
 Return the dense runtime index assigned by the generated static profile.
 
auto clickDetection (uint16_t elapsed_ms, uint8_t detectionFlags, uint16_t longClick_ms, uint16_t superLongClick_ms) -> constants::ClickResult
 Advance the click FSM with fully generated static configuration.
 
template<uint8_t DetectionFlags, uint16_t LongClick_ms, uint16_t SuperLongClick_ms>
auto clickDetection (uint16_t elapsed_ms) -> constants::ClickResult
 Advance the click FSM with fully generated compile-time constants.
 

Detailed Description

A class that represents a clickable object, like a button, and its associated logic.

Constructor & Destructor Documentation

◆ Clickable() [1/2]

LSH_OPTIONAL_CONSTEXPR_CTOR Clickable::Clickable ( uint8_t  pin)
inlineexplicitnoexcept

Construct a new Clickable object, conventional IO version.

Parameters
pinpin number

◆ Clickable() [2/2]

template<uint8_t Pin>
LSH_OPTIONAL_CONSTEXPR_CTOR Clickable::Clickable ( lsh::core::PinTag< Pin >  )
inlineexplicitnoexcept

Construct a clickable from a compile-time pin tag on the slow-I/O path.

The tag keeps the configuration DSL uniform even when the build uses the portable Arduino input path.

Member Function Documentation

◆ clickDetection()

auto Clickable::clickDetection ( uint16_t  elapsed_ms,
uint8_t  detectionFlags,
uint16_t  longClick_ms,
uint16_t  superLongClick_ms 
) -> constants::ClickResult
inline

Advance the click FSM with fully generated static configuration.

The selected TOML profile already knows which click kinds are enabled and which thresholds they use. Passing those values as constants keeps the object free from static configuration bytes and lets the generated scan path constant-fold disabled checks.

Parameters
elapsed_msMilliseconds elapsed since the previous clickable scan.
detectionFlagsBit mask from constants::clickDetection.
longClick_msLong-click threshold for this clickable.
superLongClick_msSuper-long-click threshold for this clickable.
Returns
constants::ClickResult The detected click event, or NO_CLICK.

◆ getIndex()

auto Clickable::getIndex ( ) const -> uint8_t

Return the dense runtime index assigned by the generated static profile.

Returns
uint8_t Clickable index.

◆ getState()

auto Clickable::getState ( ) const -> bool
inline

Get the state of the clickable if configured as INPUT with its external pulldown resistor (PIN -> BUTTON -> +12v/+5V).

Returns
true if clicked.
false if not clicked.

◆ setIndex()

void Clickable::setIndex ( uint8_t  indexToSet)

Store the dense runtime index assigned by the generated static profile.

Parameters
indexToSetDense clickable index.

The documentation for this class was generated from the following files: