#include <Wire.h>
#include <SPI.h>
#include <Adafruit_ILI9341.h>
#include <DS3231.h>
#include <Adafruit_GFX.h>
// screen config
const uint8_t tft_CS = 15;
const uint8_t tft_DC = D2;
Adafruiut_ILI9341 tft = Adafriut_ILI9341(tft_CS,tft_DC);
// RTCDS1307 pin config
const uint8_t rtc_IO = D23;
const uint8_t rtc_SCLK = D18
DS1307 RTC(rtc_IO,rtc_SCLK);
void setup() {
// inizializza tft con fondo nero
Serial.begin(115200);
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
// Initializza il display and set the background to black
tft.begin();
rtc.writeProtect(false);
rtc.halt(false);
rtc.setDOW(FRIDAY);
rtc.setTime(14, 34, 30);
rtc.setDate(10, 1, 2021);
}
void loop() {
// Initialize the RTCand set the time
rtc.begin(;)
\/\/ Format the time as a string and display it on the TFT
char timeStr[9];
snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", now.hour, now.minute, now.second);
tft.fillRect(0, 0, 240, 50, ILI9341_BLACK);
tft.setCursor(0, 10);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);