WIP_20240708_1558

This commit is contained in:
rxf
2024-07-08 15:58:12 +02:00
parent fc498dcea1
commit b7080c359a
5 changed files with 121 additions and 28 deletions

View File

@@ -28,11 +28,17 @@
#include "grafik.h"
#include "main.h"
long repeatTime = 10000; // alle 1sec messen
long lastTime = 0;
#define BMWREADTIME 10000
#define NTPREADTIME 1000
long bmeReadtimer = 0;
long ntpReadtimer = 0;
BME280Data bmedata;
int currentSecond = -1;
void showDateTime(struct tm tinfo);
void setup() {
// String LVGL_Arduino = String("LVGL Library Version: ") + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();
@@ -61,9 +67,11 @@ void setup() {
connectToMqtt();
Serial.println("MQTT started");
lastTime = millis();
timeinfo = gettheTime(NTPREADTIME);
showDateTime(timeinfo);
bmeReadtimer = millis();
drawChart();
/*
@@ -92,14 +100,27 @@ void setup() {
}
void loop() {
if (millis() - lastTime > repeatTime) {
lastTime = millis();
timeinfo = gettheTime(NTPREADTIME);
if (timeinfo.tm_sec == 0) { // minute over
showDateTime(timeinfo);
printLocalTime();
}
if (millis() - bmeReadtimer > BMWREADTIME) {
bmeReadtimer = millis();
bmedata = readBME280();
setValuetoArc(arcTemp, bmedata.temp);
setValuetoArc(arcHum, bmedata.hum);
updatechartData(bmedata.hum, bmedata.temp);
}
}
lv_task_handler(); // let the GUI do its work
lv_tick_inc(5); // tell LVGL how much time has passed
delay(5); // let this time pass
}
void showDateTime(struct tm tinfo) {
char time[6];
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);
}