#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <ArduinoTrace.h>
// Define the number of devices we have in the chain and the hardware interface
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
//#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
// Global data
typedef struct
{
textEffect_t effect; // text effect to display
char * psz; // text string nul terminated
uint16_t speed; // speed multiplier
uint16_t pause; // pause multiplier
} sCatalog;
sCatalog catalog[] =
{
{ PA_PRINT, "PRINT", 1, 1 },
{ PA_SLICE, "SLICE", 1, 1 },
{ PA_MESH, "MESH", 20, 1 },
{ PA_FADE, "FADE", 20, 1 },
{ PA_WIPE, "WIPE", 5, 1 },
{ PA_WIPE_CURSOR, "WPE_C", 4, 1 },
{ PA_OPENING, "OPEN", 3, 1 },
{ PA_OPENING_CURSOR, "OPN_C", 4, 1 },
{ PA_CLOSING, "CLOSE", 3, 1 },
{ PA_CLOSING_CURSOR, "CLS_C", 4, 1 },
{ PA_RANDOM, "RAND", 3, 1 },
{ PA_BLINDS, "BLIND", 7, 1 },
{ PA_DISSOLVE, "DSLVE", 7, 1 },
{ PA_SCROLL_UP, "SC_U", 5, 1 },
{ PA_SCROLL_DOWN, "SC_D", 5, 1 },
{ PA_SCROLL_LEFT, "SC_L", 5, 1 },
{ PA_SCROLL_RIGHT, "SC_R", 5, 1 },
{ PA_SCROLL_UP_LEFT, "SC_UL", 7, 1 },
{ PA_SCROLL_UP_RIGHT, "SC_UR", 7, 1 },
{ PA_SCROLL_DOWN_LEFT, "SC_DL", 7, 1 },
{ PA_SCROLL_DOWN_RIGHT, "SC_DR", 7, 1 },
{ PA_SCAN_HORIZ, "SCNH", 4, 1 },
{ PA_SCAN_HORIZX, "SCNHX", 4, 1 },
{ PA_SCAN_VERT, "SCNV", 3, 1 },
{ PA_SCAN_VERTX, "SCNVX", 3, 1 },
{ PA_GROW_UP, "GRW_U", 7, 1 },
{ PA_GROW_DOWN, "GRW_D", 7, 1 },
};
void setup()
{
Serial.begin(57600);
for (uint8_t i=0; i<ARRAY_SIZE(catalog); i++)
{
catalog[i].speed *= 10;
catalog[i].pause *= 500;
}
P.begin();
}
void loop()
{
for (uint8_t j=0; j<3; j++)
{
textPosition_t just;
switch (j)
{
case 0: just = PA_LEFT; break;
case 1: just = PA_CENTER; break;
case 2: just = PA_RIGHT; break;
}
for (uint8_t i=0; i<ARRAY_SIZE(catalog); i++)
{
P.displayText(catalog[i].psz, just, catalog[i].speed, catalog[i].pause, catalog[i].effect, catalog[i].effect);
while (!P.displayAnimate()); // animates and returns true when an animation is completed
delay(catalog[i].pause);
}
}
}