LSH-Core
A robust C++ framework for Arduino-based home automation 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

constexpr Clickable (uint8_t pin, uint8_t uniqueId) noexcept
 Construct a new Clickable object, conventional IO version.
 
auto getState () -> 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 Clickable index on Clickables namespace Array.
 
auto setClickableShort (bool shortClickable) -> Clickable &
 Set clickable short clickability.
 
auto setClickableLong (bool longClickable, constants::LongClickType clickType=constants::LongClickType::NORMAL, bool networkClickable=false, constants::NoNetworkClickType fallback=constants::NoNetworkClickType::LOCAL_FALLBACK) -> Clickable &
 Set clickable long clickability locally and over network.
 
auto setClickableSuperLong (bool superLongClickable, constants::SuperLongClickType clickType=constants::SuperLongClickType::NORMAL, bool networkClickable=false, constants::NoNetworkClickType fallback=constants::NoNetworkClickType::LOCAL_FALLBACK) -> Clickable &
 Set clickable super long clickability locally and over network.
 
auto addActuator (uint8_t actuatorIndex, constants::ClickType actuatorType) -> Clickable &
 Add an actuator to a list of actuators controlled by the clickable.
 
auto addActuatorShort (uint8_t actuatorIndex) -> Clickable &
 Add a short click actuator.
 
auto addActuatorLong (uint8_t actuatorIndex) -> Clickable &
 Add a long click actuator.
 
auto addActuatorSuperLong (uint8_t actuatorIndex) -> Clickable &
 Add a super long click actuator.
 
auto setDebounceTime (uint8_t timeToSet_ms) -> Clickable &
 Set debounce time.
 
auto setLongClickTime (uint16_t timeToSet_ms) -> Clickable &
 Set long click time.
 
auto setSuperLongClickTime (uint16_t timeToSet_ms) -> Clickable &
 Set super long click time.
 
auto getIndex () const -> uint8_t
 Get the Clickable index on Clickables namespace Array.
 
auto getId () const -> uint8_t
 Get the unique ID of the clickable.
 
auto getActuators (constants::ClickType actuatorType) const -> const etl::ivector< uint8_t > *
 Get the const vector of attached actuators.
 
auto getTotalActuators (constants::ClickType actuatorType) const -> uint8_t
 Get the number of attached actuators of one kind.
 
auto getLongClickType () const -> constants::LongClickType
 Get the type of long click.
 
auto isNetworkClickable (constants::ClickType clickType) const -> bool
 Get if the clickable performs network clicks.
 
auto getNetworkFallback (constants::ClickType clickType) const -> constants::NoNetworkClickType
 Get the fallback type for a network click type.
 
auto getSuperLongClickType () const -> constants::SuperLongClickType
 Get the type of super long click.
 
auto check () -> bool
 Validates the clickable's configuration.
 
auto shortClick () const -> bool
 Perform a short click action.
 
auto longClick () const -> bool
 Perform a long click action.
 
auto superLongClickSelective () const -> bool
 Perform a super long click selective action.
 
auto clickDetection () -> constants::ClickResult
 Perform the clickable state detection.
 
void resizeVectors ()
 Resize vectors to actual needed size.
 

Protected Attributes

uint8_t debounce_ms = constants::timings::CLICKABLE_DEBOUNCE_TIME_MS
 Debounce time in ms.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Clickable()

constexpr Clickable::Clickable ( uint8_t  pin,
uint8_t  uniqueId 
)
inlineexplicitconstexprnoexcept

Construct a new Clickable object, conventional IO version.

Parameters
pinpin number
uniqueIdunique ID of the clickable.

Member Function Documentation

◆ addActuator()

auto Clickable::addActuator ( uint8_t  actuatorIndex,
constants::ClickType  actuatorType 
) -> Clickable &

Add an actuator to a list of actuators controlled by the clickable.

Parameters
actuatorIndexthe actuator index to be attached.
actuatorTypethe type of the actuator.
Returns
Clickable& the object instance.

◆ addActuatorLong()

auto Clickable::addActuatorLong ( uint8_t  actuatorIndex) -> Clickable &

Add a long click actuator.

Parameters
actuatorIndexactuator index to be attached.
Returns
Clickable& the object instance.

◆ addActuatorShort()

auto Clickable::addActuatorShort ( uint8_t  actuatorIndex) -> Clickable &

Add a short click actuator.

Parameters
actuatorIndexactuator index to be attached.
Returns
Clickable& the object instance.

◆ addActuatorSuperLong()

auto Clickable::addActuatorSuperLong ( uint8_t  actuatorIndex) -> Clickable &

Add a super long click actuator.

Parameters
actuatorIndexactuator index to be attached.
Returns
Clickable& the object instance.

◆ check()

auto Clickable::check ( ) -> bool

Validates the clickable's configuration.

A clickable is considered valid if it's enabled for at least one click type (short, long, or super-long) AND is configured to control at least one actuator. This check also sets internal optimization flags.

Returns
true if the clickable has a valid and actionable configuration, false otherwise.

◆ clickDetection()

auto Clickable::clickDetection ( ) -> constants::ClickResult

Perform the clickable state detection.

Returns
constants::ClickResult the type of the click.
Here is the call graph for this function:

◆ getActuators()

auto Clickable::getActuators ( constants::ClickType  actuatorType) const -> const etl::ivector<uint8_t> *

Get the const vector of attached actuators.

Parameters
actuatorTypethe type of actuator vector to get.
Returns
etl::ivector<uint8_t>* the attached actuators const vector pointer.

◆ getId()

auto Clickable::getId ( ) const -> uint8_t

Get the unique ID of the clickable.

Returns
uint8_t unique ID of the clickable.
Here is the caller graph for this function:

◆ getIndex()

auto Clickable::getIndex ( ) const -> uint8_t

Get the Clickable index on Clickables namespace Array.

Returns
uint8_t clickable index.

◆ getLongClickType()

auto Clickable::getLongClickType ( ) const -> constants::LongClickType

Get the type of long click.

Returns
constants::LongClickType the type of long click.

◆ getNetworkFallback()

auto Clickable::getNetworkFallback ( constants::ClickType  clickType) const -> constants::NoNetworkClickType

Get the fallback type for a network click type.

Parameters
clickTypethe click type.
Returns
constants::NoNetworkClickType the fallback type.

◆ getState()

auto Clickable::getState ( ) -> 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.

◆ getSuperLongClickType()

auto Clickable::getSuperLongClickType ( ) const -> constants::SuperLongClickType

Get the type of super long click.

Returns
constants::SuperLongClickType the type of super long click.

◆ getTotalActuators()

auto Clickable::getTotalActuators ( constants::ClickType  actuatorType) const -> uint8_t

Get the number of attached actuators of one kind.

Parameters
actuatorTypethe type of the actuator.
Returns
uint8_t the number of attached actuators of one kind.
Here is the caller graph for this function:

◆ isNetworkClickable()

auto Clickable::isNetworkClickable ( constants::ClickType  clickType) const -> bool

Get if the clickable performs network clicks.

Parameters
clickTypefor which click type you want to know the network clickability.
Returns
true if the clickable in network clickable.
false if the clickable isn't network clickable.

◆ longClick()

auto Clickable::longClick ( ) const -> bool

Perform a long click action.

The action depends on the longClickType configuration. If NORMAL -> Switch ON if less than half of attached long actuators are OFF, switch OFF otherwise. If ON_ONLY -> Switch ON attached long actuators. If OFF_ONLY -> Switch OFF attached long actuators.

Returns
true if any actuator changed state.
false otherwise.
Here is the call graph for this function:

◆ setClickableLong()

auto Clickable::setClickableLong ( bool  longClickable,
constants::LongClickType  clickType = constants::LongClickType::NORMAL,
bool  networkClickable = false,
constants::NoNetworkClickType  fallback = constants::NoNetworkClickType::LOCAL_FALLBACK 
) -> Clickable &

Set clickable long clickability locally and over network.

Parameters
longClickableif the clickable is long clickable.
clickTypeto set the type of long click.
networkClickableif the clickable is long clickable over network.
fallbackthe fallback type (if network isn't working).
Returns
Clickable& the object instance.

◆ setClickableShort()

auto Clickable::setClickableShort ( bool  shortClickable) -> Clickable &

Set clickable short clickability.

Parameters
shortClickableif the clickable is short clickable.
Returns
Clickable& the object instance.

◆ setClickableSuperLong()

auto Clickable::setClickableSuperLong ( bool  superLongClickable,
constants::SuperLongClickType  clickType = constants::SuperLongClickType::NORMAL,
bool  networkClickable = false,
constants::NoNetworkClickType  fallback = constants::NoNetworkClickType::LOCAL_FALLBACK 
) -> Clickable &

Set clickable super long clickability locally and over network.

Parameters
superLongClickableif the clickable is super long clickable.
clickTypeto set the type of super long click.
networkClickableif the clickable is super long clickable over network.
fallbackthe fallback type (if network isn't working).
Returns
Clickable& the object instance.

◆ setDebounceTime()

auto Clickable::setDebounceTime ( uint8_t  timeToSet_ms) -> Clickable &

Set debounce time.

Parameters
timeToSet_msdebounce time in ms.
Returns
Clickable& the object instance.

◆ setIndex()

void Clickable::setIndex ( uint8_t  indexToSet)

Store the Clickable index on Clickables namespace Array.

Parameters
indexToSetindex to set.
Here is the caller graph for this function:

◆ setLongClickTime()

auto Clickable::setLongClickTime ( uint16_t  timeToSet_ms) -> Clickable &

Set long click time.

Parameters
timeToSet_mslong click time in ms.
Returns
Clickable& the object instance.

◆ setSuperLongClickTime()

auto Clickable::setSuperLongClickTime ( uint16_t  timeToSet_ms) -> Clickable &

Set super long click time.

Parameters
timeToSet_mssuper long click time in ms.
Returns
Clickable& the object instance.

◆ shortClick()

auto Clickable::shortClick ( ) const -> bool

Perform a short click action.

It toggles the state of the actuator, if it was ON it turns it OFF and vice versa.

Returns
true if any actuator changed state.
false otherwise.

◆ superLongClickSelective()

auto Clickable::superLongClickSelective ( ) const -> bool

Perform a super long click selective action.

Turns off super long unprotected actuators.

Returns
true if any actuator changed state.
false otherwise.

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