/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "RTClib.h"
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
RTC_DS1307 rtc;
String thisTime = "";
String thisDay="";
void setup() {
tft.begin();
rtc.begin();
tft.setRotation (1) ;
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(4);
tft.println("Salve Brunão!");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("Tu é o CARA!!!");
delay(3000);
//tft.invertDisplay();
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
DateTime now = rtc.now();
thisTime="";
thisTime=String(now.hour()) + ":";
if (now.minute() < 10){ thisTime=thisTime + "0";} // add leading zero if required
thisTime=thisTime + String(now.minute()) + ":";
if (now.second() < 10){ thisTime=thisTime + "0";} // add leading zero if required
thisTime=thisTime + String(now.second());
const char* newTime = (const char*) thisTime.c_str();
tft.setCursor(20, 100);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.println(newTime);
//u8g.drawStr(31,20, newTime);
thisDay="";
if(now.day() < 10){thisDay=thisDay + "0";}
thisDay =thisDay + String(now.day()) + "/";
if(now.month() < 10){thisDay=thisDay + "0";}
thisDay =thisDay + String(now.month()) + "/";
if(now.year() < 10){thisDay=thisDay + "0";}
thisDay =thisDay + String(now.year());
const char* newDay = (const char*) thisDay.c_str();
tft.setCursor(20, 200);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(3);
tft.println(newDay);
tft.setCursor(0, 0);
tft.setTextColor(ILI9341_ORANGE);
tft.setTextSize(3);
tft.println(millis());
//u8g.drawStr(24,58, newDay);
}