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)
89#ifdef CONFIG_USE_FAST_INDICATORS
92 *this->pinPort &= ~this->pinMask;
96 *this->pinPort |= this->pinMask;
99 digitalWrite(this->pinNumber,
static_cast<uint8_t
>(stateToSet));
107 [[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:43
auto setMode(constants::IndicatorMode indicatorMode) -> Indicator &
Set the mode of the indicator.
Definition indicator.cpp:55
void setIndex(uint8_t indexToSet)
Set the indicator index on Indicators namespace Array.
Definition indicator.cpp:32
auto getIndex() const -> uint8_t
Get the indicator index on Indicators namespace Array.
Definition indicator.cpp:154
void setState(bool stateToSet)
Set the state of the indicator.
Definition indicator.hpp:87
void check()
Switch the indicator based on controlled actuators status.
Definition indicator.cpp:81
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.