SBK_BarDrive Library 2.1.2
LED bar meter control and queued animations for Arduino
Loading...
Searching...
No Matches
SBK_BarDrive< DriverT > Class Template Reference

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_BarDrivesetSegmentOffset (uint8_t offset)
 Apply a segment-wise offset (shifts segment index before mapping to row/col).
SBK_BarDrivesetMatrixOffset (uint8_t rowOffset, uint8_t colOffset)
 Apply a matrix-style physical offset for row/column positioning.

Detailed Description

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.

Definition at line 590 of file SBK_BarDrive.h.

Constructor & Destructor Documentation

◆ SBK_BarDrive() [1/4]

template<typename DriverT>
SBK_BarDrive< DriverT >::SBK_BarDrive ( DriverT * driver,
uint8_t devIdx,
MatrixPreset matrixPreset,
BarDirection direction = BarDirection::FORWARD,
uint8_t rowOffset = 0,
uint8_t colOffset = 0 )
inline

Construct a SBK_BarDrive using a predefined matrix-style layout.

Parameters
driverPointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33).
devIdxIndex of the first device in the chain (0–7).
matrixPresetPreset mapping type from the MatrixPreset enum.
directionBar fill direction (FORWARD or REVERSE). Default is FORWARD.
rowOffsetOptional row offset (if the matrix is not wired to the first row). Default is 0.
colOffsetOptional 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().

◆ SBK_BarDrive() [2/4]

template<typename DriverT>
SBK_BarDrive< DriverT >::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 )
inline

Construct a SBK_BarDrive with a custom matrix size (rows × columns layout).

Parameters
driverPointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33).
devIdxIndex of the first device in the chain (0–7).
rowsNumNumber of matrix rows (anodes). May span multiple devices vertically.
colsNumNumber of matrix columns (cathodes). Limited to the column capacity of a single device.
directionOptional bar fill direction (FORWARD or REVERSE). Default is FORWARD.
rowOffsetOptional row offset, if the matrix does not begin on the first driver row. Default is 0.
colOffsetOptional 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.

◆ SBK_BarDrive() [3/4]

template<typename DriverT>
SBK_BarDrive< DriverT >::SBK_BarDrive ( DriverT * driver,
uint8_t devIdx,
uint8_t segsNum,
BarDirection direction = BarDirection::FORWARD,
uint8_t segOffset = 0 )
inline

Construct a SBK_BarDrive with a fixed number of vertical segments (non-matrix layout).

Parameters
driverPointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33).
devIdxIndex of the device in the chain (0–7).
segsNumNumber of logical segments (LEDs) in the bar meter.
directionOptional bar fill direction (FORWARD or REVERSE). Default is FORWARD.
segOffsetOptional 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.

◆ SBK_BarDrive() [4/4]

template<typename DriverT>
template<size_t N>
SBK_BarDrive< DriverT >::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 )
inline

Construct a SBK_BarDrive using a custom pixel mapping array.

Template Parameters
NNumber of segments (inferred automatically from array size).
Parameters
driverPointer to the LED driver (e.g., SBK_MAX72xx or SBK_HT16K33).
devIdxIndex of the first device in the chain (0–7).
mappingArray of [device, row, col] tuples defining the physical LED position for each segment.
directionOptional bar fill direction (FORWARD or REVERSE). Default is FORWARD.
progmemSet to true if the mapping array is stored in PROGMEM (Flash memory). Default is false.
rowOffsetOptional offset to apply to all mapped row indices. Default is 0.
colOffsetOptional 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.

Definition at line 714 of file SBK_BarDrive.h.

References FORWARD.

◆ ~SBK_BarDrive()

template<typename DriverT>
SBK_BarDrive< DriverT >::~SBK_BarDrive ( )
inline

Definition at line 732 of file SBK_BarDrive.h.

Member Function Documentation

◆ animations()

template<typename DriverT>
SBK_BarMeterAnimations< SBK_BarMeter< DriverT > > & SBK_BarDrive< DriverT >::animations ( )
inline

Get the animation controller instance (if enabled).

Returns
Reference to SBK_BarMeterAnimations.

Definition at line 744 of file SBK_BarDrive.h.

◆ barmeter()

template<typename DriverT>
SBK_BarMeter< DriverT > & SBK_BarDrive< DriverT >::barmeter ( )
inline

Get the underlying SBK_BarMeter instance.

Returns
Reference to the SBK_BarMeter object.

Definition at line 738 of file SBK_BarDrive.h.

◆ clear()

template<typename DriverT>
void SBK_BarDrive< DriverT >::clear ( )
inline

Clear all bar segments.

Definition at line 761 of file SBK_BarDrive.h.

◆ debugSegmentMapping()

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
streamReference 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.

◆ getDirection()

template<typename DriverT>
BarDirection SBK_BarDrive< DriverT >::getDirection ( )
inline

Get the current bar fill direction.

Returns
BarDirection enum.

Definition at line 773 of file SBK_BarDrive.h.

◆ getPixelState()

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
segmentIndex 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.

Definition at line 820 of file SBK_BarDrive.h.

◆ getSegsNum()

template<typename DriverT>
uint8_t SBK_BarDrive< DriverT >::getSegsNum ( )
inline

Get the total number of segments in the bar.

Returns
Number of segments.

Definition at line 779 of file SBK_BarDrive.h.

◆ setDirection()

template<typename DriverT>
void SBK_BarDrive< DriverT >::setDirection ( BarDirection dir)
inline

Set the bar fill direction.

Parameters
dirNew direction (FORWARD or REVERSE).

Definition at line 767 of file SBK_BarDrive.h.

◆ setMatrixOffset()

template<typename DriverT>
SBK_BarDrive & SBK_BarDrive< DriverT >::setMatrixOffset ( uint8_t rowOffset,
uint8_t colOffset )
inline

Apply a matrix-style physical offset for row/column positioning.

Parameters
rowOffsetNumber of rows to shift downward.
colOffsetNumber of columns to shift rightward.
Returns
Reference to this instance.

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().

◆ setPixel()

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
segmentIndex of the logical segment to control (0 to getSegNum() - 1).
statetrue 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.

◆ setSegmentOffset()

template<typename DriverT>
SBK_BarDrive & SBK_BarDrive< DriverT >::setSegmentOffset ( uint8_t offset)
inline

Apply a segment-wise offset (shifts segment index before mapping to row/col).

Parameters
offsetNumber of segments to skip.
Returns
Reference to this instance.

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().

◆ show()

template<typename DriverT>
void SBK_BarDrive< DriverT >::show ( )
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.


The documentation for this class was generated from the following file: