This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
StaticSizeExtendedIOElement< N > Class Template Referenceabstract

A class for ExtendedIOElements with a fixed size. More...

#include <StaticSizeExtendedIOElement.hpp>

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

Public Member Functions

Array< pin_t, N > pins () const
 Get an array containing all pins of the element. More...
 
virtual void pinMode (pin_t pin, uint8_t mode)=0
 Set the mode of a given pin. More...
 
virtual void digitalWrite (pin_t pin, uint8_t state)=0
 Set the output of the given pin to the given state. More...
 
virtual int digitalRead (pin_t pin)=0
 Read the state of the given pin. More...
 
virtual void analogWrite (pin_t pin, analog_t val)=0
 Write an analog (or PWM) value to the given pin. More...
 
virtual analog_t analogRead (pin_t pin)=0
 Read the analog value of the given pin. More...
 
virtual void begin ()=0
 Initialize the extended IO element. More...
 
virtual void update ()=0
 Update the extended IO element: write the internal state to the physical outputs, or read the physical state into the input buffers. More...
 
pin_t pin (pin_t pin) const
 Get the extended IO pin number of a given physical pin of this extended IO element. More...
 
pin_t operator[] (pin_t pin) const
 Get the extended IO pin number of a given physical pin of this extended IO element. More...
 
pin_t getLength () const
 Get the number of pins this IO element has. More...
 
pin_t getEnd () const
 Get the largest global extended IO pin number that belongs to this extended IO element. More...
 
pin_t getStart () const
 Get the smallest global extended IO pin number that belongs to this extended IO element. More...
 

Static Public Member Functions

static constexpr uint16_t length ()
 
static void beginAll ()
 Initialize all extended IO elements. More...
 
static DoublyLinkedList< ExtendedIOElement > & getAll ()
 Get the list of all Extended IO elements. More...
 

Protected Member Functions

 StaticSizeExtendedIOElement ()
 

Protected Attributes

ExtendedIOElementnext
 
ExtendedIOElementprevious
 

Private Attributes

const pin_t start
 
const pin_t end
 

Static Private Attributes

static pin_t offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
 
static DoublyLinkedList< ExtendedIOElementelements
 

Detailed Description

template<uint16_t N>
class 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.

Constructor & Destructor Documentation

◆ StaticSizeExtendedIOElement()

template<uint16_t N>
StaticSizeExtendedIOElement< N >::StaticSizeExtendedIOElement ( )
inlineprotected

Definition at line 18 of file StaticSizeExtendedIOElement.hpp.

Member Function Documentation

◆ pins()

template<uint16_t N>
Array<pin_t, N> StaticSizeExtendedIOElement< 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 StaticSizeExtendedIOElement< N >::length ( )
inlinestaticconstexpr

Definition at line 28 of file StaticSizeExtendedIOElement.hpp.

◆ pinMode()

virtual void ExtendedIOElement::pinMode ( pin_t  pin,
uint8_t  mode 
)
pure virtualinherited

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).

◆ digitalWrite()

virtual void ExtendedIOElement::digitalWrite ( pin_t  pin,
uint8_t  state 
)
pure virtualinherited

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.

Implemented in ShiftRegisterOutBase< N >, and MAX7219.

◆ digitalRead()

virtual int ExtendedIOElement::digitalRead ( pin_t  pin)
pure virtualinherited

Read the state of the given pin.

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

Implemented in AnalogMultiplex< N >, ShiftRegisterOutBase< N >, and MAX7219.

◆ analogWrite()

virtual void ExtendedIOElement::analogWrite ( pin_t  pin,
analog_t  val 
)
pure virtualinherited

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.

Implemented in MAX7219, and ShiftRegisterOutBase< N >.

◆ analogRead()

virtual analog_t ExtendedIOElement::analogRead ( pin_t  pin)
pure virtualinherited

Read the analog value of the given pin.

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

Implemented in ShiftRegisterOutBase< N >, MAX7219, and AnalogMultiplex< N >.

◆ begin()

virtual void ExtendedIOElement::begin ( )
pure virtualinherited

Initialize the extended IO element.

Implemented in AnalogMultiplex< N >, ShiftRegisterOut< N >, SPIShiftRegisterOut< N >, and MAX7219.

◆ beginAll()

void ExtendedIOElement::beginAll ( )
staticinherited

Initialize all extended IO elements.

Definition at line 21 of file ExtendedIOElement.cpp.

◆ update()

virtual void ExtendedIOElement::update ( )
pure virtualinherited

Update the extended IO element: write the internal state to the physical outputs, or read the physical state into the input buffers.

Implemented in AnalogMultiplex< N >, MAX7219, ShiftRegisterOut< N >, and SPIShiftRegisterOut< N >.

◆ pin()

pin_t ExtendedIOElement::pin ( pin_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.
Examples
1.First-Output.ino, and Toggle-LEDs.ino.

Definition at line 26 of file ExtendedIOElement.cpp.

◆ operator[]()

pin_t ExtendedIOElement::operator[] ( pin_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 41 of file ExtendedIOElement.cpp.

◆ getLength()

pin_t ExtendedIOElement::getLength ( ) const
inherited

Get the number of pins this IO element has.

Returns
The number of pins this IO element has.
Examples
1.AnalogReadSerial.ino, and 2.DigitalReadSerial.ino.

Definition at line 43 of file ExtendedIOElement.cpp.

◆ getEnd()

pin_t ExtendedIOElement::getEnd ( ) const
inherited

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

Definition at line 45 of file ExtendedIOElement.cpp.

◆ getStart()

pin_t ExtendedIOElement::getStart ( ) const
inherited

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

Definition at line 47 of file ExtendedIOElement.cpp.

◆ getAll()

DoublyLinkedList< ExtendedIOElement > & ExtendedIOElement::getAll ( )
staticinherited

Get the list of all Extended IO elements.

Definition at line 49 of file ExtendedIOElement.cpp.

Member Data Documentation

◆ start

const pin_t ExtendedIOElement::start
privateinherited

Definition at line 190 of file ExtendedIOElement.hpp.

◆ end

const pin_t ExtendedIOElement::end
privateinherited

Definition at line 191 of file ExtendedIOElement.hpp.

◆ offset

pin_t ExtendedIOElement::offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
staticprivateinherited

Definition at line 192 of file ExtendedIOElement.hpp.

◆ elements

DoublyLinkedList< ExtendedIOElement > ExtendedIOElement::elements
staticprivateinherited

Definition at line 194 of file ExtendedIOElement.hpp.

◆ next

ExtendedIOElement * DoublyLinkable< ExtendedIOElement >::next
protectedinherited

Definition at line 301 of file LinkedList.hpp.

◆ previous

ExtendedIOElement * DoublyLinkable< ExtendedIOElement >::previous
protectedinherited

Definition at line 302 of file LinkedList.hpp.


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