A class for LED outputs using the MAX7219 LED display driver. More...
#include <AH/Hardware/ExtendedInputOutput/MAX7219.hpp>
Classes | |
struct | IndexMask |
Public Types | |
using | Mutex = typename std::conditional< false, DefaultMutEx, EmptyMutex >::type |
using | LockGuard = typename std::conditional< false, DefaultLockGuard< Mutex >, EmptyLockGuard< Mutex > >::type |
Public Member Functions | |
MAX7219 (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... | |
int | digitalRead (pin_t pin) override |
Get the current state of a given output. More... | |
int | 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 | 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... | |
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... | |
static Mutex & | getMutex () |
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 | |
ExtendedIOElement * | next |
ExtendedIOElement * | previous |
Static Protected Attributes | |
static DoublyLinkedList< ExtendedIOElement > | updatables |
static Mutex | mutex |
Static Private Member Functions | |
static IndexMask | pin2index (pin_t pin) |
Private Attributes | |
Array< uint8_t, 8 *NumChips > | buffer |
uint8_t | dirty_rows = 0xFF |
pin_t | loadPin |
uint8_t | chainlength |
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 |
Main initialization and updating methods | |
static void | applyToAll (const LockGuard &, void(Derived::*method)(Args &&...), Args &&... args) |
static void | applyToAll (void(Derived::*method)(Args &&...), Args &&... args) |
Enabling and disabling updatables | |
void | enable (const LockGuard &lock) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
void | enable () |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
void | disable (const LockGuard &lock) |
Disable this updatable: remove it from the linked list of instances, so it no longer 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 LockGuard &) const |
Check if this updatable is enabled. More... | |
bool | isEnabled () |
Check if this updatable is enabled. More... | |
void | moveDown (const LockGuard &) |
Move down this element in the list. 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... | |
A class for LED outputs using the MAX7219 LED display driver.
The SPI interface is used.
NumChips | The number of daisy-chained MAX7219 chips. |
Definition at line 25 of file MAX7219.hpp.
struct AH::MAX7219::IndexMask |
Definition at line 41 of file MAX7219.hpp.
Class Members | ||
---|---|---|
uint8_t | row | |
uint8_t | col | |
uint8_t | rowgrp | |
uint8_t | rowmask | |
uint8_t | colmask |
|
inherited |
Definition at line 36 of file Updatable.hpp.
|
inherited |
Definition at line 38 of file Updatable.hpp.
Create a MAX7219 ExtendedIOElement.
loadPin | The pin connected to the load pin (C̄S̄) of the MAX7219. |
Definition at line 34 of file MAX7219.hpp.
|
inlineoverridevirtual |
Initialize.
Implements ExtendedIOElement.
Definition at line 38 of file MAX7219.hpp.
Definition at line 49 of file MAX7219.hpp.
The pinMode function is not implemented because the mode is OUTPUT
by definition.
Reimplemented from ExtendedIOElement.
Definition at line 63 of file MAX7219.hpp.
The pinMode function is not implemented because the mode is OUTPUT
by definition.
Implements ExtendedIOElement.
Definition at line 72 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 87 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 100 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 117 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 125 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 140 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 147 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 165 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 173 of file MAX7219.hpp.
|
inline |
Definition at line 178 of file MAX7219.hpp.
|
inlineoverridevirtual |
Write the internal state to the physical outputs.
Implements ExtendedIOElement.
Definition at line 183 of file MAX7219.hpp.
|
inlineoverridevirtual |
Read the physical state into the input buffers.
Implements ExtendedIOElement.
Definition at line 195 of file MAX7219.hpp.
|
inlineinherited |
Initialize the Arduino pins, SPI, and the MAX7219.
begin
. Definition at line 46 of file MAX7219_Base.hpp.
|
inlineinherited |
Turn off all LEDs.
Definition at line 61 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 76 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 111 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 142 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 155 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 176 of file MAX7219_Base.hpp.
|
inlineinherited |
Set the intensity of the LEDs of all chips.
intensity | The intensity [0, 15]. |
Definition at line 202 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 214 of file MAX7219_Base.hpp.
|
inlineinherited |
Get the number of daisy-chained chips.
Definition at line 221 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.
|
inlinestaticinherited |
Definition at line 79 of file Updatable.hpp.
|
inlinestaticinherited |
Definition at line 85 of file Updatable.hpp.
|
inlinestaticinherited |
Definition at line 93 of file Updatable.hpp.
|
inlineinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 106 of file Updatable.hpp.
|
inlineinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 115 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 144 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 146 of file Updatable.hpp.
|
inlinestaticinherited |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 149 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 119 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 128 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 155 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 157 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 160 of file Updatable.hpp.
|
inlineinherited |
Check if this updatable is enabled.
Definition at line 136 of file Updatable.hpp.
|
inlineinherited |
Check if this updatable is enabled.
Definition at line 141 of file Updatable.hpp.
|
inlineinherited |
Move down this element in the list.
Definition at line 166 of file Updatable.hpp.
|
inlineinherited |
Move down this element in the list.
Definition at line 168 of file Updatable.hpp.
|
private |
Definition at line 198 of file MAX7219.hpp.
|
private |
Definition at line 199 of file MAX7219.hpp.
|
staticconstexprinherited |
Definition at line 36 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 37 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 38 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 39 of file MAX7219_Base.hpp.
|
staticconstexprinherited |
Definition at line 40 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 226 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 227 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 228 of file MAX7219_Base.hpp.
|
privateinherited |
Definition at line 260 of file ExtendedIOElement.hpp.
|
privateinherited |
Definition at line 261 of file ExtendedIOElement.hpp.
|
staticprivateinherited |
Definition at line 262 of file ExtendedIOElement.hpp.
|
staticprotectedinherited |
Definition at line 173 of file Updatable.hpp.
|
staticprotectedinherited |
Definition at line 174 of file Updatable.hpp.
|
protectedinherited |
Definition at line 323 of file LinkedList.hpp.
|
protectedinherited |
Definition at line 324 of file LinkedList.hpp.