Same caveats as before.
//
// Display text on the matrix followed by the time and the cycle repeats.
//
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <Wire.h>
#include <Rtc_Pcf8563.h>
//init the real time clock
Rtc_Pcf8563 rtc;
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 6
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// set to 1 if we are implementing the user interface pot
#define USE_UI_CONTROL 0
#if USE_UI_CONTROL
#define SPEED_IN A0
#endif // USE_UI_CONTROL
#define PAUSE_TIME 1000
#define SPEED_DEADBAND 5
uint8_t frameDelay = 25; // default frame delay value
MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
#define SPEED_TIME 10
#define PAUSE_TIME 1000
// Global variables
uint8_t curText;
char szDateTime[20];
char *pc[] =
{
"This is",
"Just a",
"Test",
szDateTime,
};
uint8_t inFX, outFX;
MD_Parola::textEffect_t effect[] =
{
MD_Parola::PRINT,
MD_Parola::SCROLL_LEFT,
MD_Parola::WIPE,
MD_Parola::SCROLL_UP,
MD_Parola::OPENING_CURSOR,
MD_Parola::BLINDS,
MD_Parola::CLOSING,
MD_Parola::WIPE_CURSOR,
MD_Parola::DISSOLVE,
MD_Parola::OPENING,
MD_Parola::CLOSING_CURSOR,
MD_Parola::SCROLL_RIGHT,
MD_Parola::SCROLL_DOWN,
MD_Parola::SLICE,
};
void setup(void)
{
Serial.begin(57600);
//clear out the registers
//rtc.initClock();
//set a time to start with.
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
// uncomment to set
//rtc.setDate(30, 1, 12, 0, 13);
//hr, min, sec
//uncomment to set
//rtc.setTime(18, 42, 0);
P.begin();
P.setInvert(false);
P.displayText(pc[curText], MD_Parola::CENTER, SPEED_TIME, PAUSE_TIME, effect[inFX], effect[outFX]);
}
void loop(void)
{
if (P.displayAnimate()) // animates and returns true when an animation is completed
{
strcpy(szDateTime, rtc.formatTime());
// Set the display for the next string.
curText = (++curText) % ARRAY_SIZE(pc);
P.setTextBuffer(pc[curText]);
// When we have gone back to the first string, set a new exit effect
// and when we have done all those set a new entry effect.
if (curText == 0)
{
outFX = (++outFX) % ARRAY_SIZE(effect);
if (outFX == 0)
{
inFX = (++inFX) % ARRAY_SIZE(effect);
if (inFX == 0)
P.setInvert(!P.getInvert());
}
P.setTextEffect(effect[inFX], effect[outFX]);
}
// Tell Parola we have a new animation
P.displayReset();
}
}