Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | Static Private Attributes | List of all members
StaticSizeExtendedIOElement< N > Class Template Referenceabstract

#include <AH/Hardware/ExtendedInputOutput/StaticSizeExtendedIOElement.hpp>

Detailed Description

template<uint16_t N>
class AH::StaticSizeExtendedIOElement< N >

A class for ExtendedIOElements with a fixed size.

This class is to make it easier to get an array of all pins of the element.

Definition at line 16 of file StaticSizeExtendedIOElement.hpp.

+ Inheritance diagram for StaticSizeExtendedIOElement< N >:
+ Collaboration diagram for StaticSizeExtendedIOElement< N >:

Enabling and disabling updatables

void enable ()
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
void disable ()
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
bool isEnabled () const
 Check if this updatable is enabled.
 
void moveDown ()
 Move down this element in the list.
 
static void enable (UpdatableCRTP *element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void enable (UpdatableCRTP &element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void enable (U(&array)[N])
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void disable (UpdatableCRTP *element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
static void disable (UpdatableCRTP &element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
static void disable (U(&array)[N])
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 

Public Member Functions

Array< pin_t, N > pins () const
 Get an array containing all pins of the element.
 
virtual void pinMode (pin_int_t pin, PinMode_t mode)
 Set the mode of a given pin.
 
virtual void pinModeBuffered (pin_int_t pin, PinMode_t mode)=0
 Set the mode of a given pin in the software buffer.
 
virtual void digitalWrite (pin_int_t pin, PinStatus_t state)
 Set the output of the given pin to the given state.
 
virtual void digitalWriteBuffered (pin_int_t pin, PinStatus_t state)=0
 Set the output of a given pin in the software buffer.
 
virtual PinStatus_t digitalRead (pin_int_t pin)
 Read the state of the given pin.
 
virtual PinStatus_t digitalReadBuffered (pin_int_t pin)=0
 Read the state of the given pin from the software buffer.
 
virtual void analogWrite (pin_int_t pin, analog_t val)
 Write an analog (or PWM) value to the given pin.
 
virtual void analogWriteBuffered (pin_int_t pin, analog_t val)=0
 Write an analog (or PWM) value to the software buffer given pin.
 
virtual analog_t analogRead (pin_int_t pin)
 Read the analog value of the given pin.
 
virtual analog_t analogReadBuffered (pin_int_t pin)=0
 Read the analog value of the given pin from the software buffer.
 
virtual void begin ()=0
 Initialize the extended IO element.
 
virtual void updateBufferedOutputs ()=0
 Write the internal state to the physical outputs.
 
virtual void updateBufferedInputs ()=0
 Read the physical state into the input buffers.
 
pin_t pin (pin_int_t pin) const
 Get the extended IO pin number of a given physical pin of this extended IO element.
 
pin_t operator[] (pin_int_t pin) const
 Get the extended IO pin number of a given physical pin of this extended IO element.
 
pin_int_t getLength () const
 Get the number of pins this IO element has.
 
pin_t getEnd () const
 Get the largest global extended IO pin number that belongs to this extended IO element.
 
pin_t getStart () const
 Get the smallest global extended IO pin number that belongs to this extended IO element.
 

Static Public Member Functions

static constexpr uint16_t length ()
 
static void beginAll ()
 Initialize all extended IO elements.
 
static void updateAllBufferedOutputs ()
 Write the internal states to the physical outputs for all extended IO elements.
 
static void updateAllBufferedInputs ()
 Read the physical state into the input buffers for all extended IO elements.
 
static DoublyLinkedList< ExtendedIOElement > & getAll ()
 Get the list of all Extended IO elements.
 

Protected Member Functions

 StaticSizeExtendedIOElement ()
 

Protected Attributes

Nodenext = nullptr
 
Nodeprevious = nullptr
 

Static Protected Attributes

static DoublyLinkedList< ExtendedIOElementupdatables
 

Private Attributes

const pin_t start
 
const pin_t end
 

Static Private Attributes

static pin_t offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
 

Constructor & Destructor Documentation

◆ StaticSizeExtendedIOElement()

template<uint16_t N>
StaticSizeExtendedIOElement ( )
inlineprotected

Definition at line 18 of file StaticSizeExtendedIOElement.hpp.

Member Function Documentation

◆ pins()

template<uint16_t N>
Array< pin_t, N > pins ( ) const
inline

Get an array containing all pins of the element.

Definition at line 24 of file StaticSizeExtendedIOElement.hpp.

◆ length()

template<uint16_t N>
static constexpr uint16_t length ( )
inlinestaticconstexpr
Examples
Toggle-LEDs.ino.

Definition at line 28 of file StaticSizeExtendedIOElement.hpp.

◆ pinMode()

virtual void pinMode ( pin_int_t pin,
PinMode_t mode )
inlinevirtualinherited

Set the mode of a given pin.

Note
This function might not be implemented by all subclasses.
Some extended IO types, such as shift registers, can only be used as outputs.
On others, it might be implemented, but it could impact all pins of the IO element. For example, enabling the internal pull-up resistor on an analog multiplexer affects all pins of the mux.
Parameters
pinThe (zero-based) pin of this IO element.
modeThe mode to set the pin to (e.g. INPUT, OUTPUT or INPUT_PULLUP).

Reimplemented in MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

Definition at line 95 of file ExtendedIOElement.hpp.

◆ pinModeBuffered()

virtual void pinModeBuffered ( pin_int_t pin,
PinMode_t mode )
pure virtualinherited

Set the mode of a given pin in the software buffer.

The buffer is written to the ExtIO device when updateBufferedOutputs is called.

Note
This function might not be implemented by all subclasses.
Some extended IO types, such as shift registers, can only be used as outputs.
On others, it might be implemented, but it could impact all pins of the IO element. For example, enabling the internal pull-up resistor on an analog multiplexer affects all pins of the mux.
Parameters
pinThe (zero-based) pin of this IO element.
modeThe mode to set the pin to (e.g. INPUT, OUTPUT or INPUT_PULLUP).

Implemented in MCP23017< WireType >, MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

◆ digitalWrite()

virtual void digitalWrite ( pin_int_t pin,
PinStatus_t state )
inlinevirtualinherited

Set the output of the given pin to the given state.

Parameters
pinThe (zero-based) pin of this IO element.
stateThe new state to set the pin to.

Reimplemented in MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

Definition at line 116 of file ExtendedIOElement.hpp.

◆ digitalWriteBuffered()

virtual void digitalWriteBuffered ( pin_int_t pin,
PinStatus_t state )
pure virtualinherited

Set the output of a given pin in the software buffer.

The buffer is written to the ExtIO device when updateBufferedOutputs is called.

Parameters
pinThe (zero-based) pin of this IO element.
stateThe new state to set the pin to.

Implemented in MCP23017< WireType >, MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

◆ digitalRead()

virtual PinStatus_t digitalRead ( pin_int_t pin)
inlinevirtualinherited

Read the state of the given pin.

Parameters
pinThe (zero-based) pin of this IO element.
Returns
The state of the given pin.

Reimplemented in MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

Definition at line 136 of file ExtendedIOElement.hpp.

◆ digitalReadBuffered()

virtual PinStatus_t digitalReadBuffered ( pin_int_t pin)
pure virtualinherited

Read the state of the given pin from the software buffer.

To update the buffer, you have to call updateBufferedInputs first.

Parameters
pinThe (zero-based) pin of this IO element.
Returns
The state of the given pin.

Implemented in MAX7219< NumChips, SPIDriver >, MCP23017< WireType >, and ShiftRegisterOutBase< N >.

◆ analogWrite()

virtual void analogWrite ( pin_int_t pin,
analog_t val )
inlinevirtualinherited

Write an analog (or PWM) value to the given pin.

Parameters
pinThe (zero-based) pin of this IO element.
valThe new analog value to set the pin to.

Reimplemented in MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

Definition at line 156 of file ExtendedIOElement.hpp.

◆ analogWriteBuffered()

virtual void analogWriteBuffered ( pin_int_t pin,
analog_t val )
pure virtualinherited

Write an analog (or PWM) value to the software buffer given pin.

The buffer is written to the ExtIO device when updateBufferedOutputs is called.

Parameters
pinThe (zero-based) pin of this IO element.
valThe new analog value to set the pin to.

Implemented in MAX7219< NumChips, SPIDriver >, ShiftRegisterOutBase< N >, and MCP23017< WireType >.

◆ analogRead()

virtual analog_t analogRead ( pin_int_t pin)
inlinevirtualinherited

Read the analog value of the given pin.

Parameters
pinThe (zero-based) pin of this IO element.
Returns
The new analog value of pin.

Reimplemented in MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

Definition at line 176 of file ExtendedIOElement.hpp.

◆ analogReadBuffered()

virtual analog_t analogReadBuffered ( pin_int_t pin)
pure virtualinherited

Read the analog value of the given pin from the software buffer.

To update the buffer, you have to call updateBufferedInputs first.

Parameters
pinThe (zero-based) pin of this IO element.
Returns
The new analog value of pin.

Implemented in MCP23017< WireType >, MAX7219< NumChips, SPIDriver >, and ShiftRegisterOutBase< N >.

◆ begin()

virtual void begin ( )
pure virtualinherited

◆ beginAll()

void beginAll ( )
staticinherited

Initialize all extended IO elements.

Definition at line 17 of file ExtendedIOElement.cpp.

◆ updateBufferedOutputs()

virtual void updateBufferedOutputs ( )
pure virtualinherited

Write the internal state to the physical outputs.

Implemented in MAX7219< NumChips, SPIDriver >, MCP23017< WireType >, ShiftRegisterOut< N >, and SPIShiftRegisterOut< N, SPIDriver >.

◆ updateAllBufferedOutputs()

void updateAllBufferedOutputs ( )
staticinherited

Write the internal states to the physical outputs for all extended IO elements.

Definition at line 21 of file ExtendedIOElement.cpp.

◆ updateBufferedInputs()

virtual void updateBufferedInputs ( )
pure virtualinherited

Read the physical state into the input buffers.

Implemented in MAX7219< NumChips, SPIDriver >, MCP23017< WireType >, and ShiftRegisterOutBase< N >.

◆ updateAllBufferedInputs()

void updateAllBufferedInputs ( )
staticinherited

Read the physical state into the input buffers for all extended IO elements.

Definition at line 25 of file ExtendedIOElement.cpp.

◆ pin()

pin_t pin ( pin_int_t pin) const
inherited

Get the extended IO pin number of a given physical pin of this extended IO element.

Parameters
pinThe zero-based physical pin number of this IO element.
Returns
The global, unique extended IO pin number for the given pin.

Definition at line 29 of file ExtendedIOElement.cpp.

◆ operator[]()

pin_t operator[] ( pin_int_t pin) const
inherited

Get the extended IO pin number of a given physical pin of this extended IO element.


It is alias for ExtendedIOElement::pin.

Parameters
pinThe zero-based physical pin number of this IO element.
Returns
The global, unique extended IO pin number for the given pin.

Definition at line 45 of file ExtendedIOElement.cpp.

◆ getLength()

pin_int_t getLength ( ) const
inherited

Get the number of pins this IO element has.

Returns
The number of pins this IO element has.

Definition at line 47 of file ExtendedIOElement.cpp.

◆ getEnd()

pin_t getEnd ( ) const
inherited

Get the largest global extended IO pin number that belongs to this extended IO element.

Definition at line 49 of file ExtendedIOElement.cpp.

◆ getStart()

pin_t getStart ( ) const
inherited

Get the smallest global extended IO pin number that belongs to this extended IO element.

Definition at line 51 of file ExtendedIOElement.cpp.

◆ getAll()

DoublyLinkedList< ExtendedIOElement > & getAll ( )
staticinherited

Get the list of all Extended IO elements.

Definition at line 53 of file ExtendedIOElement.cpp.

◆ enable() [1/4]

void enable ( )
inlineinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 96 of file Updatable.hpp.

◆ enable() [2/4]

static void enable ( UpdatableCRTP< ExtendedIOElement > * element)
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 125 of file Updatable.hpp.

◆ enable() [3/4]

static void enable ( UpdatableCRTP< ExtendedIOElement > & element)
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 127 of file Updatable.hpp.

◆ enable() [4/4]

static void enable ( U(&) array[N])
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 130 of file Updatable.hpp.

◆ disable() [1/4]

void disable ( )
inlineinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 106 of file Updatable.hpp.

◆ disable() [2/4]

static void disable ( UpdatableCRTP< ExtendedIOElement > * element)
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 136 of file Updatable.hpp.

◆ disable() [3/4]

static void disable ( UpdatableCRTP< ExtendedIOElement > & element)
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 138 of file Updatable.hpp.

◆ disable() [4/4]

static void disable ( U(&) array[N])
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 141 of file Updatable.hpp.

◆ isEnabled()

bool isEnabled ( ) const
inlineinherited

Check if this updatable is enabled.

Note
Assumes that the updatable is not added to a different linked list by the user.

Definition at line 120 of file Updatable.hpp.

◆ moveDown()

void moveDown ( )
inlineinherited

Move down this element in the list.

Definition at line 147 of file Updatable.hpp.

Member Data Documentation

◆ start

const pin_t start
privateinherited

Definition at line 265 of file ExtendedIOElement.hpp.

◆ end

const pin_t end
privateinherited

Definition at line 266 of file ExtendedIOElement.hpp.

◆ offset

pin_t offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
staticprivateinherited

Definition at line 267 of file ExtendedIOElement.hpp.

◆ updatables

DoublyLinkedList< ExtendedIOElement > updatables
staticprotectedinherited

Definition at line 152 of file Updatable.hpp.

◆ next

template<class Node >
Node* next = nullptr
protectedinherited

Definition at line 320 of file LinkedList.hpp.

◆ previous

template<class Node >
Node* previous = nullptr
protectedinherited

Definition at line 321 of file LinkedList.hpp.


The documentation for this class was generated from the following file: