Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | List of all members
MAX7219SevenSegmentDisplay< SPIDriver > Class Template Reference

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

Detailed Description

template<class SPIDriver = decltype(SPI) &>
class AH::MAX7219SevenSegmentDisplay< SPIDriver >

A class for 8-digit 7-segment displays with a MAX7219 driver.

Template Parameters
SPIDriverThe SPI class to use. Usually, the default is fine.

Definition at line 51 of file MAX7219SevenSegmentDisplay.hpp.

+ Inheritance diagram for MAX7219SevenSegmentDisplay< SPIDriver >:
+ Collaboration diagram for MAX7219SevenSegmentDisplay< SPIDriver >:

Public Member Functions

 MAX7219SevenSegmentDisplay (SPIDriver spi, pin_t loadPin, uint8_t chainlength=1)
 Create a MAX7219SevenSegmentDisplay.
 
void begin ()
 Initialize.
 
void sendDigit (uint16_t digit, uint8_t value)
 Set the value of a single digit.
 
uint8_t getNumberOfDigits () const
 Get the total number of digits in this chain of displays, i.e.
 
int16_t display (long number, int16_t startDigit=0, int16_t endDigit=-1)
 Display a long integer to the display.
 
int16_t display (int number, int16_t startDigit=0, int16_t endDigit=-1)
 Display a long integer to the display.
 
int16_t display (unsigned long number, int16_t startDigit=0, int16_t endDigit=-1)
 Display a long unsigned integer to the display.
 
int16_t display (unsigned int number, int16_t startDigit=0, int16_t endDigit=-1)
 Display a long unsigned integer to the display.
 
int16_t display (const char *text, int16_t startPos=0)
 Display a string of text to the display.
 
void printHexChar (int16_t digit, uint8_t value)
 Print a single hexadecimal digit.
 
int16_t displayHex (unsigned long number, int16_t startDigit=0, int16_t endDigit=-1)
 Print a number to the display in hexadecimal format.
 
void clear ()
 Turn off all LEDs.
 
void send (uint8_t digit, uint8_t value, uint8_t chip=0)
 Send the value to the given digit or row.
 
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.
 
void sendAll (const uint8_t *values)
 Send different values to all digits/rows of all chips.
 
void sendRawAll (uint8_t opcode, uint8_t value)
 Send the same raw opcode and value to all chips in the chain.
 
void sendRaw (uint8_t opcode, uint8_t value, uint8_t chip=0)
 Send a raw opcode and value to the given MAX7219.
 
void setIntensity (uint8_t intensity)
 Set the intensity of the LEDs of all chips.
 
void setIntensity (uint8_t intensity, uint8_t chip)
 Set the intensity of the LEDs of a specific chip.
 
uint8_t getChainLength () const
 Get the number of daisy-chained chips.
 

Public Attributes

SPISettings settings {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
 

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

SPIDriver spi
 
pin_t loadPin
 
uint8_t chainlength
 

Constructor & Destructor Documentation

◆ MAX7219SevenSegmentDisplay()

template<class SPIDriver = decltype(SPI) &>
MAX7219SevenSegmentDisplay ( SPIDriver spi,
pin_t loadPin,
uint8_t chainlength = 1 )
inline

Create a MAX7219SevenSegmentDisplay.

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

Definition at line 63 of file MAX7219SevenSegmentDisplay.hpp.

Member Function Documentation

◆ begin()

template<class SPIDriver = decltype(SPI) &>
void begin ( )
inline

Initialize.

See also
MAX7219_Base::begin

Definition at line 70 of file MAX7219SevenSegmentDisplay.hpp.

◆ sendDigit()

template<class SPIDriver = decltype(SPI) &>
void sendDigit ( uint16_t digit,
uint8_t value )
inline

Set the value of a single digit.

Parameters
digitThe digit to set the value of. May be greater than 7 if more than one chip are daisy-chained.
Digit numbering starts from the right, the rightmost digit is digit zero.
valueThe value/bit pattern to set the digit to.

Definition at line 83 of file MAX7219SevenSegmentDisplay.hpp.

◆ getNumberOfDigits()

template<class SPIDriver = decltype(SPI) &>
uint8_t getNumberOfDigits ( ) const
inline

Get the total number of digits in this chain of displays, i.e.

eight times the number of chips.

Definition at line 91 of file MAX7219SevenSegmentDisplay.hpp.

◆ display() [1/5]

template<class SPIDriver = decltype(SPI) &>
int16_t display ( long number,
int16_t startDigit = 0,
int16_t endDigit = -1 )
inline

Display a long integer to the display.

The number will be right-aligned.

Parameters
numberThe number to display.
startDigitThe digit (zero-based, counting from the right) to start printing the number.
Digits: 7 6 5 4 3 2 1 0
endDigitThe last digit (zero-based, counting from the right) that can be printed. If the number is larger than endDigit - startDigit, a series of dashes is displayed. If the number is smaller than endDigit - startDigit, the leftmost digits including endDigit are cleared.
Returns
The number of digits that have been overwritten (endDigit - startDigit).

Definition at line 113 of file MAX7219SevenSegmentDisplay.hpp.

◆ display() [2/5]

template<class SPIDriver = decltype(SPI) &>
int16_t display ( int number,
int16_t startDigit = 0,
int16_t endDigit = -1 )
inline

Display a long integer to the display.

The number will be right-aligned.

Parameters
numberThe number to display.
startDigitThe digit (zero-based, counting from the right) to start printing the number.
Digits: 7 6 5 4 3 2 1 0
endDigitThe last digit (zero-based, counting from the right) that can be printed. If the number is larger than endDigit - startDigit, a series of dashes is displayed. If the number is smaller than endDigit - startDigit, the leftmost digits including endDigit are cleared.
Returns
The number of digits that have been overwritten (endDigit - startDigit).

Definition at line 140 of file MAX7219SevenSegmentDisplay.hpp.

◆ display() [3/5]

template<class SPIDriver = decltype(SPI) &>
int16_t display ( unsigned long number,
int16_t startDigit = 0,
int16_t endDigit = -1 )
inline

Display a long unsigned integer to the display.

The number will be right-aligned.

Parameters
numberThe number to display.
startDigitThe digit (zero-based, counting from the right) to start printing the number.
Digits: 7 6 5 4 3 2 1 0
endDigitThe last digit (zero-based, counting from the right) that can be printed. If the number is larger than endDigit - startDigit, a series of dashes is displayed. If the number is smaller than endDigit - startDigit, the leftmost digits including endDigit are cleared.
Returns
The number of digits that have been overwritten (endDigit - startDigit).

Definition at line 164 of file MAX7219SevenSegmentDisplay.hpp.

◆ display() [4/5]

template<class SPIDriver = decltype(SPI) &>
int16_t display ( unsigned int number,
int16_t startDigit = 0,
int16_t endDigit = -1 )
inline

Display a long unsigned integer to the display.

The number will be right-aligned.

Parameters
numberThe number to display.
startDigitThe digit (zero-based, counting from the right) to start printing the number.
Digits: 7 6 5 4 3 2 1 0
endDigitThe last digit (zero-based, counting from the right) that can be printed. If the number is larger than endDigit - startDigit, a series of dashes is displayed. If the number is smaller than endDigit - startDigit, the leftmost digits including endDigit are cleared.
Returns
The number of digits that have been overwritten (endDigit - startDigit).

Definition at line 187 of file MAX7219SevenSegmentDisplay.hpp.

◆ display() [5/5]

template<class SPIDriver = decltype(SPI) &>
int16_t display ( const char * text,
int16_t startPos = 0 )
inline

Display a string of text to the display.

Full stops are printed to the decimal point between characters.

Parameters
textThe null-terminated string to display.
startPosThe position to start printing.

Definition at line 202 of file MAX7219SevenSegmentDisplay.hpp.

◆ printHexChar()

template<class SPIDriver = decltype(SPI) &>
void printHexChar ( int16_t digit,
uint8_t value )
inline

Print a single hexadecimal digit.

Parameters
digitThe digit to print to [0, 7].
valueThe 4-bit value to print [0, 15].

Definition at line 239 of file MAX7219SevenSegmentDisplay.hpp.

◆ displayHex()

template<class SPIDriver = decltype(SPI) &>
int16_t displayHex ( unsigned long number,
int16_t startDigit = 0,
int16_t endDigit = -1 )
inline

Print a number to the display in hexadecimal format.

Parameters
numberThe number to display.
startDigitThe digit (zero-based, counting from the right) to start printing the number.
Digits: 7 6 5 4 3 2 1 0
endDigitThe last digit (zero-based, counting from the right) that can be printed. If the number is larger than endDigit - startDigit, a series of dashes is displayed. If the number is smaller than endDigit - startDigit, the leftmost digits including endDigit are cleared.
Returns
The number of digits that have been overwritten (endDigit - startDigit).

Definition at line 267 of file MAX7219SevenSegmentDisplay.hpp.

◆ clear()

template<class SPIDriver = decltype(SPI) &>
void clear ( )
inlineinherited

Turn off all LEDs.

Definition at line 62 of file MAX7219_Base.hpp.

◆ send()

template<class SPIDriver = decltype(SPI) &>
void send ( uint8_t digit,
uint8_t value,
uint8_t chip = 0 )
inlineinherited

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 77 of file MAX7219_Base.hpp.

◆ sendRowAll()

template<class SPIDriver = decltype(SPI) &>
void sendRowAll ( uint8_t digit,
const uint8_t * values,
uint8_t leading_dim = 1 )
inlineinherited

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 112 of file MAX7219_Base.hpp.

◆ sendAll()

template<class SPIDriver = decltype(SPI) &>
void sendAll ( const uint8_t * values)
inlineinherited

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 143 of file MAX7219_Base.hpp.

◆ sendRawAll()

template<class SPIDriver = decltype(SPI) &>
void sendRawAll ( uint8_t opcode,
uint8_t value )
inlineinherited

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 156 of file MAX7219_Base.hpp.

◆ sendRaw()

template<class SPIDriver = decltype(SPI) &>
void sendRaw ( uint8_t opcode,
uint8_t value,
uint8_t chip = 0 )
inlineinherited

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 177 of file MAX7219_Base.hpp.

◆ setIntensity() [1/2]

template<class SPIDriver = decltype(SPI) &>
void setIntensity ( uint8_t intensity)
inlineinherited

Set the intensity of the LEDs of all chips.

Parameters
intensityThe intensity [0, 15].

Definition at line 203 of file MAX7219_Base.hpp.

◆ setIntensity() [2/2]

template<class SPIDriver = decltype(SPI) &>
void setIntensity ( uint8_t intensity,
uint8_t chip )
inlineinherited

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 215 of file MAX7219_Base.hpp.

◆ getChainLength()

template<class SPIDriver = decltype(SPI) &>
uint8_t getChainLength ( ) const
inlineinherited

Get the number of daisy-chained chips.

Definition at line 222 of file MAX7219_Base.hpp.

Member Data Documentation

◆ DECODEMODE

template<class SPIDriver = decltype(SPI) &>
constexpr uint8_t DECODEMODE = 9
staticconstexprinherited

Definition at line 38 of file MAX7219_Base.hpp.

◆ INTENSITY

template<class SPIDriver = decltype(SPI) &>
constexpr uint8_t INTENSITY = 10
staticconstexprinherited

Definition at line 39 of file MAX7219_Base.hpp.

◆ SCANLIMIT

template<class SPIDriver = decltype(SPI) &>
constexpr uint8_t SCANLIMIT = 11
staticconstexprinherited

Definition at line 40 of file MAX7219_Base.hpp.

◆ SHUTDOWN

template<class SPIDriver = decltype(SPI) &>
constexpr uint8_t SHUTDOWN = 12
staticconstexprinherited

Definition at line 41 of file MAX7219_Base.hpp.

◆ DISPLAYTEST

template<class SPIDriver = decltype(SPI) &>
constexpr uint8_t DISPLAYTEST = 15
staticconstexprinherited

Definition at line 42 of file MAX7219_Base.hpp.

◆ spi

template<class SPIDriver = decltype(SPI) &>
SPIDriver spi
privateinherited

Definition at line 225 of file MAX7219_Base.hpp.

◆ loadPin

template<class SPIDriver = decltype(SPI) &>
pin_t loadPin
privateinherited

Definition at line 226 of file MAX7219_Base.hpp.

◆ chainlength

template<class SPIDriver = decltype(SPI) &>
uint8_t chainlength
privateinherited

Definition at line 227 of file MAX7219_Base.hpp.

◆ settings

template<class SPIDriver = decltype(SPI) &>
SPISettings settings {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0}
inherited

Definition at line 230 of file MAX7219_Base.hpp.


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