#include <TFT_eSPI.h> // Hardware-specific library
#include <RTClib.h>
#include "NotoSansBold36.h" // Smooth Font
RTC_DS1307 rtc; // RTC Clock Object
TFT_eSPI tft = TFT_eSPI();
int xPos {0};
int yPos {0};
void setup(void) {
rtc.begin();
tft.begin();
tft.setRotation(3);
tft.fillScreen(TFT_BLUE);
tft.loadFont(NotoSansBold36); // tft Font
// Adding a parameter "true" to the setTextColor() function fills character background
// This extra parameter is only for smooth fonts! (tft Fonts)
tft.setTextColor(TFT_GREEN, TFT_BLUE, true);
tft.setTextPadding(tft.textWidth("55555")); // Textpadding zum löschen der "alten" Ausgabe
tft.setTextDatum(MC_DATUM); // Textausrichtung
xPos = tft.width() / 2; // x Position Textausgabe
yPos = tft.height() / 2; // y Position Textausgabe
}
void loop() {
static byte lastSecond {61};
DateTime now = rtc.now();
/*********** Blinki Blinki ;) *********/
byte second = now.second();
if (second != lastSecond) {
lastSecond = second;
char timeBuffer[7];
snprintf(timeBuffer, 6, "%02d%c%02d", now.hour(), (second & 1) ? ':' : ' ', now.minute());
tft.drawString(timeBuffer, xPos, yPos);
}
}