Fix clock update frequency
This commit is contained in:
parent
c0220110d6
commit
152144671d
1 changed files with 19 additions and 16 deletions
35
src/main.cpp
35
src/main.cpp
|
@ -62,22 +62,25 @@ public:
|
||||||
}
|
}
|
||||||
void loop() {
|
void loop() {
|
||||||
static constexpr const char* const wd[7] = {"Sun","Mon","Tue","Wed","Thr","Fri","Sat"};
|
static constexpr const char* const wd[7] = {"Sun","Mon","Tue","Wed","Thr","Fri","Sat"};
|
||||||
|
static auto last_t = time(nullptr) - 10;
|
||||||
auto t = time(nullptr);
|
auto t = time(nullptr);
|
||||||
auto tm = localtime(&t);
|
if (t >= (last_t + 10)) {
|
||||||
M5.Display.setCursor(0, M5.Display.height() / 3);
|
last_t = t;
|
||||||
M5.Display.setFont(&fonts::Orbitron_Light_24);
|
auto tm = localtime(&t);
|
||||||
M5.Display.printf("%s\n%04d.%02d.%02d\n"
|
M5.Display.setCursor(0, M5.Display.height() / 3);
|
||||||
, wd[tm->tm_wday]
|
M5.Display.setFont(&fonts::Orbitron_Light_24);
|
||||||
, tm->tm_year + 1900
|
M5.Display.printf("%s\n%04d.%02d.%02d\n"
|
||||||
, tm->tm_mon + 1
|
, wd[tm->tm_wday]
|
||||||
, tm->tm_mday
|
, tm->tm_year + 1900
|
||||||
);
|
, tm->tm_mon + 1
|
||||||
M5.Display.setFont(&fonts::Orbitron_Light_32);
|
, tm->tm_mday
|
||||||
M5.Display.printf("%02d:%02d "
|
);
|
||||||
, tm->tm_hour
|
M5.Display.setFont(&fonts::Orbitron_Light_32);
|
||||||
, tm->tm_min
|
M5.Display.printf("%02d:%02d "
|
||||||
);
|
, tm->tm_hour
|
||||||
delay(10000);
|
, tm->tm_min
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ void setup(void) {
|
||||||
M5.Display.init();
|
M5.Display.init();
|
||||||
M5.Display.setTextSize(3);
|
M5.Display.setTextSize(3);
|
||||||
M5.Display.setCursor(0, M5.Display.height() / 4);
|
M5.Display.setCursor(0, M5.Display.height() / 4);
|
||||||
M5.Display.printf("Starting up...");
|
M5.Display.println("Starting up...");
|
||||||
|
|
||||||
M5.Display.print("Connecting to WiFi");
|
M5.Display.print("Connecting to WiFi");
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
Loading…
Reference in a new issue