#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <ArduinoTrace.h>
#include "Font.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", 10, 1 },
// { PA_FADE, "FADE", 20, 1 },
// { PA_WIPE, "WIPE", 3, 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", 6, 1 },
// { PA_SCAN_HORIZX, "SCNHX", 6, 1 },
// { PA_SCAN_VERT, "SCNV", 6, 1 },
// { PA_SCAN_VERTX, "SCNVX", 6, 1 },
// { PA_GROW_UP, "GRW_U", 7, 1 },
// { PA_GROW_DOWN, "GRW_D", 7, 1 },
// };
sCatalog catalog[] =
{
{ PA_SCROLL_DOWN, "HOLA", 5, 1 },
{ PA_SCROLL_UP, "HOLA", 5, 1 },
{ PA_DISSOLVE, "@ @", 15, 1 },
{ PA_SCROLL_LEFT, "@ARQUITECTURA@", 4, 1 },
{ PA_SCROLL_RIGHT, "&", 4, 0 },
{ PA_BLINDS, "AC@", 7, 1 },
{ PA_RANDOM, "AC$$", 3, 1 },
{ PA_OPENING_CURSOR, "CLASE", 4, 1 },
{ PA_WIPE, "CLASE", 3, 1 },
{ PA_GROW_UP, "NOV 16", 5, 1 },
{ PA_GROW_DOWN, "NOV 16", 5, 1 },
{ PA_SCROLL_UP_LEFT, "NOV 16", 7, 1 },
{ PA_SCROLL_DOWN_LEFT, "NOV 16", 7, 1 },
};
uint16_t AnimationSpeed;
uint16_t BellAnimationSpeed;
uint8_t VBlankLine[] = {
1,0
};
uint8_t XTree[] = {
9,
B01000000,
B01100100,
B01110110,
B11111111,
B11111111,
B01110110,
B01100100,
B01000000,
B00000000,
};
uint8_t Sleigh[] = {
48,
B01111111,
B10111110,
B10111110,
B11111100,
B11111100,
B10111100,
B10111100,
B10111000,
B00111011,
B00111111,
B10111010,
B11111000,
B10111100,
B00111110,
B00100000,
B00100000,
B00100000,
B10010000,
B01010000,
B00111000,
B00110000,
B00111000,
B00111000,
B01001110,
B10011100,
B00011000,
B00100000,
B00100000,
B10010000,
B01010000,
B00111000,
B00110000,
B00111000,
B00111000,
B01001110,
B10011100,
B00011000,
B00100000,
B00100000,
B10010000,
B01010000,
B00111000,
B00110000,
B00111000,
B00111000,
B01001110,
B10011100,
B00011000
};
uint8_t Bell1[] = {
8,
B00011111,
B00011111,
B00001111,
B00001111,
B00000111,
B00000111,
B00000011,
B00000001,
};
uint8_t Bell2[] = {
10,
B00000011,
B00000111,
B00001111,
B00011111,
B00111111,
B01111111,
B11111111,
B00111111,
B00001111,
B00000011
};
uint8_t Bell3[] = {
10,
B11000000,
B11110000,
B11111100,
B11111110,
B11111111,
B11111111,
B11111110,
B11111100,
B11110000,
B11000000
};
uint8_t Bell4[] = {
10,
B00000011,
B00001111,
B00111111,
B11111111,
B01111111,
B00111111,
B00011111,
B00001111,
B00000111,
B00000011
};
uint8_t Bell5[] = {
8,
B00000001,
B00000011,
B00000111,
B00000111,
B00001111,
B00001111,
B00011111,
B00011111
};
const uint8_t Baubles[] = {
13,
B00001100,
B00011111,
B00001100,
B00000000,
B00000000,
B01110000,
B11111000,
B11111111,
B11111000,
B01110000,
B00000110,
B00001111,
B00000110
};
void setup()
{
Serial.begin(57600);
AnimationSpeed=200;
BellAnimationSpeed=200;
for (uint8_t i=0; i<ARRAY_SIZE(catalog); i++)
{
catalog[i].speed *= 10;
catalog[i].pause *= 500;
}
P.begin();
P.setFont(_sys_var_single);
P.addChar('&', Sleigh);
P.setInvert(false);
P.addChar('$', XTree);
P.addChar('|', VBlankLine);
// Bell Animations
P.addChar('6', Bell1);
P.addChar('7', Bell2);
P.addChar('8', Bell3);
P.addChar('9', Bell4);
P.addChar('0', Bell5);
P.addChar('@', Baubles);
// P.addChar('^', Baubles);
// P.addChar('$', Sleigh);
}
void loop()
{
AnimateBell();
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);
}
}
}
void AnimateBell()
{
for(int i=0;i<1;i++)
{
P.displayText("||||6",PA_LEFT,0,AnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("|||7",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("||||||8",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("||||||||||9",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("||||||||||0",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("||||||||||9",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("||||||8",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
P.displayText("|||7",PA_LEFT,0,BellAnimationSpeed,PA_PRINT,PA_NO_EFFECT);
while (!P.displayAnimate());
}
}