21#ifndef LSH_CORE_PERIPHERALS_OUTPUT_INDICATOR_HPP
22#define LSH_CORE_PERIPHERALS_OUTPUT_INDICATOR_HPP
29#ifdef CONFIG_USE_FAST_INDICATORS
40#ifndef CONFIG_USE_FAST_INDICATORS
41 const uint8_t pinNumber;
43 const uint8_t pinMask;
44 volatile uint8_t *
const pinPort;
56 const uint8_t oldSREG = SREG;
58 *this->pinPort &= ~this->pinMask;
63#if defined(LSH_DEBUG) || defined(LSH_STATIC_CONFIG_RUNTIME_CHECKS)
64 uint8_t index = UINT8_MAX;
66 bool actualState =
false;
69#ifndef CONFIG_USE_FAST_INDICATORS
74 explicit LSH_OPTIONAL_CONSTEXPR_CTOR
Indicator(uint8_t pin) noexcept : pinNumber(pin)
76 digitalWrite(pin, LOW);
86 template <u
int8_t Pin>
94 explicit Indicator(uint8_t pin) noexcept :
Indicator(lsh::core::avr::makeFastOutputPinBinding(pin))
103 template <u
int8_t Pin>
122#ifdef CONFIG_USE_FAST_INDICATORS
125 *this->pinPort &= ~this->pinMask;
129 *this->pinPort |= this->pinMask;
132 digitalWrite(this->pinNumber,
static_cast<uint8_t
>(stateToSet));
135 void applyComputedState(
bool newState)
140 if (newState == this->actualState)
144 this->actualState = newState;
150 [[nodiscard]]
auto getIndex() const -> uint8_t;
Typed helpers for AVR fast I/O access without Arduino macro casts.
Represents a state indicator for one or more attached actuators, indicators are normally connected to...
Definition indicator.hpp:38
LSH_OPTIONAL_CONSTEXPR_CTOR Indicator(uint8_t pin) noexcept
Construct a new Indicator object using standard I/O.
Definition indicator.hpp:74
void setIndex(uint8_t indexToSet)
Set the indicator index on Indicators namespace Array.
Definition indicator.cpp:31
auto getIndex() const -> uint8_t
Get the indicator index on Indicators namespace Array.
Definition indicator.cpp:68
void setState(bool stateToSet)
Set the state of the indicator.
Definition indicator.hpp:120
LSH_OPTIONAL_CONSTEXPR_CTOR Indicator(lsh::core::PinTag< Pin >) noexcept
Construct an indicator from a compile-time pin tag on the slow-I/O path.
Definition indicator.hpp:87
void check()
Switch the indicator based on controlled actuators status.
Definition indicator.cpp:55
Centralized C++ feature-detection macros for lsh-core.
Compile-time pin tag used to route peripheral construction through constant pin paths.
Type-level wrapper around one Arduino pin number.
Definition pin_tag.hpp:41
Resolved fast-output binding for one Arduino pin.
Definition avr_fast_io.hpp:62
volatile uint8_t * modePort
Final AVR DDR register used to configure the pin direction.
Definition avr_fast_io.hpp:65
volatile uint8_t * pinPort
Final AVR output register used to drive the pin.
Definition avr_fast_io.hpp:64
uint8_t mask
Final bit mask for the pin inside the AVR port.
Definition avr_fast_io.hpp:63
Internal bridge that imports static profile resources into the library's scope.