// /0978/ESP32_MAX7219_clock_Single/ESP32_MAX7219_clock_Single.ino ; update: 2024/02/03 11:41 //ESP32 Dev Module // #include #include #include #include #include //For Time Based Application #include "GF4x8p.h" // 4x8 font #include "GF3x5p.h" // 3x5 font //#include "GF3x8p.h" // 3x8 font //Wi-Fi #define SSID "ax50anotherZ" #define WIFIKEY "rock#tang@50Gpgw" #define JST 3600 * 9 //tzOffset #define tzOffset JST //32400 = 3600 * 9 #define DSPZONE0 0 // #define DSPZONE1 1 // //MAX7219 #define MAX_DEVICES 4 // modules #define CLK_PIN 27 #define DATA_PIN 12 #define CS_PIN 14 #define SPEED_TIME 25 //Small numbers are faster. Zero is the fastest. #define SPEED_TIMESLOW 70 //Small numbers are faster. Zero is the fastest. #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define PAUSE_TIME_L 1200 //1200ms for month/day long pause #define PAUSE_TIME_S 300 //300ms for month/day short pause static struct tm timeinfo; static char buf[30]; //static char bufD[15], bufT[9]; // "yyyy mm/dd aaa" + 1 = 15, "hh:mm:ss" + 1 = 9 static const uint8_t intensity = MAX_INTENSITY/15;//Darkest //LEDの輝度を調整0-15、0=MAX static char bufS[3], bufT[7]; // bufS = Sec, 'ss' + 1 = 3, bufT = HourMinute, 'hhmm" + 1 = 5 static int wsec=-1; // Hardware SPI connection //MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES); MD_Parola mx = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); void setup() { Serial.begin(115200);//115200 delay(100); //WiFi Connection Setting WiFi.begin(SSID, WIFIKEY); while ( WiFi.status() != WL_CONNECTED ) { delay ( 1000 ); } configTime( tzOffset, 0, "ntp.nict.jp", "ntp.jst.mfeed.ad.jp"); Serial.println("73: Run setup"); // Matrix Display Setting mx.begin(2); // 2 zones mx.setZone(DSPZONE1, 1, 3); //00011111 <- Zone 1 for HM display mx.setZone(DSPZONE0, 0, 0); //11100000 <- Zone 0 for Sec display mx.setFont(DSPZONE1,GF4x8p);//GF5x8p); mx.setFont(DSPZONE0,GF3x5p);//GF3x8p);// mx.setIntensity(intensity); //Darkest } void loop() { time_t epTime = time(NULL); ///timeClient.getEpochTime(); timeinfo = *localtime(&epTime); mx.displayAnimate(); //Zone 1 Time if (mx.getZoneStatus(DSPZONE1)) { strftime(bufT, sizeof(bufT), "%H:%M:", &timeinfo); // %T: hh:mm:ss mx.displayZoneText(DSPZONE1, bufT, PA_RIGHT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT); mx.displayReset(DSPZONE1); } //Zone 0 Time if (mx.getZoneStatus(DSPZONE0)) { strftime(bufS, sizeof(bufS), "%S", &timeinfo); // %T: hh:mm:ss mx.displayZoneText(DSPZONE0, bufS, PA_RIGHT, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT); mx.displayReset(DSPZONE0); } delay(50); //Don't remove this delay, and don't make it too small }