#include <Arduino.h>
#define SBK_BARDRIVE_WITH_ANIM
// Wokwi setup: MAX7219 via hardware SPI.
#define CS_PIN 10
#include <SBK_MAX72xxHard.h>
SBK_MAX72xxHard driver(CS_PIN, 2);
// 16 logical bar segments mapped as a linear strip across the visually first row
// on 2 chained Wokwi MAX7219 modules (row/col are transposed visually).
// Segment 0..7: device 0, row 0..7, col 0
// Segment 8..15: device 1, row 0..7, col 0
const uint8_t BARGRAPH_16SEG_MAP[16][3] = {
{0, 0, 0},
{0, 1, 0},
{0, 2, 0},
{0, 3, 0},
{0, 4, 0},
{0, 5, 0},
{0, 6, 0},
{0, 7, 0},
{1, 0, 0},
{1, 1, 0},
{1, 2, 0},
{1, 3, 0},
{1, 4, 0},
{1, 5, 0},
{1, 6, 0},
{1, 7, 0}
};
#include <SBK_BarDrive.h>
SBK_BarDrive<SBK_MAX72xxHard> bar(&driver, 0, BARGRAPH_16SEG_MAP);
void startAnimationQueue() {
// Queue 4 entries and loop them continuously.
bar.animations().stop()
.bounceFillUpIntv(50, 50).noLoop().enqueue()
.collidingBlocks(75, 4, 4, 0).enqueue().forTime(3000)
.enqueueReverseAnim().stopBlockEmissionAfter(3000)
.wait(1000).enqueue()
.loopQueue().startQueue();
}
void setup() {
Serial.begin(115200);
driver.begin();
driver.setBrightness(0, 10);
driver.setBrightness(1, 10);
bar.setDirection(BarDirection::FORWARD);
startAnimationQueue();
Serial.println(F("Queue demo started (16-segment mapped bargraph)."));
}
void loop() {
bar.animations().update();
bar.show();
}