#include <AH/Hardware/ExtendedInputOutput/MAX7219.hpp>
A class for LED outputs using the MAX7219 LED display driver.
The SPI interface is used.
NumChips | The number of daisy-chained MAX7219 chips. |
SPIDriver | The SPI class to use. Usually, the default is fine. |
Definition at line 27 of file MAX7219.hpp.
Enabling and disabling updatables | |
void | enable () |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
void | disable () |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
bool | isEnabled () const |
Check if this updatable is enabled. More... | |
void | moveDown () |
Move down this element in the list. More... | |
static void | enable (UpdatableCRTP *element) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
static void | enable (UpdatableCRTP &element) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
static void | enable (U(&array)[N]) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
static void | disable (UpdatableCRTP *element) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
static void | disable (UpdatableCRTP &element) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
static void | disable (U(&array)[N]) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
Classes | |
struct | IndexMask |
Public Member Functions | |
MAX7219 (SPIDriver spi, pin_t loadPin) | |
Create a MAX7219 ExtendedIOElement. More... | |
void | begin () override |
Initialize. More... | |
void | pinMode (pin_t pin, PinMode_t mode) override __attribute__((deprecated)) |
The pinMode function is not implemented because the mode is OUTPUT by definition. More... | |
void | pinModeBuffered (pin_t pin, PinMode_t mode) override __attribute__((deprecated)) |
The pinMode function is not implemented because the mode is OUTPUT by definition. More... | |
void | digitalWrite (pin_t pin, PinStatus_t val) override |
Set the state of a given output pin. More... | |
void | digitalWriteBuffered (pin_t pin, PinStatus_t val) override |
Set the state of a given pin in the software buffer. More... | |
PinStatus_t | digitalRead (pin_t pin) override |
Get the current state of a given output. More... | |
PinStatus_t | digitalReadBuffered (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... | |
analog_t | analogReadBuffered (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 | analogWriteBuffered (pin_t pin, analog_t val) override __attribute__((deprecated)) |
The analogWrite function is deprecated because a MAX7219 is always digital. More... | |
void | updateBufferedOutputRow (IndexMask i) |
void | updateBufferedOutputs () override |
Write the internal state to the physical outputs. More... | |
void | updateBufferedInputs () override |
Read the physical state into the input buffers. 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... | |
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 void | updateAllBufferedOutputs () |
Write the internal states to the physical outputs for all extended IO elements. More... | |
static void | updateAllBufferedInputs () |
Read the physical state into the input buffers for all extended IO elements. More... | |
static DoublyLinkedList< ExtendedIOElement > & | getAll () |
Get the list of all Extended IO elements. More... | |
Public Attributes | |
SPISettings | settings |
Static Public Attributes | |
static constexpr uint8_t | DECODEMODE |
static constexpr uint8_t | INTENSITY |
static constexpr uint8_t | SCANLIMIT |
static constexpr uint8_t | SHUTDOWN |
static constexpr uint8_t | DISPLAYTEST |
Protected Attributes | |
ExtendedIOElement * | next |
ExtendedIOElement * | previous |
Static Protected Attributes | |
static DoublyLinkedList< ExtendedIOElement > | updatables |
Static Private Member Functions | |
static IndexMask | pin2index (pin_t pin) |
Private Attributes | |
Array< uint8_t, 8 *NumChips > | buffer |
uint8_t | dirty_rows = 0xFF |
decltype(SPI) & | spi |
pin_t | loadPin |
uint8_t | chainlength |
const pin_t | start |
const pin_t | end |
Static Private Attributes | |
static pin_t | offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS |
Create a MAX7219 ExtendedIOElement.
spi | The SPI interface to use. |
loadPin | The pin connected to the load pin (C̄S̄) of the MAX7219. |
Definition at line 38 of file MAX7219.hpp.
|
inlineoverridevirtual |
Initialize.
Implements ExtendedIOElement.
Definition at line 44 of file MAX7219.hpp.
Definition at line 55 of file MAX7219.hpp.
The pinMode function is not implemented because the mode is OUTPUT
by definition.
Reimplemented from ExtendedIOElement.
Definition at line 69 of file MAX7219.hpp.
The pinMode function is not implemented because the mode is OUTPUT
by definition.
Implements ExtendedIOElement.
Definition at line 78 of file MAX7219.hpp.
|
inlineoverridevirtual |
Set the state of a given output pin.
pin | The output pin to set. |
val | The value to set the output to. (Either HIGH (1) or LOW (0)) |
Reimplemented from ExtendedIOElement.
Definition at line 93 of file MAX7219.hpp.
|
inlineoverridevirtual |
Set the state of a given pin in the software buffer.
The buffer is written to the MAX7219 when updateBufferedOutputs is called.
pin | The output pin to set. |
val | The value to set the output to. (Either HIGH (1) or LOW (0)) |
Implements ExtendedIOElement.
Definition at line 106 of file MAX7219.hpp.
|
inlineoverridevirtual |
Get the current state of a given output.
pin | The output to read the state from. |
0 | The state of the output is LOW . |
1 | The state of the output is HIGH . |
Reimplemented from ExtendedIOElement.
Definition at line 123 of file MAX7219.hpp.
|
inlineoverridevirtual |
Get the current state of a given output.
pin | The output to read the state from. |
0 | The state of the output is LOW . |
1 | The state of the output is HIGH . |
Implements ExtendedIOElement.
Definition at line 131 of file MAX7219.hpp.
The analogRead function is deprecated because a MAX7219 is always digital.
pin | The output to read the state from. |
0 | The state of the output is LOW . |
1023 | The state of the output is HIGH . |
Reimplemented from ExtendedIOElement.
Definition at line 146 of file MAX7219.hpp.
The analogRead function is deprecated because a MAX7219 is always digital.
pin | The output to read the state from. |
0 | The state of the output is LOW . |
1023 | The state of the output is HIGH . |
Implements ExtendedIOElement.
Definition at line 153 of file MAX7219.hpp.
The analogWrite function is deprecated because a MAX7219 is always digital.
pin | The output to set. |
val | The 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. |
Reimplemented from ExtendedIOElement.
Definition at line 171 of file MAX7219.hpp.
The analogWrite function is deprecated because a MAX7219 is always digital.
pin | The output to set. |
val | The 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. |
Implements ExtendedIOElement.
Definition at line 179 of file MAX7219.hpp.
|
inline |
Definition at line 184 of file MAX7219.hpp.
|
inlineoverridevirtual |
Write the internal state to the physical outputs.
Implements ExtendedIOElement.
Definition at line 189 of file MAX7219.hpp.
|
inlineoverridevirtual |
Read the physical state into the input buffers.
Implements ExtendedIOElement.
Definition at line 201 of file MAX7219.hpp.
|
inlineinherited |
Turn off all LEDs.
Definition at line 65 of file MAX7219_Base.hpp.
|
inlineinherited |
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 80 of file MAX7219_Base.hpp.
|
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 [ ] ...
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 115 of file MAX7219_Base.hpp.
|
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.
values | The array of values to send. |
Definition at line 146 of file MAX7219_Base.hpp.
|
inlineinherited |
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 159 of file MAX7219_Base.hpp.
|
inlineinherited |
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 180 of file MAX7219_Base.hpp.
|
inlineinherited |
Set the intensity of the LEDs of all chips.
intensity | The intensity [0, 15]. |
Definition at line 206 of file MAX7219_Base.hpp.
|
inlineinherited |
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 218 of file MAX7219_Base.hpp.
|
inlineinherited |
Get the number of daisy-chained chips.
Definition at line 225 of file MAX7219_Base.hpp.
Get an array containing all pins of the element.
Definition at line 27 of file StaticSizeExtendedIOElement.hpp.
|
inlinestaticconstexprinherited |
Definition at line 31 of file StaticSizeExtendedIOElement.hpp.
|
staticinherited |
Initialize all extended IO elements.
Definition at line 20 of file ExtendedIOElement.cpp.
|
staticinherited |
Write the internal states to the physical outputs for all extended IO elements.
Definition at line 24 of file ExtendedIOElement.cpp.
|
staticinherited |
Read the physical state into the input buffers for all extended IO elements.
Definition at line 28 of file ExtendedIOElement.cpp.
Get the extended IO pin number of a given physical pin of this extended IO element.
pin | The zero-based physical pin number of this IO element. |
Definition at line 32 of file ExtendedIOElement.cpp.
Get the extended IO pin number of a given physical pin of this extended IO element.
It is alias for ExtendedIOElement::pin
.
pin | The zero-based physical pin number of this IO element. |
Definition at line 47 of file ExtendedIOElement.cpp.
|
inherited |
Get the number of pins this IO element has.
Definition at line 49 of file ExtendedIOElement.cpp.
|
inherited |
Get the largest global extended IO pin number that belongs to this extended IO element.
Definition at line 51 of file ExtendedIOElement.cpp.
|
inherited |
Get the smallest global extended IO pin number that belongs to this extended IO element.
Definition at line 53 of file ExtendedIOElement.cpp.
|
staticinherited |
Get the list of all Extended IO elements.
Definition at line 55 of file ExtendedIOElement.cpp.
|
inlineinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 100 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 129 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 131 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 134 of file Updatable.hpp.
|
inlineinherited |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 110 of file Updatable.hpp.
|
inlinestaticinherited |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 140 of file Updatable.hpp.
|
inlinestaticinherited |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 142 of file Updatable.hpp.
|
inlinestaticinherited |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 145 of file Updatable.hpp.
|
inlineinherited |
Check if this updatable is enabled.
Definition at line 124 of file Updatable.hpp.
|
inlineinherited |
Move down this element in the list.
Definition at line 151 of file Updatable.hpp.
|
private |
Definition at line 204 of file MAX7219.hpp.
|
private |
Definition at line 205 of file MAX7219.hpp.
|
staticconstexprinherited |
Definition at line 41 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 42 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 43 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 44 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 45 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 228 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 229 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 230 of file MAX7219_Base.hpp.
|
inherited |
Definition at line 233 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 270 of file ExtendedIOElement.hpp.
|
privateinherited |
Definition at line 271 of file ExtendedIOElement.hpp.
|
staticprivateinherited |
Definition at line 272 of file ExtendedIOElement.hpp.
|
staticprotectedinherited |
Definition at line 156 of file Updatable.hpp.
|
protectedinherited |
Definition at line 324 of file LinkedList.hpp.
|
protectedinherited |
Definition at line 325 of file LinkedList.hpp.