|
SBK_BarDrive Library 2.1.2
LED bar meter control and queued animations for Arduino
|
Template class for controlling segment-based LED bar meters using row/column mappings. More...
#include <SBK_BarDrive.h>
Public Member Functions | |
| SBK_BarMeter (DriverT *driver, uint8_t devIdx, MatrixPreset matrixPreset=MatrixPreset::BL28_3005SK, BarDirection direction=BarDirection::FORWARD, uint8_t rowOffset=0, uint8_t colOffset=0) | |
| Construct a SBK_BarMeter using a predefined matrix-style layout. | |
| SBK_BarMeter (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_BarMeter with a custom matrix size (rows × columns layout). | |
| SBK_BarMeter (DriverT *driver, uint8_t devIdx, uint8_t segsNum, BarDirection direction=BarDirection::FORWARD, uint8_t segOffset=0) | |
| Construct a SBK_BarMeter with a fixed number of vertical segments (non-matrix layout). | |
| template<size_t N> | |
| SBK_BarMeter (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_BarMeter using a custom pixel mapping array. | |
| ~SBK_BarMeter () | |
| 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 () const |
| Get the current bar fill direction. | |
| uint8_t | getSegsNum () const |
| 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) const |
| Get the current state of a bar segment (pixel). | |
| SBK_BarMeter & | setSegmentOffset (uint8_t offset) |
| Apply a segment-wise offset (shifts segment index before mapping to row/col). | |
| SBK_BarMeter & | setMatrixOffset (uint8_t rowOffset, uint8_t colOffset) |
| Apply a matrix-style physical offset for row/column positioning. | |
Template class for controlling segment-based LED bar meters using row/column mappings.
This class provides flexible control over bar meter displays by mapping logical segments to physical LED positions defined by [device, row, col] coordinates. It supports:
Compatible with any driver that implements the SBK display driver API, including SBK_MAX72xx (hardware/software SPI) and SBK_HT16K33 (I2C).
Typically used via the higher-level SBK_BarDrive wrapper for simplified control and animation support.
Definition at line 125 of file SBK_BarDrive.h.
|
inline |
Construct a SBK_BarMeter using a predefined matrix-style layout.
| driver | Pointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33). |
| devIdx | Index of the first device in the chain (0–7). |
| matrixPreset | Preset mapping type from the MatrixPreset enum. |
| direction | Bar fill direction (FORWARD or REVERSE). Default is FORWARD. |
| rowOffset | Optional row offset (if the matrix is not wired to the first row). Default is 0. |
| colOffset | Optional column offset (if the matrix is not wired to the first column). Default is 0. |
This constructor simplifies setup by using a predefined segment-to-row/column mapping, useful for SBK matrix-type bar meters such as SK28 or SA28 models.
Definition at line 141 of file SBK_BarDrive.h.
References BL28_3005SK, and FORWARD.
Referenced by setMatrixOffset(), and setSegmentOffset().
|
inline |
Construct a SBK_BarMeter with a custom matrix size (rows × columns layout).
| 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.
Definition at line 189 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Construct a SBK_BarMeter with a fixed number of vertical segments (non-matrix layout).
| 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.
Definition at line 236 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Construct a SBK_BarMeter using a custom pixel mapping array.
| N | Number of segments (inferred automatically from array size). |
| 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:
⚠️ If the specified devIdx is invalid (beyond the available devices), the bar is initialized as empty.
Definition at line 283 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Definition at line 315 of file SBK_BarDrive.h.
|
inline |
|
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.
| stream | Reference to a Stream object (e.g., Serial) for printing output. Defaults to Serial if not specified. |
Definition at line 368 of file SBK_BarDrive.h.
|
inline |
Get the current bar fill direction.
Definition at line 347 of file SBK_BarDrive.h.
|
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.
| segment | Index of the segment to query (0 to _segsNum - 1). |
Definition at line 420 of file SBK_BarDrive.h.
|
inline |
Get the total number of segments in the bar.
Definition at line 353 of file SBK_BarDrive.h.
|
inline |
Set the bar fill direction.
| dir | New direction (FORWARD or REVERSE). |
Definition at line 341 of file SBK_BarDrive.h.
|
inline |
Apply a matrix-style physical offset for row/column positioning.
| rowOffset | Number of rows to shift downward. |
| colOffset | Number of columns to shift rightward. |
Those offsets are better used with matrix led display matrixPreset, like BL28 matrixPreset where the matrix is not connected to the firsts IC row/column.
Definition at line 457 of file SBK_BarDrive.h.
References SBK_BarMeter().
|
inline |
Set the on/off state of a logical segment (LED).
| 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.
Definition at line 397 of file SBK_BarDrive.h.
Referenced by clear().
|
inline |
Apply a segment-wise offset (shifts segment index before mapping to row/col).
| offset | Number of segments to skip. |
This offset is better used with a 1 to 1 ICs output to led display where the display do not start on the first IC output.
Definition at line 441 of file SBK_BarDrive.h.
References SBK_BarMeter().
|
inline |
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.
Definition at line 326 of file SBK_BarDrive.h.