// /0978/NTPClock_ESP32_MAX7219/NTPClock_ESP32_MAX7219.ino ; update: 2024/01/22 14:31 // // This software uses several open software, // with each of different license declaration. // Please use this software with understanding of // each included software license // Script by kinoene.jp #include //For WiFi Network Connection #include //For MAX7219 Matrix LED #include //For MAX7219 SPI LED Driver #include //For SPI Communication #include //For Time Based Application #include "GF3x8p.h" // 3x8 font #include "GF5x8p.h" // 5x8 font //Wi-Fi #define SSID "ax50anotherZ" //Use your own WiFi SSID #define WIFIKEY "rock#tang@50Gpgw" //Ise your own WiFi Key #define JST 3600* 9 //MAX7219 #define MAX_DEVICES 4 // four modules //MD_MAX72XX #define CLK_PIN 27 //18 //13 #define DATA_PIN 12 //23 //11 #define CS_PIN 14 //5 //10 #define SPEED_TIME 25 //Small numbers are faster. Zero is the fastest. #define HARDWARE_TYPE MD_MAX72XX::FC16_HW static struct tm timeinfo; static char buf[30];//20 static char bufS[3], bufT[5]; // bufS = Sec, 'ss' + 1 = 3, bufT = HourMinute, 'hhmm" + 1 = 5 static const uint8_t intensity = MAX_INTENSITY/15;//Darkest //LEDの輝度を調整0-15、0=MAX static const char *wd[7] = {"Sun","Mon","Tue","Wed","Thr","Fri","Sat"}; static int wsec=-1; // Hardware SPI connection MD_Parola mx = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); void setup() { Serial.begin(115200);//115200 delay(100); Serial.println("53: Run setup"); //WiFi Connection Setting WiFi.begin(SSID, WIFIKEY); while ( WiFi.status() != WL_CONNECTED ) { Serial.print('.'); delay ( 500 ); } Serial.println(); Serial.printf("Connected, IP address: "); Serial.println(WiFi.localIP()); configTime( JST, 0, "ntp.nict.jp", "ntp.jst.mfeed.ad.jp"); // Matrix Display Setting mx.begin(2); // 2 zones mx.setZone(0, 1, 3); //00011111 <- Zone 0 for HM display mx.setZone(1, 0, 0); //11100000 <- Zone 1 for Sec display mx.setFont(0,GF5x8p); mx.setFont(1,GF3x8p); mx.setIntensity(intensity); //Darkest } void loop() { time_t epTime = time(NULL); ///timeClient.getEpochTime(); timeinfo = *localtime(&epTime); // if(wsec != timeinfo.tm_sec) { // wsec = timeinfo.tm_sec; // Serial.printf(" %04d/%02d/%02d(%s) %02d:%02d:%02d\n", // timeinfo.tm_year+1900, timeinfo.tm_mon+1, timeinfo.tm_mday, // wd[timeinfo.tm_wday], // timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); // } mx.displayAnimate(); //Zone 0 Time if (mx.getZoneStatus(0)) { strftime(bufT, sizeof(bufT), "%H%M", &timeinfo); // %T: hh:mm:ss // Serial.printf(" (%s) \n", bufT);//############################## mx.displayZoneText(0, bufT, PA_LEFT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT); mx.displayReset(0); } //Zone 1 Time if (mx.getZoneStatus(1)) { strftime(bufS, sizeof(bufS), "%S", &timeinfo); // %T: hh:mm:ss mx.displayZoneText(1, bufS, PA_RIGHT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT); mx.displayReset(1); } delay(50); //Don't remove this delay, and don't make it too small }