21#ifndef LSHCORE_PERIPHERALS_OUTPUT_INDICATOR_HPP
22#define LSHCORE_PERIPHERALS_OUTPUT_INDICATOR_HPP
24#include <etl/vector.h>
37#ifndef CONFIG_USE_FAST_INDICATORS
38 const uint8_t pinNumber;
40 const uint8_t pinMask;
41 volatile uint8_t *
const pinPort;
45 etl::vector<uint8_t, CONFIG_MAX_ACTUATORS> controlledActuators{};
46 bool actualState =
false;
49#ifndef CONFIG_USE_FAST_INDICATORS
54 explicit constexpr Indicator(uint8_t pin) noexcept : pinNumber(pin)
63 explicit Indicator(uint8_t pin) noexcept : pinMask(digitalPinToBitMask(pin)), pinPort(portOutputRegister(digitalPinToPort(pin)))
66 uint8_t port = digitalPinToPort(pin);
67 volatile uint8_t *
const reg = portModeRegister(port);
68 const uint8_t oldSREG = SREG;
70 *reg |= this->pinMask;
75#if (__cplusplus >= 201703L) && (__GNUC__ >= 7)
88 [[nodiscard]]
auto getIndex() const -> uint8_t;
Represents a state indicator for one or more attached actuators, indicators are normally connected to...
Definition indicator.hpp:35
constexpr Indicator(uint8_t pin) noexcept
Construct a new Indicator object using standard I/O.
Definition indicator.hpp:54
auto addActuator(uint8_t actuatorIndex) -> Indicator &
Add one actuator to controlled controlledActuators vector.
Definition indicator.cpp:62
auto setMode(constants::IndicatorMode indicatorMode) -> Indicator &
Set the mode of the indicator.
Definition indicator.cpp:74
void setIndex(uint8_t indexToSet)
Set the indicator index on Indicators namespace Array.
Definition indicator.cpp:51
void resizeVectors()
Resize controlled actuators vector to its actual size.
Definition indicator.cpp:170
auto getIndex() const -> uint8_t
Get the indicator index on Indicators namespace Array.
Definition indicator.cpp:180
void setState(bool stateToSet)
Set the state of the indicator.
Definition indicator.cpp:30
void check()
Switch the indicator based on controlled actuators status.
Definition indicator.cpp:100
Defines the IndicatorMode enum for indicator light behavior.
IndicatorMode
Indicator mode for an indicator.
Definition indicatormodes.hpp:36
@ ANY
If any controlled actuators is ON turn on the indicator.
Internal bridge that imports user-defined macros into the library's scope.