diff --git a/src/main.cpp b/src/main.cpp index a46dbcb..2926c1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,18 @@ void displayIcoPartial(const uint8_t bitmap[], uint16_t x, uint16_t y, uint16_t } +void getTime(char* ptr, size_t maxsize, const char* format) { + time_t now; + struct tm timeinfo; + time(&now); // update 'now' variable with current time + setenv("TZ", "CET-1CEST,M3.5.0/2,M10.5.0/3", 1); + tzset(); + localtime_r(&now, &timeinfo); + + strftime(ptr, maxsize, format, &timeinfo); +} + + void printValues() { #define SEALEVELPRESSURE_HPA (1013.25) Serial.print("Temperature = "); @@ -199,6 +211,13 @@ void loop() display.print("Luftdruck:"); display.print(bme.readPressure() / 100.0F); display.println(" hPa"); + + char timeStr[9]; + getTime(timeStr, sizeof(timeStr), "%H:%M:%S"); + display.setCursor(5, display.height()-5); + display.setFont(&Org_01); + display.print("Zeit: "); + display.println(timeStr); } while (display.nextPage()); display.powerOff();