8#include "ExtendedInputOutput.hpp"
102 updateBufferedOutputs();
123 updateBufferedOutputs();
142 updateBufferedInputs();
163 updateBufferedOutputs();
182 updateBufferedInputs();
201 static void beginAll();
212 static void updateAllBufferedOutputs();
223 static void updateAllBufferedInputs();
249 pin_t getLength()
const;
255 pin_t getEnd()
const;
261 pin_t getStart()
const;
281 elementPin(element ? pin - element->getStart() : pin) {}
283 template <
class FRet,
class... FArgs,
class Fallback>
284 FRet __attribute__((always_inline))
287 if (element !=
nullptr)
288 return (element->*func)(elementPin, args...);
289 else if (elementPin !=
NO_PIN)
292 return static_cast<FRet
>(0);
356 else if (dataPin.
element !=
nullptr && clockPin.
element !=
nullptr) {
357 const auto dataEl = dataPin.
element;
359 const auto clockEl = clockPin.
element;
361 for (uint8_t i = 0; i < 8; i++) {
362 uint8_t mask = bitOrder == LSBFIRST ? (1 << i) : (1 << (7 - i));
363 dataEl->digitalWrite(dataPinN, (val & mask) ?
HIGH :
LOW);
364 clockEl->digitalWrite(clockPinN,
HIGH);
365 clockEl->digitalWrite(clockPinN,
LOW);
370 for (uint8_t i = 0; i < 8; i++) {
371 uint8_t mask = bitOrder == LSBFIRST ? (1 << i) : (1 << (7 - i));
426using ExtIO::CachedExtIOPin;
#define BEGIN_AH_NAMESPACE
constexpr PinStatus_t LOW
AH::function_traits< decltype(::digitalWrite)>::argument_t< 0 > ArduinoPin_t
constexpr PinStatus_t HIGH
AH::function_traits< decltype(::pinMode)>::argument_t< 1 > PinMode_t
AH::function_traits< decltype(::digitalWrite)>::argument_t< 1 > PinStatus_t
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
An abstract base class for Extended Input/Output elements.
ExtendedIOElement(ExtendedIOElement &&)=default
Move constructor.
virtual void updateBufferedInputs()=0
Read the physical state into the input buffers.
ExtendedIOElement(const ExtendedIOElement &)=delete
Copying not allowed.
virtual void updateBufferedOutputs()=0
Write the internal state to the physical outputs.
virtual void analogWriteBuffered(pin_t pin, analog_t val)=0
Write an analog (or PWM) value to the software buffer given pin.
virtual analog_t analogRead(pin_t pin)
Read the analog value of the given pin.
virtual PinStatus_t digitalReadBuffered(pin_t pin)=0
Read the state of the given pin from the software buffer.
virtual void digitalWriteBuffered(pin_t pin, PinStatus_t state)=0
Set the output of a given pin in the software buffer.
virtual void pinMode(pin_t pin, PinMode_t mode)
Set the mode of a given pin.
ExtendedIOElement & operator=(const ExtendedIOElement &)=delete
Copying not allowed.
virtual void begin()=0
Initialize the extended IO element.
virtual void analogWrite(pin_t pin, analog_t val)
Write an analog (or PWM) value to the given pin.
ExtendedIOElement & operator=(ExtendedIOElement &&)=delete
Move assignment.
virtual void digitalWrite(pin_t pin, PinStatus_t state)
Set the output of the given pin to the given state.
virtual void pinModeBuffered(pin_t pin, PinMode_t mode)=0
Set the mode of a given pin in the software buffer.
virtual analog_t analogReadBuffered(pin_t pin)=0
Read the analog value of the given pin from the software buffer.
virtual PinStatus_t digitalRead(pin_t pin)
Read the state of the given pin.
A super class for object that have to be updated regularly.
Array< decltype(F{}(U{})), N > apply(const Array< U, N > &src, F f)
Apply a function to all elements of the array and return a copy.
bool isNativePin(pin_t pin)
Check if the given pin number is a real Arduino pin number, and not an ExtIO pin number.
ExtendedIOElement * getIOElementOfPin(pin_t pin)
Find the IO element of a given extended IO pin number.
analog_t analogReadBuffered(CachedExtIOPin pin)
A buffered ExtIO version of the Arduino function.
void shiftOut(CachedExtIOPin dataPin, CachedExtIOPin clockPin, BitOrder_t bitOrder, uint8_t val)
An ExtIO version of the Arduino function.
void pinModeBuffered(CachedExtIOPin pin, PinMode_t mode)
A buffered ExtIO version of the Arduino function.
void digitalWrite(CachedExtIOPin pin, PinStatus_t val)
An ExtIO version of the Arduino function.
void digitalWriteBuffered(CachedExtIOPin pin, PinStatus_t val)
A buffered ExtIO version of the Arduino function.
PinStatus_t digitalReadBuffered(CachedExtIOPin pin)
A buffered ExtIO version of the Arduino function.
void analogWrite(CachedExtIOPin pin, int val)
An ExtIO version of the Arduino function.
PinStatus_t digitalRead(CachedExtIOPin pin)
An ExtIO version of the Arduino function.
void analogWriteBuffered(CachedExtIOPin pin, int val)
A buffered ExtIO version of the Arduino function.
analog_t analogRead(CachedExtIOPin pin)
An ExtIO version of the Arduino function.
void pinMode(CachedExtIOPin pin, PinMode_t mode)
An ExtIO version of the Arduino function.
uint16_t analog_t
The type returned from analogRead and similar functions.
constexpr pin_t NO_PIN
A special pin number that indicates an unused or invalid pin.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
ArduinoPin_t arduino_pin_cast(T t)
ExtendedIOElement * element
CachedExtIOPin(pin_t pin)