Fix clock update frequency

This commit is contained in:
Correl Roush 2023-01-22 12:02:28 -05:00
parent c0220110d6
commit 152144671d

View file

@ -62,7 +62,10 @@ public:
}
void loop() {
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);
if (t >= (last_t + 10)) {
last_t = t;
auto tm = localtime(&t);
M5.Display.setCursor(0, M5.Display.height() / 3);
M5.Display.setFont(&fonts::Orbitron_Light_24);
@ -77,7 +80,7 @@ public:
, tm->tm_hour
, tm->tm_min
);
delay(10000);
}
}
};
@ -91,7 +94,7 @@ void setup(void) {
M5.Display.init();
M5.Display.setTextSize(3);
M5.Display.setCursor(0, M5.Display.height() / 4);
M5.Display.printf("Starting up...");
M5.Display.println("Starting up...");
M5.Display.print("Connecting to WiFi");
WiFi.mode(WIFI_STA);