/***********************************************************************
https://www.youtube.com/watch?v=Yidbmcn1H_w
Digital clock Max 7219 dot matrix Random animation & how to set the time in the RTC
https://pastebin.com/EkX8aJvc Relógio Digital - Max 7219 mostrador de matriz de pontos - RTC DS1307 módulo - sem sensor DHT11
https://www.youtube.com/watch?v=DP7cP9ISzsA
Digital clock - Max 7219 dot matrix display DS1307 RTC DHT11
https://pastebin.com/N7PaZNFk Relógio Digital - Max 7219 com animações aleatórias
***********************************************************************/
#include <MD_Parola.h>
#include "RTClib.h"
//#include <DHT.h>
//#define DHTPIN 2
//#define DHTTYPE DHT11
//DHT dht(DHTPIN, DHTTYPE);
RTC_DS1307 RTC;
DateTime now;
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW //EMULAÇÃO (HERE!)
//#define HARDWARE_TYPE MD_MAX72XX::FC16_HW //PROJETO (IN THE ARDUINO NANO)
#define MAX_DEVICES 4 // 4 ~ 8?
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
int i = 9;
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
char daysOfTheWeek[7][12] = {"Domingo", "Segunda", "Terca", "Quarta", "Quinta", "Sexta", "Sabado"};
char monthOfTheYear[12][12] = {"Janeiro", "Fevereiro", "Março", "Abril", "Mai", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"};
// 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,
};
void setup()
{
P.begin();
P.setInvert(false);
P.setIntensity(2); //intesidade do display
//dht.begin();
Wire.begin();
RTC.begin();
/***COMENTE AS LINHAS COMENTAR*** PARA ENVIAR A HORA DO PC AO ARDU***/
if (! RTC.isrunning()) // COMENTAR*******************
{ // COMENTAR*******************
//Serial.println("RTC is NOT running!"); //NÃO MEXER
RTC.adjust(DateTime(__DATE__, __TIME__)); //NÃO MEXER
} // COMENTAR*******************
/***DEPOIS DE ENVIADO DESCOMENTE E REENVIE PARA O RTC FUNCIONAR***/
#if ENA_SPRITE
P.setSpriteData(pacman1, W_PMAN1, F_PMAN1, pacman2, W_PMAN2, F_PMAN2);
#endif
}
const char *ZiuaCurenta = " "; //dia atual
String Hour;
String TIMP=" ";
String HORA=" ";
String MINUTO=" ";
String DATA="";
String Day;
String Month;
String Year;
String CelSTR;
void loop()
{
now = RTC.now();
/*float t = dht.readTemperature();
if (isnan(t))
{
return;
}
float q = (float)t/1.0;
CelSTR = String(q,1);
CelSTR = CelSTR + " C";
const char *CelC = CelSTR.c_str();
*/
String DayOfWeek = daysOfTheWeek[now.dayOfTheWeek()];
String MonthOfYear = monthOfTheYear[now.month() - 1];
const char *DayOfWeekC = DayOfWeek.c_str();
const char *MonthOfYearC = MonthOfYear.c_str();
HORA = (now.hour());
if (HORA.length() < 2)
{
HORA = "0"+ HORA;
}
MINUTO = (now.minute());
if (MINUTO.length() < 2)
{
MINUTO = "0"+ MINUTO;
}
TIMP = HORA + ":" + MINUTO;
const char *Timp = TIMP.c_str();
Day = now.day();
Month = now.month();
Year = now.year();
const char *Ziua = Day.c_str();
const char *Luna = Month.c_str();
const char *Anul = Year.c_str();
String Date = Day + "/" + Month + "/" + Year;
const char *Data = Date.c_str();
if (i = 1)
{
P.displayText(DayOfWeekC, PA_CENTER, 50, 500, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!P.displayAnimate()); // dia semana (txt)
}
if (i = 2)
{
P.displayText(Ziua, PA_CENTER, 30, 1000, PA_SCROLL_DOWN_RIGHT, PA_SCROLL_DOWN_RIGHT);
while (!P.displayAnimate()); // dia mês (num.)
}
if (i = 3)
{
P.displayText(MonthOfYearC, PA_CENTER, 100, 300, PA_MESH, PA_FADE);
while (!P.displayAnimate()); // Mês (txt)
}
if (i = 4)
{
P.displayText(Anul, PA_CENTER, 50, 1000, PA_BLINDS, PA_BLINDS);
while (!P.displayAnimate()); //ano
}
if (i = 6) /*************************************************/
{
P.displayText(Timp, PA_CENTER, 50, 9000, PA_SPRITE, PA_SPRITE);
while (!P.displayAnimate()); // hh:mm.ss
}
/*if (i = 7)
{
String Celsius = String(t) + "°C";
P.displayText(CelC, PA_CENTER, 100, 3000, PA_MESH, PA_MESH);
while (!P.displayAnimate()); // ºC
}
*/
i= i+1;
if (i > 9)
{
i=0;
};
}