Browse Source

display time

ir
Hendrik Langer 5 years ago
parent
commit
ee33513ab4
  1. 19
      src/main.cpp

19
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() { void printValues() {
#define SEALEVELPRESSURE_HPA (1013.25) #define SEALEVELPRESSURE_HPA (1013.25)
Serial.print("Temperature = "); Serial.print("Temperature = ");
@ -199,6 +211,13 @@ void loop()
display.print("Luftdruck:"); display.print("Luftdruck:");
display.print(bme.readPressure() / 100.0F); display.print(bme.readPressure() / 100.0F);
display.println(" hPa"); 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()); while (display.nextPage());
display.powerOff(); display.powerOff();

Loading…
Cancel
Save