V 1.6.0 MQTT identifizierung mit 'Bad'

- Datumstexte auf deutsch
This commit is contained in:
rxf
2024-08-23 09:53:56 +02:00
parent c57572262f
commit 251c73b517
7 changed files with 47 additions and 35 deletions

View File

@@ -40,7 +40,7 @@ BME280Data bmedata;
int currentSecond = -1;
void showDateTime(struct tm tinfo);
void updateDateTime(struct tm tinfo);
void setBMEreadtime(int time) {
bmeReadTime = time * 1000;
@@ -50,13 +50,6 @@ void setUpdatetime(int time) {
updateTime = time * 1000;
}
char * getChipID(void) {
static char chipid[20];
uint64_t chipid64 = ESP.getEfuseMac();
sprintf(chipid, "%04X%08X", (uint16_t)(chipid64 >> 32), (uint32_t)chipid64);
return chipid;
}
void setup() {
setlocale(LC_ALL, "de_DE");
String LVGL_Arduino = String("LVGL Library Version: ") + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
@@ -87,8 +80,9 @@ void setup() {
// Start MQTT
setup_mqtt();
// Get the time
timeinfo = gettheTime(NTPREADTIME);
showDateTime(timeinfo);
updateDateTime(timeinfo);
bmeReadtimer = millis();
@@ -122,7 +116,7 @@ void setup() {
void loop() {
timeinfo = gettheTime(NTPREADTIME);
if (timeinfo.tm_sec == 0) { // minute over
showDateTime(timeinfo);
updateDateTime(timeinfo);
}
if (millis() - bmeReadtimer > bmeReadTime) {
bmeReadtimer = millis();
@@ -156,11 +150,14 @@ void loop() {
delay(5); // let this time pass
}
void showDateTime(struct tm tinfo) {
void updateDateTime(struct tm tinfo) {
char time[6];
char date[50];
static char date[50];
strftime(time, 6, "%H:%M", &tinfo);
strftime(date, 50, "%A, %d %B %Y", &tinfo);
lv_label_set_text(time_label, time);
lv_label_set_text(date_label, date);
}
int wd = tinfo.tm_wday;
int mo = tinfo.tm_mon;
int day = tinfo.tm_mday;
int year = tinfo.tm_year + 1900;
sprintf(date, "%s, %d. %s %d", wday[wd], day, month[mo], year);
setDateTime(time, date);
}