21#ifndef LSH_CORE_DEVICE_ACTUATOR_MANAGER_HPP
22#define LSH_CORE_DEVICE_ACTUATOR_MANAGER_HPP
44#if defined(LSH_DEBUG) || defined(LSH_STATIC_CONFIG_RUNTIME_CHECKS)
45extern etl::array<Actuator *, CONFIG_MAX_ACTUATORS> actuators;
55[[nodiscard]]
auto getId(uint8_t actuatorIndex) -> uint8_t;
57[[nodiscard]]
auto getIndex(uint8_t actuatorId) -> uint8_t;
58[[nodiscard]]
auto tryGetIndex(uint8_t actuatorId, uint8_t &actuatorIndex)
62#if CONFIG_USE_COMPACT_ACTUATOR_SWITCH_TIMES && LSH_STATIC_CONFIG_AUTO_OFF_ACTUATORS > 0
63[[nodiscard]]
auto checkCompactAutoOffTimer(uint8_t autoOffIndex,
64 uint8_t actuatorIndex,
67 uint32_t timer_ms) -> bool;
89template <u
int8_t ActuatorIndex>
__attribute__((always_inline))
inline void updatePackedStateStatic(
bool state)
91 static_assert(ActuatorIndex < CONFIG_MAX_ACTUATORS,
"ActuatorIndex is outside the generated static profile.");
92 constexpr uint8_t byteIndex =
static_cast<uint8_t
>(ActuatorIndex >> 3U);
93 constexpr uint8_t bitMask =
static_cast<uint8_t
>(1U << (ActuatorIndex & 0x07U));
Represents an actuator (relay) attached to a digital pin.
Definition actuator.hpp:53
Safe wrapper for ETL array with Arduino min/max macros neutralized locally.
Globally stores all actuators (relays) and to operates over them.
Definition actuator_manager.cpp:32
auto tryGetIndex(uint8_t actuatorId, uint8_t &actuatorIndex) -> bool
Resolves an actuator ID to its dense runtime index with a single map lookup.
Definition actuator_manager.cpp:124
__attribute__((always_inline)) inline void updatePackedStateStatic(bool state)
Keep the packed actuator-state shadow aligned using a generated index.
Definition actuator_manager.hpp:89
etl::array< uint8_t, CONFIG_PACKED_ACTUATOR_STATE_STORAGE_CAPACITY > PackedActuatorStateBytes
Compact shadow of the full actuator runtime state in protocol bit order.
Definition actuator_manager.hpp:42
auto getIndex(uint8_t actuatorId) -> uint8_t
Get a single actuator index (in device vector of actuators).
Definition actuator_manager.cpp:106
void recordSwitchTime(uint8_t actuatorIndex, uint32_t now_ms)
Records the latest switch time for an actuator when compact actuator timer storage is enabled.
Definition actuator_manager.cpp:155
auto actuatorExists(uint8_t actuatorId) -> bool
Get if the actuator actually exists.
Definition actuator_manager.cpp:142
auto getActuator(uint8_t actuatorId) -> Actuator *
Get a single actuator.
Definition actuator_manager.cpp:84
void finalizeSetup()
Final validation after actuator registration.
Definition actuator_manager.cpp:253
auto getId(uint8_t actuatorIndex) -> uint8_t
Return the static wire ID for one registered actuator index.
Definition actuator_manager.cpp:72
auto getPackedStateByteCount() -> uint8_t
Return the number of packed bytes required by the current topology.
Definition actuator_manager.cpp:228
void updatePackedState(uint8_t actuatorIndex, bool state)
Keep the compact actuator-state shadow aligned with one runtime state change.
Definition actuator_manager.cpp:204
PackedActuatorStateBytes packedActuatorStates
Canonical packed actuator-state shadow kept in sync with Actuator::setState().
Definition actuator_manager.cpp:37
auto getPackedStateByte(uint8_t byteIndex) -> uint8_t
Return one packed state byte in protocol wire order.
Definition actuator_manager.cpp:239
Internal bridge that imports static profile resources into the library's scope.