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 | Static Public Attributes | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
MAX7219 Class Referenceabstract

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

#include <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 (UNUSED_PARAM pin_t pin, UNUSED_PARAM 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...
 
virtual void pinMode (pin_t pin, uint8_t mode)=0
 Set the mode of a given pin. 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 18 of file MAX7219.hpp.

Constructor & Destructor Documentation

◆ MAX7219()

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 26 of file MAX7219.hpp.

Member Function Documentation

◆ begin()

void MAX7219::begin ( )
inlineoverridevirtual

Initialize.

See also
MAX7219::init

Implements ExtendedIOElement.

Definition at line 30 of file MAX7219.hpp.

◆ pinMode() [1/2]

void MAX7219::pinMode ( UNUSED_PARAM pin_t  pin,
UNUSED_PARAM uint8_t  mode 
)
inlineoverride

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

Definition at line 36 of file MAX7219.hpp.

◆ digitalWrite()

void MAX7219::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 48 of file MAX7219.hpp.

◆ digitalRead()

int MAX7219::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 63 of file MAX7219.hpp.

◆ analogRead()

analog_t MAX7219::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 75 of file MAX7219.hpp.

◆ analogWrite()

void MAX7219::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 92 of file MAX7219.hpp.

◆ update()

void MAX7219::update ( )
inlineoverridevirtual

Write the buffer to the display.

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

Implements ExtendedIOElement.

Definition at line 102 of file MAX7219.hpp.

◆ init()

void MAX7219_Base::init ( )
inlineinherited

Initialize the Arduino pins, SPI, and the MAX7219.

Definition at line 36 of file MAX7219_Base.hpp.

◆ clear()

void MAX7219_Base::clear ( )
inlineinherited

Turn off all LEDs.

Definition at line 51 of file MAX7219_Base.hpp.

◆ send()

void MAX7219_Base::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 64 of file MAX7219_Base.hpp.

◆ sendRaw()

void MAX7219_Base::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 76 of file MAX7219_Base.hpp.

◆ setIntensity()

void MAX7219_Base::setIntensity ( uint8_t  intensity)
inlineinherited

Set the intensity of the LEDs.

Parameters
intensityThe intensity [0, 15].

Definition at line 91 of file MAX7219_Base.hpp.

◆ pins()

Array<pin_t, N> StaticSizeExtendedIOElement< N >::pins ( ) const
inlineinherited

Get an array containing all pins of the element.

Definition at line 24 of file StaticSizeExtendedIOElement.hpp.

◆ length()

static constexpr uint16_t StaticSizeExtendedIOElement< N >::length ( )
inlinestaticconstexprinherited

Definition at line 28 of file StaticSizeExtendedIOElement.hpp.

◆ pinMode() [2/2]

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

◆ beginAll()

void ExtendedIOElement::beginAll ( )
staticinherited

Initialize all extended IO elements.

Definition at line 21 of file ExtendedIOElement.cpp.

◆ 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

◆ buffer

BitArray<8 * 8> MAX7219::buffer
private

Definition at line 108 of file MAX7219.hpp.

◆ DECODEMODE

constexpr uint8_t MAX7219_Base::DECODEMODE = 9
staticconstexprinherited

Definition at line 27 of file MAX7219_Base.hpp.

◆ INTENSITY

constexpr uint8_t MAX7219_Base::INTENSITY = 10
staticconstexprinherited

Definition at line 28 of file MAX7219_Base.hpp.

◆ SCANLIMIT

constexpr uint8_t MAX7219_Base::SCANLIMIT = 11
staticconstexprinherited

Definition at line 29 of file MAX7219_Base.hpp.

◆ SHUTDOWN

constexpr uint8_t MAX7219_Base::SHUTDOWN = 12
staticconstexprinherited

Definition at line 30 of file MAX7219_Base.hpp.

◆ DISPLAYTEST

constexpr uint8_t MAX7219_Base::DISPLAYTEST = 15
staticconstexprinherited

Definition at line 31 of file MAX7219_Base.hpp.

◆ loadPin

pin_t MAX7219_Base::loadPin
privateinherited

Definition at line 96 of file MAX7219_Base.hpp.

◆ settings

SPISettings MAX7219_Base::settings = {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
privateinherited

Definition at line 97 of file MAX7219_Base.hpp.

◆ 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: