I'm trying to create a countdown timer using 2 8x32 matrices of the FC-16 Hardware type. I've successfully managed to get the countdown part working correctly, however, after the countdown completes, I want my custom font to appear on the matrices using the grow down animation text effect. The custom font appears but both zones grow synchronously creating a blinds kind of effect when all I really want is the custom font to grow down starting at the top of the upper zone and finishing at the bottom of the lower zone. Can anyone see why my code might be misleading me? The custom font function is "displayArrow()"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "Font_Data.h"
#define MAX_ZONES 2
#define ZONE_SIZE 4
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)
#define ZONE_UPPER 0
#define ZONE_LOWER 1
#define CLK_PIN D5
#define DATA_PIN D7
#define CS_PIN D2
// HARDWARE SPI
MD_Parola P = MD_Parola(MD_MAX72XX::FC16_HW, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(MD_MAX72XX::FC16_HW,DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
uint8_t secs = 0;
uint8_t mins = 1;
bool timerActive = true;
bool timerCompleted = false;
void ctdwnFunc() {
if (secs == 0) {
secs = 59;
if (mins != 0) {
--mins;
}
}
else {
--secs;
}
}
void displayTimer() {
char ctdnBuffer[8];
if (mins > 0 && secs >= 10) {
sprintf(ctdnBuffer, "%d:%d", mins, secs);
}
else if (mins > 0 && secs < 10) {
sprintf(ctdnBuffer, "%d:%02d", mins, secs);
}
else {
secs < 10 ? sprintf(ctdnBuffer, ":%02d", secs) : sprintf(ctdnBuffer, ":%d", secs);
}
P.displayZoneText(ZONE_LOWER, ctdnBuffer, PA_CENTER, 75, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(ZONE_UPPER, ctdnBuffer, PA_CENTER, 75, 0, PA_PRINT, PA_NO_EFFECT);
ctdnBuffer[0] = '\0';
}
void displayArrow() {
//P.displayZoneText(ZONE_UPPER, "^", PA_CENTER, 100, 0, PA_GROW_DOWN, PA_NO_EFFECT);
if (P.displayAnimate()) {
for (uint8_t i=0; i<MAX_ZONES; i++) {
if (P.getZoneStatus(i)) {
P.displayZoneText(i, "^", PA_CENTER, 100, 0, PA_GROW_DOWN, PA_NO_EFFECT);
}
}
}
}
void setup() {
// initialise the LED display
P.begin(MAX_ZONES);
P.setIntensity(2);
P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
P.setFont(ZONE_LOWER, BigFontLower);
P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES-1);
P.setFont(ZONE_UPPER, BigFontUpper);
P.setCharSpacing(P.getCharSpacing() * 1); // double height --> double spacing
}
void loop() {
static uint32_t ctdnTime = 0;
static uint32_t arrowTime = 0;
P.displayAnimate();
if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER) && timerActive) {
if (millis() - ctdnTime >= 1000) {
ctdnTime = millis();
displayTimer();
timerActive = (mins == 0 && secs == 0) ? false : true;
ctdwnFunc();
P.displayReset();
P.synchZoneStart();
}
}
if (timerActive == false) {
if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER)) {
if (millis() - arrowTime >= 2000) {
arrowTime = millis();
P.displayClear();
displayArrow();
P.displayReset();
//P.synchZoneStart();
}
}
}
}