#include <Arduino.h>
#define SBK_BARDRIVE_WITH_ANIM
// Wokwi setup: MAX7219 via hardware SPI, 2 chained devices (16x8 visual area)
#define CS_PIN 10
#include <SBK_MAX72xxHard.h>
SBK_MAX72xxHard driver(CS_PIN, 2);
// Visual note for Wokwi MAX7219 module:
// To draw a horizontal visual row, keep column fixed and increment row.
// Bar 1 on first visual row
const uint8_t BAR1_ROW1_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}
};
// Bar 2 on third visual row
const uint8_t BAR2_ROW3_MAP[16][3] = {
{0, 0, 2}, {0, 1, 2}, {0, 2, 2}, {0, 3, 2},
{0, 4, 2}, {0, 5, 2}, {0, 6, 2}, {0, 7, 2},
{1, 0, 2}, {1, 1, 2}, {1, 2, 2}, {1, 3, 2},
{1, 4, 2}, {1, 5, 2}, {1, 6, 2}, {1, 7, 2}
};
#include <SBK_BarDrive.h>
SBK_BarDrive<SBK_MAX72xxHard> bar1(&driver, 0, BAR1_ROW1_MAP);
SBK_BarDrive<SBK_MAX72xxHard> bar2(&driver, 0, BAR2_ROW3_MAP);
void setup() {
Serial.begin(115200);
driver.begin();
driver.setBrightness(0, 10);
driver.setBrightness(1, 10);
bar1.setDirection(BarDirection::FORWARD);
bar2.setDirection(BarDirection::FORWARD);
// Reuse split-driver intent: two independent bars on same driver chain.
bar1.animations().animInit().fillUpIntv(50).loop();
bar2.animations().animInit().fillDownIntv(50).loop();
Serial.println(F("Split-driver Wokwi demo started: row1 + row3 bar meters."));
}
void loop() {
bar1.animations().update();
bar2.animations().update();
// Push both bars in a single transfer pass.
driver.show();
}