Professional Documents
Culture Documents
// Great Projetcs
// https://www.youtube.com/watch?v=A_2pAaqc6n4
//
#include "Font_Data.h"
// 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 HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#include "DHT.h"
#define DHTPIN 23
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define SPEED_TIME 65
#define PAUSE_TIME 0
#define MAX_MESG 75
int timezone = 0;
int dst = 0;
const char *ssid = "********";
const char *password = "********";
char Message[MAX_MESG + 1] = { "Great Projects Wishes You A Nice Day!" };
char WeatherTh[MAX_MESG + 1] = "";
uint16_t h, m, s;
uint8_t dow;
int day;
uint8_t month;
String year;
// Global variables
char szTime[9]; // mm:ss\0
char szsecond[4]; // ss
char szMesg[MAX_MESG + 1] = "";
*psz = '\0';
mon--;
if (mon < 12) {
strncpy_P(psz, str[mon], len);
psz[len] = '\0';
}
return (psz);
}
*psz = '\0';
code--;
if (code < 7) {
strncpy_P(psz, str[code], len);
psz[len] = '\0';
}
return (psz);
}
void getsec(char *psz)
// Code for reading clock date
{
sprintf(psz, "%02d", s);
}
void getTime(char *psz, bool f = true)
// Code for reading clock time
{
time_t now = time(nullptr);
struct tm *p_tm = localtime(&now);
h = p_tm->tm_hour;
m = p_tm->tm_min;
s = p_tm->tm_sec;
sprintf(psz, "%02d%c%02d", h, (f ? ':' : ' '), m);
}
void setup(void) {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(3000);
getTimentp();
P.begin(3);
P.setInvert(false);
P.setZone(0, 0, 11);
P.setZone(1, 12, 12);
P.setZone(2, 13, 15);
P.setFont(1, numeric7Seg);
P.setFont(2, numeric7Se);
P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_PRINT, PA_SCROLL_LEFT);
P.displayZoneText(1, szsecond, PA_LEFT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(2, szTime, PA_CENTER, SPEED_TIME, PAUSE_TIME, PA_PRINT,
PA_NO_EFFECT);
P.addChar('$', degC);
dht.begin();
getDate(szMesg);
getTime(szTime);
}
void loop(void) {
static uint32_t lastTime = 0; // millis() memory
static uint8_t display = 0; // current display mode
static bool flasher = false; // seconds passing flasher
P.displayAnimate();
if (P.getZoneStatus(0)) {
switch (display) {
case 0: // Temperature deg C
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
dow2str(dow, szMesg, MAX_MESG);
break;
case 3: // Calendar
P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
display++;
getHumidit(szMesg);
break;
P.displayReset(0);
}
P.displayReset(1);
P.displayReset(2);
}
}
void getTimentp() {
while (!time(nullptr)) {
delay(500);
Serial.print(".");
}
Serial.print("Time Update");
}