#include <AH/Hardware/LEDs/MAX7219_Base.hpp>
A base class for classes that control MAX7219 LED drivers.
SPIDriver | The SPI class to use. Usually, the default is fine. |
Definition at line 22 of file MAX7219_Base.hpp.
Public Member Functions | |
MAX7219_Base (SPIDriver spi, pin_t loadPin, uint8_t chainlength=1) | |
Create a MAX7219_Base object. More... | |
void | begin () |
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... | |
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 |
|
inline |
Create a MAX7219_Base object.
spi | The SPI interface to use. |
loadPin | The pin connected to the load pin (C̄S̄) of the MAX7219. |
chainlength | The number of daisy-chained MAX7219 chips. |
Definition at line 34 of file MAX7219_Base.hpp.
|
inline |
Initialize the Arduino pins, SPI, and the MAX7219.
Definition at line 47 of file MAX7219_Base.hpp.
|
inline |
Turn off all LEDs.
Definition at line 62 of file MAX7219_Base.hpp.
|
inline |
Send the value to the given digit or row.
digit | The digit or row to set [0, 7]. |
value | The value to set the row to. |
chip | The chip to send the digit to. |
Definition at line 77 of file MAX7219_Base.hpp.
|
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 [ ] ...
digit | The digit or row to set [0, 7]. |
values | The array of values to send. |
leading_dim | The leading dimension of the array of values. |
Definition at line 112 of file MAX7219_Base.hpp.
|
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.
values | The array of values to send. |
Definition at line 143 of file MAX7219_Base.hpp.
|
inline |
Send the same raw opcode and value to all chips in the chain.
opcode | The opcode to send. |
value | The value to send. |
Definition at line 156 of file MAX7219_Base.hpp.
|
inline |
Send a raw opcode and value to the given MAX7219.
opcode | The opcode to send. |
value | The value to send. |
chip | The chip to send the command to. |
Definition at line 177 of file MAX7219_Base.hpp.
|
inline |
Set the intensity of the LEDs of all chips.
intensity | The intensity [0, 15]. |
Definition at line 203 of file MAX7219_Base.hpp.
|
inline |
Set the intensity of the LEDs of a specific chip.
intensity | The intensity [0, 15]. |
chip | The chip to set the intensity of. |
Definition at line 215 of file MAX7219_Base.hpp.
|
inline |
Get the number of daisy-chained chips.
Definition at line 222 of file MAX7219_Base.hpp.
|
staticconstexpr |
Definition at line 38 of file MAX7219_Base.hpp.
|
staticconstexpr |
Definition at line 39 of file MAX7219_Base.hpp.
|
staticconstexpr |
Definition at line 40 of file MAX7219_Base.hpp.
|
staticconstexpr |
Definition at line 41 of file MAX7219_Base.hpp.
|
staticconstexpr |
Definition at line 42 of file MAX7219_Base.hpp.
|
private |
Definition at line 225 of file MAX7219_Base.hpp.
|
private |
Definition at line 226 of file MAX7219_Base.hpp.
|
private |
Definition at line 227 of file MAX7219_Base.hpp.
SPISettings settings {SPI_MAX_SPEED, MSBFIRST, SPI_MODE0} |
Definition at line 230 of file MAX7219_Base.hpp.