Control Surface  1.1.1
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
MAX7219 Class Reference

A class for LED outputs using the MAX7219 LED display driver. More...

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

Inheritance diagram for MAX7219:
Collaboration diagram for MAX7219:

Public Member Functions

 MAX7219 (pin_t loadPin)
 Create a MAX7219 ExtendedIOElement. More...
 
void begin () override
 Initialize. More...
 
void pinMode (pin_t pin, uint8_t mode) override __attribute__((deprecated))
 The pinMode function is not implemented because the mode is OUTPUT by definition. More...
 
void digitalWrite (pin_t pin, uint8_t val) override
 Set the state of a given output pin. More...
 
int digitalRead (pin_t pin) override
 Get the current state of a given output. More...
 
analog_t analogRead (pin_t pin) override __attribute__((deprecated))
 The analogRead function is deprecated because a MAX7219 is always digital. More...
 
void analogWrite (pin_t pin, analog_t val) override __attribute__((deprecated))
 The analogWrite function is deprecated because a MAX7219 is always digital. More...
 
void update () override
 Write the buffer to the display. More...
 
void init ()
 Initialize the Arduino pins, SPI, and the MAX7219. More...
 
void clear ()
 Turn off all LEDs. More...
 
void send (uint8_t digit, uint8_t value)
 Send the value to the given digit. More...
 
void sendRaw (uint8_t opcode, uint8_t value)
 Send a raw opcode and value to the MAX7219. More...
 
void setIntensity (uint8_t intensity)
 Set the intensity of the LEDs. More...
 
Array< pin_t, N > pins () const
 Get an array containing all pins of the element. 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...
 

Static Public Attributes

static constexpr uint8_t DECODEMODE = 9
 
static constexpr uint8_t INTENSITY = 10
 
static constexpr uint8_t SCANLIMIT = 11
 
static constexpr uint8_t SHUTDOWN = 12
 
static constexpr uint8_t DISPLAYTEST = 15
 

Protected Attributes

ExtendedIOElementnext
 
ExtendedIOElementprevious
 

Private Attributes

BitArray< 8 *8 > buffer
 
pin_t loadPin
 
SPISettings settings = {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
 
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

A class for LED outputs using the MAX7219 LED display driver.

The SPI interface is used.

Todo:
Wiring diagram for SPI connection.

Definition at line 21 of file MAX7219.hpp.

Constructor & Destructor Documentation

◆ MAX7219()

MAX7219 ( pin_t  loadPin)
inline

Create a MAX7219 ExtendedIOElement.

Parameters
loadPinThe pin connected to the load pin (C̄S̄) of the MAX7219.

Definition at line 29 of file MAX7219.hpp.

Member Function Documentation

◆ begin()

void begin ( )
inlineoverridevirtual

Initialize.

See also
MAX7219::init

Implements ExtendedIOElement.

Definition at line 33 of file MAX7219.hpp.

◆ pinMode()

void pinMode ( pin_t  pin,
uint8_t  mode 
)
inlineoverridevirtual

The pinMode function is not implemented because the mode is OUTPUT by definition.

Implements ExtendedIOElement.

Definition at line 39 of file MAX7219.hpp.

◆ digitalWrite()

void digitalWrite ( pin_t  pin,
uint8_t  val 
)
inlineoverridevirtual

Set the state of a given output pin.

Parameters
pinThe output pin to set.
valThe value to set the output to. (Either HIGH (1) or LOW (0))

Implements ExtendedIOElement.

Definition at line 53 of file MAX7219.hpp.

◆ digitalRead()

int digitalRead ( pin_t  pin)
inlineoverridevirtual

Get the current state of a given output.

Parameters
pinThe output to read the state from.
Return values
0The state of the output is LOW.
1The state of the output is HIGH.

Implements ExtendedIOElement.

Definition at line 68 of file MAX7219.hpp.

◆ analogRead()

analog_t analogRead ( pin_t  pin)
inlineoverridevirtual

The analogRead function is deprecated because a MAX7219 is always digital.

Parameters
pinThe output to read the state from.
Return values
0The state of the output is LOW.
1023The state of the output is HIGH.

Implements ExtendedIOElement.

Definition at line 80 of file MAX7219.hpp.

◆ analogWrite()

void analogWrite ( pin_t  pin,
analog_t  val 
)
inlineoverridevirtual

The analogWrite function is deprecated because a MAX7219 is always digital.

Parameters
pinThe output to set.
valThe value to set the output to. A value greater or equal to 0x80 will set the output to a HIGH state, a value less than 0x80 will set the output to a LOW state.
Note
This function is just implemented for compatibility. Don't use it in new code.

Implements ExtendedIOElement.

Definition at line 97 of file MAX7219.hpp.

◆ update()

void update ( )
inlineoverridevirtual

Write the buffer to the display.

Todo:
Does this really have to happen on each update?

Implements ExtendedIOElement.

Definition at line 107 of file MAX7219.hpp.

◆ init()

void init ( )
inlineinherited

Initialize the Arduino pins, SPI, and the MAX7219.

Todo:
Rename to begin.

Definition at line 43 of file MAX7219_Base.hpp.

◆ clear()

void clear ( )
inlineinherited

Turn off all LEDs.

Definition at line 58 of file MAX7219_Base.hpp.

◆ send()

void send ( uint8_t  digit,
uint8_t  value 
)
inlineinherited

Send the value to the given digit.

Parameters
digitThe digit or row to set [0, 7].
valueThe value to set the row to.

Definition at line 71 of file MAX7219_Base.hpp.

◆ sendRaw()

void sendRaw ( uint8_t  opcode,
uint8_t  value 
)
inlineinherited

Send a raw opcode and value to the MAX7219.

Parameters
opcodeThe opcode to send.
valueThe value to send.

Definition at line 83 of file MAX7219_Base.hpp.

◆ setIntensity()

void setIntensity ( uint8_t  intensity)
inlineinherited

Set the intensity of the LEDs.

Parameters
intensityThe intensity [0, 15].

Definition at line 98 of file MAX7219_Base.hpp.

◆ pins()

Array<pin_t, N> pins ( ) const
inlineinherited

Get an array containing all pins of the element.

Definition at line 27 of file StaticSizeExtendedIOElement.hpp.

◆ length()

static constexpr uint16_t length ( )
inlinestaticconstexprinherited

Definition at line 31 of file StaticSizeExtendedIOElement.hpp.

◆ beginAll()

void beginAll ( )
staticinherited

Initialize all extended IO elements.

Definition at line 23 of file ExtendedIOElement.cpp.

◆ pin()

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

Definition at line 28 of file ExtendedIOElement.cpp.

◆ operator[]()

pin_t 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 43 of file ExtendedIOElement.cpp.

◆ getLength()

pin_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 45 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 47 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 49 of file ExtendedIOElement.cpp.

◆ getAll()

DoublyLinkedList< ExtendedIOElement > & getAll ( )
staticinherited

Get the list of all Extended IO elements.

Definition at line 51 of file ExtendedIOElement.cpp.

Member Data Documentation

◆ buffer

BitArray<8 * 8> buffer
private

Definition at line 113 of file MAX7219.hpp.

◆ DECODEMODE

constexpr uint8_t DECODEMODE = 9
staticconstexprinherited

Definition at line 33 of file MAX7219_Base.hpp.

◆ INTENSITY

constexpr uint8_t INTENSITY = 10
staticconstexprinherited

Definition at line 34 of file MAX7219_Base.hpp.

◆ SCANLIMIT

constexpr uint8_t SCANLIMIT = 11
staticconstexprinherited

Definition at line 35 of file MAX7219_Base.hpp.

◆ SHUTDOWN

constexpr uint8_t SHUTDOWN = 12
staticconstexprinherited

Definition at line 36 of file MAX7219_Base.hpp.

◆ DISPLAYTEST

constexpr uint8_t DISPLAYTEST = 15
staticconstexprinherited

Definition at line 37 of file MAX7219_Base.hpp.

◆ loadPin

pin_t loadPin
privateinherited

Definition at line 103 of file MAX7219_Base.hpp.

◆ settings

SPISettings settings = {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
privateinherited

Definition at line 104 of file MAX7219_Base.hpp.

◆ start

const pin_t start
privateinherited

Definition at line 193 of file ExtendedIOElement.hpp.

◆ end

const pin_t end
privateinherited

Definition at line 194 of file ExtendedIOElement.hpp.

◆ offset

pin_t offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS
staticprivateinherited

Definition at line 195 of file ExtendedIOElement.hpp.

◆ elements

DoublyLinkedList< ExtendedIOElement > elements
staticprivateinherited

Definition at line 197 of file ExtendedIOElement.hpp.

◆ next

ExtendedIOElement * next
protectedinherited

Definition at line 305 of file LinkedList.hpp.

◆ previous

ExtendedIOElement * previous
protectedinherited

Definition at line 306 of file LinkedList.hpp.


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