Controls multiple MAX7219/MAX7221 LED drivers via hardware SPI.
More...
#include <SBK_MAX72xxHard.h>
|
| | SBK_MAX72xxHard (uint8_t csPin, uint8_t devsNum=1) |
| | Construct a new hardware SPI SBK_MAX72xxHard driver instance.
|
| void | setSPIClock (uint32_t frequency) |
| | Set SPI clock speed (hardware SPI only).
|
| void | end () |
| | Set SPI clock speed (hardware SPI only).
|
| uint8_t | maxRows (uint8_t devIdx=0) const |
| | Returns the number of addressable row lines (anode outputs = SEGx).
|
| uint8_t | maxColumns () const |
| | Returns the number of addressable columns (cathode outputs = DIGx).
|
| uint8_t | maxSegments (uint8_t devIdx=0) const |
| | Returns the total number of addressable LED segments for this device.
|
|
void | begin () |
| | Initialize SPI pins and all MAX72xx chips.
|
| void | setShutdown (uint8_t devIdx, bool status) |
| | Enable or disable shutdown mode on a specific device.
|
| void | setScanLimit (uint8_t devIdx, uint8_t limit) |
| | Set the scan limit (number of active digits) for a specific device.
|
| void | setBrightness (uint8_t devIdx, uint8_t brightness) |
| | Set display brightness for a specific device.
|
| uint8_t | devsNum () const |
| | Return the number of actives driver devices.
|
| void | clear (uint8_t devIdx) |
| | Clear display buffer and hardware for one device.
|
|
void | clear () |
| | Clear display buffers and hardware for all devices.
|
| void | setLed (uint8_t devIdx, uint8_t rowIdx, uint8_t colIdx, bool state) |
| | Set the state of a specific LED in the device’s internal matrix buffer.
|
| bool | getLed (uint8_t devIdx, uint8_t rowIdx, uint8_t colIdx) const |
| | Get the state of a specific LED in the device’s internal matrix buffer.
|
| void | setCol (uint8_t devIdx, uint8_t colIdx, uint8_t value) |
| | Set the entire col value for a specific device (buffer only).
|
| void | show () |
| | Push the internal display buffer to all connected devices.
|
| void | show (uint8_t devIdx) |
| | Push the internal display buffer to a specific device.
|
Controls multiple MAX7219/MAX7221 LED drivers via hardware SPI.
◆ SBK_MAX72xxHard()
| SBK_MAX72xxHard::SBK_MAX72xxHard |
( |
uint8_t | csPin, |
|
|
uint8_t | devsNum = 1 ) |
Construct a new hardware SPI SBK_MAX72xxHard driver instance.
- Parameters
-
| csPin | Chip Select (CS) pin used for SPI communication. |
| devsNum | Number of daisy-chained MAX72xx devices. Default is 1. |
Initializes internal display buffer for each device in the chain. Each device reserves 8 bytes — one for each digit line (DIG0–DIG7), representing columns (cathode outputs).*
- Note
- Each byte in the buffer holds segment (SEG0–SEG7) values for one column.
◆ clear()
| void SBK_MAX72xxHard::clear |
( |
uint8_t | devIdx | ) |
|
Clear display buffer and hardware for one device.
- Parameters
-
| devIdx | Target device index. |
◆ devsNum()
| uint8_t SBK_MAX72xxHard::devsNum |
( |
| ) |
const |
|
inline |
Return the number of actives driver devices.
- Returns
- number of actives driver devices.
◆ end()
| void SBK_MAX72xxHard::end |
( |
| ) |
|
Set SPI clock speed (hardware SPI only).
- Parameters
-
| frequency | Frequency in Hz (e.g., 1000000 for 1 MHz). |
◆ getLed()
| bool SBK_MAX72xxHard::getLed |
( |
uint8_t | devIdx, |
|
|
uint8_t | rowIdx, |
|
|
uint8_t | colIdx ) const |
Get the state of a specific LED in the device’s internal matrix buffer.
This function reads the last known state of a given LED at the specified row and column on a target device. It does not access the physical display hardware, but instead reads from the internal RAM buffer used for batching updates.
- Note
- This function may not reflect real-time display contents unless show() has been called after setLed(). For animations or state-dependent logic, ensure consistency by calling show() regularly.
- Parameters
-
| devIdx | Index of the target device (0-based). |
| rowIdx | Row index (0–7). |
| colIdx | Column index (0–7). |
- Returns
- true if the LED is currently set ON in the buffer, false if OFF or invalid.
- Note
- The coordinate system follows a standard [row, col] layout. For MAX72xx drivers:
- row corresponds to SEGx (segment outputs, V+ source = anode)
- col corresponds to DIGx (digit selectors, GND sink = cathode)
◆ maxColumns()
| uint8_t SBK_MAX72xxHard::maxColumns |
( |
| ) |
const |
|
inline |
Returns the number of addressable columns (cathode outputs = DIGx).
This is a fixed value of 8 for MAX7219/7221, since each digit line (DIG0–DIG7) selects one column (cathode). Each DIGx line maps to one 8-bit buffer entry representing the vertical SEGx lines.
- Returns
- Number of columns (DIGx = cathode outputs), always 8.
◆ maxRows()
| uint8_t SBK_MAX72xxHard::maxRows |
( |
uint8_t | devIdx = 0 | ) |
const |
|
inline |
Returns the number of addressable row lines (anode outputs = SEGx).
- Parameters
-
| devIdx | Index of the target device (0-based in daisy chain). This parameter is ignored for MAX7219/7221 chips, but included for API compatibility with SBK_BarDrive. |
For MAX7219/7221 drivers, this value is always 8, since each column (DIGx) can display up to 8 vertical segments connected to SEG0–SEG7 (anode lines).
- Returns
- Number of row lines (SEGx/anodes), always 8 for MAX72xx devices.
◆ maxSegments()
| uint8_t SBK_MAX72xxHard::maxSegments |
( |
uint8_t | devIdx = 0 | ) |
const |
|
inline |
Returns the total number of addressable LED segments for this device.
- Parameters
-
| devIdx | Index of the target device (0-based in daisy chain). This parameter is ignored for MAX7219/7221 chips, but is included for API compatibility with SBK_BarDrive. |
This value is computed as: maxRows(devIdx) × maxColumns() For MAX7219/7221, this is always 8 × 8 = 64 segments per device.
- Returns
- Total number of addressable LED segments (pixels) for this device.
◆ setBrightness()
| void SBK_MAX72xxHard::setBrightness |
( |
uint8_t | devIdx, |
|
|
uint8_t | brightness ) |
Set display brightness for a specific device.
- Parameters
-
| devIdx | Target device index. |
| brightness | Value from 0 (min) to 15 (max). |
◆ setCol()
| void SBK_MAX72xxHard::setCol |
( |
uint8_t | devIdx, |
|
|
uint8_t | colIdx, |
|
|
uint8_t | value ) |
Set the entire col value for a specific device (buffer only).
- Parameters
-
| devIdx | Index of the target device. |
| colIdx | Column number (0 to 7). |
| value | 8-bit value for the row. |
◆ setLed()
| void SBK_MAX72xxHard::setLed |
( |
uint8_t | devIdx, |
|
|
uint8_t | rowIdx, |
|
|
uint8_t | colIdx, |
|
|
bool | state ) |
Set the state of a specific LED in the device’s internal matrix buffer.
- Parameters
-
| devIdx | Index of the target device (0-based in daisy chain). |
| rowIdx | Logical rowIdx index (0 to maxRows(_devIdx) - 1) — vertical position (anode). |
| colIdx | Logical column index (0 to maxColumns() - 1) — horizontal position (cathode). |
| state | true = LED ON, false = LED OFF. |
- Note
- The coordinate system follows a standard [row, col] layout. For MAX72xx drivers:
- row corresponds to SEGx (segment outputs, V+ source = anode)
- col corresponds to DIGx (digit selectors, GND sink = cathode)
This function updates the internal buffer; call show() to apply changes to hardware.
◆ setScanLimit()
| void SBK_MAX72xxHard::setScanLimit |
( |
uint8_t | devIdx, |
|
|
uint8_t | limit ) |
Set the scan limit (number of active digits) for a specific device.
- Parameters
-
| devIdx | Target device index. |
| limit | Value from 0 to 7. |
◆ setShutdown()
| void SBK_MAX72xxHard::setShutdown |
( |
uint8_t | devIdx, |
|
|
bool | status ) |
Enable or disable shutdown mode on a specific device.
- Parameters
-
| devIdx | Index of the target device. |
| status | false = shutdown, true = normal operation |
◆ setSPIClock()
| void SBK_MAX72xxHard::setSPIClock |
( |
uint32_t | frequency | ) |
|
Set SPI clock speed (hardware SPI only).
- Parameters
-
| frequency | Frequency in Hz (e.g., 1000000 for 1 MHz). |
◆ show() [1/2]
| void SBK_MAX72xxHard::show |
( |
| ) |
|
Push the internal display buffer to all connected devices.
This flushes all buffered LED states to the physical hardware for every device managed by this driver instance. Use this after making multiple setLed() calls to apply the changes to the display.
Typically used in split-device or multi-bar meter setups.
◆ show() [2/2]
| void SBK_MAX72xxHard::show |
( |
uint8_t | devIdx | ) |
|
Push the internal display buffer to a specific device.
- Parameters
-
| devIdx | Index of the target device (0-based in the daisy chain). |
Only the specified device's display will be updated. Useful for optimized partial updates when only one device has changed.
- Note
- The driver must track changes correctly for this to be meaningful.
The documentation for this class was generated from the following files: