|
| | SBK_BarDrive (DriverT *driver, uint8_t devIdx, MatrixPreset matrixPreset, BarDirection direction=BarDirection::FORWARD, uint8_t rowOffset=0, uint8_t colOffset=0) |
| | Construct a SBK_BarDrive using a predefined matrix-style layout.
|
| | SBK_BarDrive (DriverT *driver, uint8_t devIdx, uint8_t rowsNum, uint8_t colsNum, BarDirection direction=BarDirection::FORWARD, uint8_t rowOffset=0, uint8_t colOffset=0) |
| | Construct a SBK_BarDrive with a custom matrix size (rows × columns layout).
|
| | SBK_BarDrive (DriverT *driver, uint8_t devIdx, uint8_t segsNum, BarDirection direction=BarDirection::FORWARD, uint8_t segOffset=0) |
| | Construct a SBK_BarDrive with a fixed number of vertical segments (non-matrix layout).
|
| template<size_t N> |
| | SBK_BarDrive (DriverT *driver, uint8_t devIdx, const uint8_t(&mapping)[N][3], BarDirection direction=BarDirection::FORWARD, bool progmem=false, uint8_t rowOffset=0, uint8_t colOffset=0) |
| | Construct a SBK_BarDrive using a custom pixel mapping array.
|
| SBK_BarMeter< DriverT > & | barmeter () |
| | Get the underlying SBK_BarMeter instance.
|
| void | show () |
| | Push the current LED state buffer to the physical display.
|
|
void | clear () |
| | Clear all bar segments.
|
| void | setDirection (BarDirection dir) |
| | Set the bar fill direction.
|
| BarDirection | getDirection () |
| | Get the current bar fill direction.
|
| uint8_t | getSegsNum () |
| | Get the total number of segments in the bar.
|
| void | debugSegmentMapping (Stream &stream=Serial) |
| | Print the segment-to-device mapping for debugging purposes.
|
| void | setPixel (uint8_t segment, uint8_t state) |
| | Set the on/off state of a logical segment (LED).
|
| uint8_t | getPixelState (uint8_t segment) |
| | Get the current state of a bar segment (pixel).
|
| SBK_BarDrive & | setSegmentOffset (uint8_t offset) |
| | Apply a segment-wise offset (shifts segment index before mapping to row/col).
|
| SBK_BarDrive & | setMatrixOffset (uint8_t rowOffset, uint8_t colOffset) |
| | Apply a matrix-style physical offset for row/column positioning.
|
template<typename DriverT>
class SBK_BarDrive< DriverT >
Unified interface combining SBK_BarMeter logic with optional built-in animation support.
SBK_BarDrive provides a simplified, high-level interface for controlling LED bar meters, including segment fills, signal-driven displays, pulse effects, and block-based animations.
Internally wraps an instance of SBK_BarMeter and, if enabled, provides access to animation utilities via SBK_BarMeterAnimations.
- Note
- To enable animation features, define SBK_BARDRIVE_WITH_ANIM before including SBK_BarDrive.h. If not defined, animation methods like .animations() will be excluded to save memory.
template<typename DriverT>
Construct a SBK_BarDrive with a custom matrix size (rows × columns layout).
- Parameters
-
| driver | Pointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33). |
| devIdx | Index of the first device in the chain (0–7). |
| rowsNum | Number of matrix rows (anodes). May span multiple devices vertically. |
| colsNum | Number of matrix columns (cathodes). Limited to the column capacity of a single device. |
| direction | Optional bar fill direction (FORWARD or REVERSE). Default is FORWARD. |
| rowOffset | Optional row offset, if the matrix does not begin on the first driver row. Default is 0. |
| colOffset | Optional column offset, if the matrix does not begin on the first driver column. Default is 0. |
This constructor allows you to define a matrix-style bar layout with a custom size and origin, without using a predefined MatrixPreset.
⚠️ Note: Columns cannot be split across devices. Only rows may be extended vertically over multiple devices. Attempting to configure more columns than the driver hardware supports will result in clamping.
Useful for adapting custom matrix layouts or hardware not covered by presets.
template<typename DriverT>
Construct a SBK_BarDrive with a fixed number of vertical segments (non-matrix layout).
- Parameters
-
| driver | Pointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33). |
| devIdx | Index of the device in the chain (0–7). |
| segsNum | Number of logical segments (LEDs) in the bar meter. |
| direction | Optional bar fill direction (FORWARD or REVERSE). Default is FORWARD. |
| segOffset | Optional segment offset if the bar does not start at the first LED output. Default is 0. |
This constructor is intended for 1D segment-based bar displays, such as linear bars where each segment is addressed sequentially (not via a 2D matrix).
The segOffset allows you to skip physical outputs if the display is not connected to the first pin of the device. This is useful when sharing a device across multiple bar segments or skipping unused lines.
⚠️ If the specified device index exceeds the available device count, the bar meter is initialized as empty.
template<typename DriverT>
template<size_t N>
Construct a SBK_BarDrive using a custom pixel mapping array.
- Template Parameters
-
| N | Number of segments (inferred automatically from array size). |
- Parameters
-
| driver | Pointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33). |
| devIdx | Index of the first device in the chain (0–7). |
| mapping | Array of [device, row, col] tuples defining the physical LED position for each segment. |
| direction | Optional bar fill direction (FORWARD or REVERSE). Default is FORWARD. |
| progmem | Set to true if the mapping array is stored in PROGMEM (Flash memory). Default is false. |
| rowOffset | Optional offset to apply to all mapped row indices. Default is 0. |
| colOffset | Optional offset to apply to all mapped column indices. Default is 0. |
This constructor gives you full control over how each logical segment maps to a specific LED location on a matrix or linear display, across one or more devices. It is ideal for:
- Non-standard matrix layouts
- Discontinuous or irregular bar patterns
- Hybrid/multi-device configurations
⚠️ If the specified devIdx is invalid (beyond the available devices), the bar is initialized as empty.
template<typename DriverT>
| void SBK_BarDrive< DriverT >::debugSegmentMapping |
( |
Stream & | stream = Serial | ) |
|
|
inline |
Print the segment-to-device mapping for debugging purposes.
This function outputs the resolved mapping of each logical segment index to its corresponding [device, row, column] LED coordinates, based on the internal configuration (preset, custom map, or auto-mapped layout).
Useful for verifying how segments are translated into physical driver outputs, especially when using segment offsets, matrix presets, or split-device configurations.
- Parameters
-
| stream | Reference to a Stream object (e.g., Serial) for printing output. Defaults to Serial if not specified. |
template<typename DriverT>
| uint8_t SBK_BarDrive< DriverT >::getPixelState |
( |
uint8_t | segment | ) |
|
|
inline |
Get the current state of a bar segment (pixel).
This function returns the last known ON/OFF state of a segment. It queries the driver’s internal buffer (not the physical IC).
Direction and segment mapping are handled internally, so the returned value always corresponds to the logical segment number.
- Parameters
-
| segment | Index of the segment to query (0 to _segsNum - 1). |
- Returns
- 1 if the segment is ON, 0 if OFF, or 0 if invalid or driver unavailable.
template<typename DriverT>
| void SBK_BarDrive< DriverT >::setPixel |
( |
uint8_t | segment, |
|
|
uint8_t | state ) |
|
inline |
Set the on/off state of a logical segment (LED).
- Parameters
-
| segment | Index of the logical segment to control (0 to getSegNum() - 1). |
| state | true to turn the LED on, false to turn it off. |
This function resolves the segment index to its corresponding [device, row, col] location and updates the internal buffer of the underlying driver. The change will not be visible until show() is called.
template<typename DriverT>
Push the current LED state buffer to the physical display.
This flushes the internal buffer of the underlying driver to all connected devices — not just the one associated with this bar meter instance — making any recent changes (e.g., via setPixel() or clear()) visible on the actual hardware.
Internally calls _driver->show() to update the display.