Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
MAX7219_Base Class Reference

A base class for classes that control MAX7219 LED drivers. More...

#include <AH/Hardware/LEDs/MAX7219_Base.hpp>

+ Inheritance diagram for MAX7219_Base:
+ Collaboration diagram for MAX7219_Base:

Public Member Functions

 MAX7219_Base (pin_t loadPin, uint8_t chainlength=1)
 Create a MAX7219_Base object. 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, uint8_t chip=0)
 Send the value to the given digit or row. More...
 
void sendRowAll (uint8_t digit, const uint8_t *values, uint8_t leading_dim=1)
 Send values to the given digit or row, sending a different value for each chip. More...
 
void sendAll (const uint8_t *values)
 Send different values to all digits/rows of all chips. More...
 
void sendRawAll (uint8_t opcode, uint8_t value)
 Send the same raw opcode and value to all chips in the chain. More...
 
void sendRaw (uint8_t opcode, uint8_t value, uint8_t chip=0)
 Send a raw opcode and value to the given MAX7219. More...
 
void setIntensity (uint8_t intensity)
 Set the intensity of the LEDs of all chips. More...
 
void setIntensity (uint8_t intensity, uint8_t chip)
 Set the intensity of the LEDs of a specific chip. More...
 
uint8_t getChainLength () const
 Get the number of daisy-chained chips. 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
 

Private Attributes

pin_t loadPin
 
uint8_t chainlength
 
SPISettings settings = {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
 

Detailed Description

A base class for classes that control MAX7219 LED drivers.

The SPI interface is used.

Todo:
Wiring diagram for SPI connection.

Definition at line 23 of file MAX7219_Base.hpp.

Constructor & Destructor Documentation

◆ MAX7219_Base()

MAX7219_Base ( pin_t  loadPin,
uint8_t  chainlength = 1 
)
inline

Create a MAX7219_Base object.

Parameters
loadPinThe pin connected to the load pin (C̄S̄) of the MAX7219.
chainlengthThe number of daisy-chained MAX7219 chips.

Definition at line 33 of file MAX7219_Base.hpp.

Member Function Documentation

◆ init()

void init ( )
inline

Initialize the Arduino pins, SPI, and the MAX7219.

Todo:
Rename to begin.

Definition at line 46 of file MAX7219_Base.hpp.

◆ clear()

void clear ( )
inline

Turn off all LEDs.

Definition at line 61 of file MAX7219_Base.hpp.

◆ send()

void send ( uint8_t  digit,
uint8_t  value,
uint8_t  chip = 0 
)
inline

Send the value to the given digit or row.

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

Definition at line 76 of file MAX7219_Base.hpp.

◆ sendRowAll()

void sendRowAll ( uint8_t  digit,
const uint8_t *  values,
uint8_t  leading_dim = 1 
)
inline

Send values to the given digit or row, sending a different value for each chip.

The array is often a matrix containing the values for all rows of all chips in this chain. In that case, the leading dimension is 8, because each chip has 8 rows.

[0] chip 0, row 0  ┐
[1] chip 0, row 1  │
[ ] ...            │ 8 elements between two chips
[7] chip 0, row 7  │
[8] chip 1, row 0  ┘
[9] chip 1, row 1
[ ] ...

If you just want to specify a single row for all chips, the leading dimension of the array is 1.

[0] chip 0, row 0  ┐
[1] chip 1, row 0  ┘ 1 element between two chips
[2] chip 2, row 0
[ ] ...
Parameters
digitThe digit or row to set [0, 7].
valuesThe array of values to send.
leading_dimThe leading dimension of the array of values.

Definition at line 111 of file MAX7219_Base.hpp.

◆ sendAll()

void sendAll ( const uint8_t *  values)
inline

Send different values to all digits/rows of all chips.

The array layout should be as follows:

[0] chip 0, row 0  ┐
[1] chip 0, row 1  │
[ ] ...            │ 8 elements between two chips
[7] chip 0, row 7  │
[8] chip 1, row 0  ┘
[9] chip 1, row 1
[ ] ...

The array has 8 * chainlength elements in total.

Parameters
valuesThe array of values to send.

Definition at line 142 of file MAX7219_Base.hpp.

◆ sendRawAll()

void sendRawAll ( uint8_t  opcode,
uint8_t  value 
)
inline

Send the same raw opcode and value to all chips in the chain.

Parameters
opcodeThe opcode to send.
valueThe value to send.

Definition at line 155 of file MAX7219_Base.hpp.

◆ sendRaw()

void sendRaw ( uint8_t  opcode,
uint8_t  value,
uint8_t  chip = 0 
)
inline

Send a raw opcode and value to the given MAX7219.

Parameters
opcodeThe opcode to send.
valueThe value to send.
chipThe chip to send the command to.

Definition at line 176 of file MAX7219_Base.hpp.

◆ setIntensity() [1/2]

void setIntensity ( uint8_t  intensity)
inline

Set the intensity of the LEDs of all chips.

Parameters
intensityThe intensity [0, 15].

Definition at line 202 of file MAX7219_Base.hpp.

◆ setIntensity() [2/2]

void setIntensity ( uint8_t  intensity,
uint8_t  chip 
)
inline

Set the intensity of the LEDs of a specific chip.

Parameters
intensityThe intensity [0, 15].
chipThe chip to set the intensity of.

Definition at line 214 of file MAX7219_Base.hpp.

◆ getChainLength()

uint8_t getChainLength ( ) const
inline

Get the number of daisy-chained chips.

Definition at line 221 of file MAX7219_Base.hpp.

Member Data Documentation

◆ DECODEMODE

constexpr uint8_t DECODEMODE = 9
staticconstexpr

Definition at line 36 of file MAX7219_Base.hpp.

◆ INTENSITY

constexpr uint8_t INTENSITY = 10
staticconstexpr

Definition at line 37 of file MAX7219_Base.hpp.

◆ SCANLIMIT

constexpr uint8_t SCANLIMIT = 11
staticconstexpr

Definition at line 38 of file MAX7219_Base.hpp.

◆ SHUTDOWN

constexpr uint8_t SHUTDOWN = 12
staticconstexpr

Definition at line 39 of file MAX7219_Base.hpp.

◆ DISPLAYTEST

constexpr uint8_t DISPLAYTEST = 15
staticconstexpr

Definition at line 40 of file MAX7219_Base.hpp.

◆ loadPin

pin_t loadPin
private

Definition at line 226 of file MAX7219_Base.hpp.

◆ chainlength

uint8_t chainlength
private

Definition at line 227 of file MAX7219_Base.hpp.

◆ settings

SPISettings settings = {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
private

Definition at line 228 of file MAX7219_Base.hpp.


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