This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
ExtendedIOElement.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
5 #include <Def/Def.hpp>
6 #include <Helpers/LinkedList.hpp>
7 
9 
59 class ExtendedIOElement : public DoublyLinkable<ExtendedIOElement> {
60  protected:
68 
69  public:
70  virtual ~ExtendedIOElement();
71 
88  virtual void pinMode(pin_t pin, uint8_t mode) = 0;
89 
98  virtual void digitalWrite(pin_t pin, uint8_t state) = 0;
99 
107  virtual int digitalRead(pin_t pin) = 0;
108 
117  virtual void analogWrite(pin_t pin, analog_t val) = 0;
118 
126  virtual analog_t analogRead(pin_t pin) = 0;
127 
131  virtual void begin() = 0;
132 
136  static void beginAll();
137 
143  virtual void update() = 0;
144 
152  pin_t pin(pin_t pin) const;
153 
162  pin_t operator[](pin_t pin) const;
163 
169  pin_t getLength() const;
170 
175  pin_t getEnd() const;
176 
181  pin_t getStart() const;
182 
187 
188  private:
189  const pin_t length;
190  const pin_t start;
191  const pin_t end;
192  static pin_t offset;
193 
195 };
196 
ExtendedIOElement::length
const pin_t length
Definition: ExtendedIOElement.hpp:189
ExtendedIOElement::pinMode
virtual void pinMode(pin_t pin, uint8_t mode)=0
Set the mode of a given pin.
ExtendedIOElement::end
const pin_t end
Definition: ExtendedIOElement.hpp:191
pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Def.hpp:17
ExtendedIOElement::update
virtual void update()=0
Update the extended IO element: write the internal state to the physical outputs, or read the physica...
Def.hpp
ExtendedIOElement::~ExtendedIOElement
virtual ~ExtendedIOElement()
Definition: ExtendedIOElement.cpp:19
ExtendedIOElement::getStart
pin_t getStart() const
Get the smallest global extended IO pin number that belongs to this extended IO element.
Definition: ExtendedIOElement.cpp:47
LinkedList.hpp
ExtendedIOElement::operator[]
pin_t operator[](pin_t pin) const
Get the extended IO pin number of a given physical pin of this extended IO element.
Definition: ExtendedIOElement.cpp:41
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition: Def.hpp:15
ExtendedIOElement::getLength
pin_t getLength() const
Get the number of pins this IO element has.
Definition: ExtendedIOElement.cpp:43
ExtendedIOElement::offset
static pin_t offset
Definition: ExtendedIOElement.hpp:192
ExtendedIOElement::getEnd
pin_t getEnd() const
Get the largest global extended IO pin number that belongs to this extended IO element.
Definition: ExtendedIOElement.cpp:45
ExtendedIOElement::pin
pin_t pin(pin_t pin) const
Get the extended IO pin number of a given physical pin of this extended IO element.
Definition: ExtendedIOElement.cpp:26
ExtendedIOElement::getAll
static DoublyLinkedList< ExtendedIOElement > & getAll()
Get the list of all Extended IO elements.
Definition: ExtendedIOElement.cpp:49
ExtendedIOElement::start
const pin_t start
Definition: ExtendedIOElement.hpp:190
ExtendedIOElement
An abstract base class for Extended Input/Output elements.
Definition: ExtendedIOElement.hpp:59
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
ExtendedIOElement::digitalWrite
virtual void digitalWrite(pin_t pin, uint8_t state)=0
Set the output of the given pin to the given state.
ExtendedIOElement::analogWrite
virtual void analogWrite(pin_t pin, analog_t val)=0
Write an analog (or PWM) value to the given pin.
DoublyLinkedList< ExtendedIOElement >
DoublyLinkable
A class that can be inherited from to allow inserting into a DoublyLinkedList.
Definition: LinkedList.hpp:298
ExtendedIOElement::elements
static DoublyLinkedList< ExtendedIOElement > elements
Definition: ExtendedIOElement.hpp:194
ExtendedIOElement::begin
virtual void begin()=0
Initialize the extended IO element.
ExtendedIOElement::ExtendedIOElement
ExtendedIOElement(pin_t length)
Create an ExtendedIOElement with the given number of pins.
Definition: ExtendedIOElement.cpp:8
ExtendedIOElement::beginAll
static void beginAll()
Initialize all extended IO elements.
Definition: ExtendedIOElement.cpp:21
ExtendedIOElement::digitalRead
virtual int digitalRead(pin_t pin)=0
Read the state of the given pin.
ExtendedIOElement::analogRead
virtual analog_t analogRead(pin_t pin)=0
Read the analog value of the given pin.