add Moscow time in status bar

This commit is contained in:
UA1ZBE
2026-05-22 13:30:45 +03:00
parent ad5ce97152
commit bd65ad7438

View File

@@ -1,5 +1,6 @@
#include <WiFi.h>
#include <Wire.h>
#include <time.h>
#include <APRS-IS.h>
#include <APRS-Decoder.h>
#include <U8g2lib.h>
@@ -270,12 +271,17 @@ void drawSplash() {
u8g2.sendBuffer();
}
String getTimeStr() {
struct tm t;
if (!getLocalTime(&t)) return "--:--";
char buf[6];
snprintf(buf, sizeof(buf), "%02d:%02d", t.tm_hour, t.tm_min);
return String(buf);
}
void drawStatusBar() {
u8g2.setFont(u8g2_font_6x12_t_cyrillic);
String left = "APRS-IS";
if (!aprs.connected()) left += " ...";
u8g2.drawUTF8(2, 10, left.c_str());
u8g2.drawUTF8(2, 10, getTimeStr().c_str());
String right = String(totalPackets) + "pkt";
int rw = u8g2.getUTF8Width(right.c_str());
@@ -452,6 +458,7 @@ void setup() {
lastPacketTime = millis();
if (connectWiFi()) {
configTime(10800, 0, "pool.ntp.org", "time.nist.gov");
connectAPRS();
} else {
// will retry in loop()
@@ -474,6 +481,7 @@ void loop() {
if (WiFi.status() != WL_CONNECTED && millis() - lastWifiTry > 30000) {
lastWifiTry = millis();
connectWiFi();
configTime(10800, 0, "pool.ntp.org", "time.nist.gov");
}
}
{