|
SBK_BarDrive Library 2.2.0
LED bar meter control and queued animations for Arduino
|
Unified interface combining SBK_BarMeter logic with optional built-in animation support. More...
#include <SBK_BarDrive.h>
Public Member Functions | |
| 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_BarDrive () | |
| SBK_BarMeter< DriverT > & | barmeter () |
| Get the underlying SBK_BarMeter instance. | |
| SBK_BarMeterAnimations< SBK_BarMeter< DriverT > > & | animations () |
| Get the animation controller instance (if enabled). | |
| 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. | |
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.
Definition at line 590 of file SBK_BarDrive.h.
|
inline |
Construct a SBK_BarDrive 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 606 of file SBK_BarDrive.h.
References FORWARD.
Referenced by setMatrixOffset(), and setSegmentOffset().
|
inline |
Construct a SBK_BarDrive 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 642 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Construct a SBK_BarDrive 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 677 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Construct a SBK_BarDrive 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 714 of file SBK_BarDrive.h.
References FORWARD.
|
inline |
Definition at line 732 of file SBK_BarDrive.h.
|
inline |
Get the animation controller instance (if enabled).
Definition at line 744 of file SBK_BarDrive.h.
|
inline |
Get the underlying SBK_BarMeter instance.
Definition at line 738 of file SBK_BarDrive.h.
|
inline |
Clear all bar segments.
Definition at line 761 of file SBK_BarDrive.h.
|
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 794 of file SBK_BarDrive.h.
|
inline |
Get the current bar fill direction.
Definition at line 773 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 820 of file SBK_BarDrive.h.
|
inline |
Get the total number of segments in the bar.
Definition at line 779 of file SBK_BarDrive.h.
|
inline |
Set the bar fill direction.
| dir | New direction (FORWARD or REVERSE). |
Definition at line 767 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 847 of file SBK_BarDrive.h.
References SBK_BarDrive(), and setMatrixOffset().
Referenced by setMatrixOffset().
|
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 806 of file SBK_BarDrive.h.
|
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 831 of file SBK_BarDrive.h.
References SBK_BarDrive(), and setSegmentOffset().
Referenced by setSegmentOffset().
|
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 756 of file SBK_BarDrive.h.