#include <MD_Parola.h>
#include "RTClib.h"
#include "FONTDATA.h"
RTC_DS3231 RTC;
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
int i = 9;
int Animation;
String RandAn;
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
char daysOfTheWeek[7][12] = {"SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY"};
char monthOfTheYear[12][12] = {"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBAR", "OCTOBER", "NOVEMBER", "DECEMBER"};
struct sCatalog
{
textEffect_t effect;
const char * psz;
uint16_t speed;
uint16_t pause;
};
sCatalog catalog[] =
{
{ PA_PRINT, "", 80, 3000 },
{ PA_SCROLL_UP, "", 80, 3000 },
{ PA_SCROLL_DOWN, "", 80, 3000 },
{ PA_SCROLL_LEFT, "", 80, 3000 },
{ PA_SCROLL_RIGHT, "", 80, 3000 },
{ PA_SPRITE, "", 80, 3000 },
{ PA_SLICE, "", 0, 3000 },
{ PA_MESH, "", 150, 3000 },
{ PA_FADE, "", 250, 3000 },
{ PA_DISSOLVE, "", 500, 3000 },
{ PA_BLINDS, "", 120, 3000 },
{ PA_RANDOM, "", 50, 3000 },
{ PA_WIPE, "", 80, 3000 },
{ PA_WIPE_CURSOR, "", 80, 3000 },
{ PA_SCAN_HORIZ, "", 80, 3000 },
{ PA_SCAN_HORIZX, "", 80, 3000 },
{ PA_SCAN_VERT, "", 80, 3000 },
{ PA_SCAN_VERTX, "", 80, 3000 },
{ PA_OPENING, "", 80, 3000 },
{ PA_OPENING_CURSOR, "", 80, 3000 },
{ PA_CLOSING, "", 80, 3000 },
{ PA_CLOSING_CURSOR, "", 80, 3000 },
{ PA_SCROLL_UP_LEFT, "", 80, 3000 },
{ PA_SCROLL_UP_RIGHT, "", 80, 3000 },
{ PA_SCROLL_DOWN_LEFT, "", 80, 3000 },
{ PA_SCROLL_DOWN_RIGHT, "", 80, 3000 },
{ PA_GROW_UP, "", 80, 3000 },
{ PA_GROW_DOWN, "", 80, 3000 },
};
// Sprite Definitions
const uint8_t F_PMAN1 = 6;
const uint8_t W_PMAN1 = 8;
static const uint8_t PROGMEM pacman1[F_PMAN1 * W_PMAN1] = // gobbling pacman animation
{
0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c,
0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c,
0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c,
0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c,
0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c,
0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c,
};
const uint8_t F_PMAN2 = 6;
const uint8_t W_PMAN2 = 18;
static const uint8_t PROGMEM pacman2[F_PMAN2 * W_PMAN2] = // ghost pursued by a pacman
{
0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,
0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,
0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,
0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x73, 0xfb, 0x7f, 0xf3, 0x7b, 0xfe,
0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x73, 0xfb, 0x7f, 0xf3, 0x7b, 0xfe,
0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x73, 0xfb, 0x7f, 0xf3, 0x7b, 0xfe,
};
int k;
void setup()
{
P.begin();
P.setInvert(false);
P.setIntensity(0);
Wire.begin();
RTC.begin();
//Serial.begin(9600);
//Serial.println("hi");
//if (! RTC.isrunning())RTC.adjust(DateTime(__DATE__, __TIME__));
#if ENA_SPRITE
P.setSpriteData(pacman1, W_PMAN1, F_PMAN1, pacman2, W_PMAN2, F_PMAN2);
#endif
P.setFont(myfont);
}
const char *ZiuaCurenta = " ";
String Hour;
String TIMP = " ";
String ORA = " ";
String MINUT = " ";
String SECUNDA = " ";
String DATA = "";
String Day;
String Month;
String Year;
bool AM=0;
bool dot;
int ls;
void loop()
{
DateTime now = RTC.now();
String DayOfWeek = daysOfTheWeek[now.dayOfTheWeek()];
String MonthOfYear = monthOfTheYear[now.month() - 1];
const char *DayOfWeekC = DayOfWeek.c_str();
const char *MonthOfYearC = MonthOfYear.c_str();
int hr;
if(now.hour()==0)hr=12;
else if(now.hour()>12)hr=now.hour()-12;
else hr=now.hour();
if(now.hour()>=12)AM=0;
else AM=1;
bool alarm=Alarm(now.hour(),now.minute(),11,9,1);
ORA = (hr);
if (ORA.length() < 2)
{
ORA = "0" + ORA;
}
MINUT = (now.minute());
if (MINUT.length() < 2)
{
MINUT = "0" + MINUT;
}
TIMP=ORA+":"+ MINUT;
//const char *Timp = TIMP.c_str();
Day = now.day();
Month = now.month();
Year = now.year();
String Date = String(Day) + " " + MonthOfYearC + " " + String(Year) + " " + DayOfWeekC;
const char *Data = Date.c_str();
if(alarm){
String show=(AM==1)? TIMP+" AM" : TIMP+" PM";
P.displayText(show.c_str(), PA_CENTER, 50, 100, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!P.displayAnimate());
}
else{
if (i == 2)
{
P.displayText(Data, PA_CENTER, 30, 100, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!P.displayAnimate());
}
if (i == 1)
{
Animation ++;
if (Animation > 29)Animation = 0;
P.displayText(TIMP.c_str(), PA_CENTER, catalog[Animation].speed, 10000, catalog[Animation].effect, catalog[Animation].effect);
while (!P.displayAnimate());
}
i++;
if (i > 2)
{
i = 1;
};
}
}
bool Alarm(int rt,int rm,int at,int am,bool st){
if(rt==at && rm==am && st==1)return 1;
else return 0;
}