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

Represents an actuator (relay) attached to a digital pin. More...

#include <actuator.hpp>

Collaboration diagram for Actuator:
Collaboration graph

Public Member Functions

LSH_OPTIONAL_CONSTEXPR_CTOR Actuator (uint8_t pin, bool normalState=false) noexcept
 Construct a new Actuator object, conventional IO version.
 
template<uint8_t Pin>
LSH_OPTIONAL_CONSTEXPR_CTOR Actuator (lsh::core::PinTag< Pin >, bool normalState=false) noexcept
 Construct an actuator from a compile-time pin tag on the slow-I/O path.
 
auto setState (bool state) -> bool
 Set the new actuator state if the new state can be set.
 
auto setState (bool state, uint32_t now_ms) -> bool
 Set the new actuator state if the new state can be set.
 
auto setStateForIndex (uint8_t actuatorIndex, bool state) -> bool
 Set the new actuator state with a generated dense runtime index.
 
auto setStateForIndex (uint8_t actuatorIndex, bool state, uint32_t now_ms) -> bool
 Set the new actuator state with generated index and cached timestamp.
 
template<uint8_t ActuatorIndex>
auto setStateStatic (bool state) -> bool
 
template<uint8_t ActuatorIndex>
auto setStateStatic (bool state, uint32_t now_ms) -> bool
 
void setIndex (uint8_t indexToSet)
 store the actuator index in Actuators namespace array.
 
auto setProtected (bool hasProtection) -> Actuator &
 Set protection against some turn ON/OFF behaviour.
 
auto getIndex () const -> uint8_t
 Get the actuator index on Actuators namespace array.
 
auto getState () const -> bool
 Get the state of the actuator.
 
auto toggleState () -> bool
 Switch the state of the actuator (if it was OFF is going to be ON and vice versa).
 
auto toggleState (uint32_t now_ms) -> bool
 Switch the state of the actuator using a caller-cached timestamp.
 
auto toggleStateForIndex (uint8_t actuatorIndex) -> bool
 Toggle the actuator with a generated dense runtime index.
 
auto toggleStateForIndex (uint8_t actuatorIndex, uint32_t now_ms) -> bool
 Toggle the actuator with generated index and caller-cached timestamp.
 
template<uint8_t ActuatorIndex>
auto toggleStateStatic () -> bool
 
template<uint8_t ActuatorIndex>
auto toggleStateStatic (uint32_t now_ms) -> bool
 
auto checkAutoOffTimer (uint32_t now_ms, uint32_t autoOffTimer_ms) -> bool
 Checks the provided auto-off timer, switch OFF the actuator if it's over.
 
auto checkAutoOffTimerForIndex (uint8_t actuatorIndex, uint32_t now_ms, uint32_t autoOffTimer_ms) -> bool
 Checks an auto-off timer with the generated dense actuator index.
 

Detailed Description

Represents an actuator (relay) attached to a digital pin.

Constructor & Destructor Documentation

◆ Actuator() [1/2]

LSH_OPTIONAL_CONSTEXPR_CTOR Actuator::Actuator ( uint8_t  pin,
bool  normalState = false 
)
inlineexplicitnoexcept

Construct a new Actuator object, conventional IO version.

Parameters
pinpin number
normalStatethe default state of the actuator.

◆ Actuator() [2/2]

template<uint8_t Pin>
LSH_OPTIONAL_CONSTEXPR_CTOR Actuator::Actuator ( lsh::core::PinTag< Pin >  ,
bool  normalState = false 
)
inlineexplicitnoexcept

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

The tag keeps the public macro surface uniform even when fast I/O is disabled or unavailable for the current build target.

Member Function Documentation

◆ checkAutoOffTimer()

auto Actuator::checkAutoOffTimer ( uint32_t  now_ms,
uint32_t  autoOffTimer_ms 
) -> bool

Checks the provided auto-off timer, switch OFF the actuator if it's over.

Parameters
now_mscaller-cached current time in milliseconds.
autoOffTimer_msauto-off timer to test.
Returns
true if the state has been changed.
false otherwise.

◆ checkAutoOffTimerForIndex()

auto Actuator::checkAutoOffTimerForIndex ( uint8_t  actuatorIndex,
uint32_t  now_ms,
uint32_t  autoOffTimer_ms 
) -> bool

Checks an auto-off timer with the generated dense actuator index.

Parameters
actuatorIndexDense static-profile actuator index.
now_mscaller-cached current time in milliseconds.
autoOffTimer_msauto-off timer to test.
Returns
true if the state has been changed.
false otherwise.

◆ getIndex()

auto Actuator::getIndex ( ) const -> uint8_t

Get the actuator index on Actuators namespace array.

Returns
uint8_t actuator index.

◆ getState()

auto Actuator::getState ( ) const -> bool

Get the state of the actuator.

Returns
true if ON.
false if OFF.

◆ setIndex()

void Actuator::setIndex ( uint8_t  indexToSet)

store the actuator index in Actuators namespace array.

Parameters
indexToSetindex to set.

◆ setProtected()

auto Actuator::setProtected ( bool  hasProtection) -> Actuator &

Set protection against some turn ON/OFF behaviour.

Parameters
hasProtectionto set the property.
Returns
Actuator& the object instance.

◆ setState() [1/2]

auto Actuator::setState ( bool  state) -> bool

Set the new actuator state if the new state can be set.

Parameters
statenew state to set.
Returns
true if the state has been applied.
false otherwise.
Here is the call graph for this function:

◆ setState() [2/2]

auto Actuator::setState ( bool  state,
uint32_t  now_ms 
) -> bool

Set the new actuator state if the new state can be set.

Parameters
statenew state to set.
now_mscaller-cached timestamp used when debounce or auto-off storage needs it.
Returns
true if the state has been applied.
false otherwise.

◆ setStateForIndex() [1/2]

auto Actuator::setStateForIndex ( uint8_t  actuatorIndex,
bool  state 
) -> bool

Set the new actuator state with a generated dense runtime index.

Parameters
actuatorIndexDense static-profile actuator index.
statenew state to set.
Returns
true if the state has been applied.
false otherwise.
Here is the call graph for this function:

◆ setStateForIndex() [2/2]

auto Actuator::setStateForIndex ( uint8_t  actuatorIndex,
bool  state,
uint32_t  now_ms 
) -> bool

Set the new actuator state with generated index and cached timestamp.

Parameters
actuatorIndexDense static-profile actuator index.
statenew state to set.
now_mscaller-cached timestamp used when debounce or auto-off storage needs it.
Returns
true if the state has been applied.
false otherwise.

◆ toggleState() [1/2]

auto Actuator::toggleState ( ) -> bool

Switch the state of the actuator (if it was OFF is going to be ON and vice versa).

Returns
true if the state has been changed.
false otherwise.

◆ toggleState() [2/2]

auto Actuator::toggleState ( uint32_t  now_ms) -> bool

Switch the state of the actuator using a caller-cached timestamp.

Parameters
now_mscached timestamp shared by a generated action body.
Returns
true if the state has been changed.
false otherwise.

◆ toggleStateForIndex() [1/2]

auto Actuator::toggleStateForIndex ( uint8_t  actuatorIndex) -> bool

Toggle the actuator with a generated dense runtime index.

Parameters
actuatorIndexDense static-profile actuator index.
Returns
true if the state has been changed.
false otherwise.

◆ toggleStateForIndex() [2/2]

auto Actuator::toggleStateForIndex ( uint8_t  actuatorIndex,
uint32_t  now_ms 
) -> bool

Toggle the actuator with generated index and caller-cached timestamp.

Parameters
actuatorIndexDense static-profile actuator index.
now_mscached timestamp shared by a generated action body.
Returns
true if the state has been changed.
false otherwise.

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