/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "Clock.h"
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
unsigned long age_s;
int pn1, pn2, pn3, pn4;
enum DisplayState {
DisplayClock,
DisplaySetting,
};
void initTFT(){
tft.begin();
tft.setRotation(1);
age_s = 1152929300;
}
void dispForm(){
/// display title & RTC...
tft.setCursor(5, 20);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2.5);
tft.println("Life Time Clock");
tft.setCursor(200, 20);
tft.setTextColor(ILI9341_GREEN);
tft.println("16:18:43");
/// display name...
tft.setCursor(45, 50);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(3);
tft.println("Cris Anton");
tft.setCursor(50, 90);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("You survived for");
tft.setCursor(110, 160);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.println("seconds");
tft.drawRect(60, 188, 180, 37, ILI9341_YELLOW);
tft.fillRect(61, 189, 144, 35, ILI9341_GREEN);
///// draw heart & head bone
//heart
tft.fillCircle(12, 200, 12, ILI9341_RED);
tft.fillCircle(28, 200, 12, ILI9341_RED);
tft.fillTriangle(1,205,39,205,20,225,ILI9341_RED);
//head shape
tft.fillRect(268, 188, 24, 32, ILI9341_WHITE);
tft.fillRect(258, 195, 44, 13, ILI9341_WHITE);
tft.fillTriangle(268,188,258,195,268,195,ILI9341_WHITE);
tft.fillTriangle(292,188,292,195,302,195,ILI9341_WHITE);
tft.fillTriangle(258,208,268,208,268,219,ILI9341_WHITE);
tft.fillTriangle(302,208,292,208,292,219,ILI9341_WHITE);
//nose
tft.fillRect(278, 211, 4, 4, ILI9341_BLACK);
//eye
tft.fillRect(265, 202, 9, 5, ILI9341_BLACK);
tft.fillRect(286, 202, 9, 5, ILI9341_BLACK);
tft.fillTriangle(274, 202, 274, 206, 277,206,ILI9341_BLACK);
tft.fillTriangle(286, 202, 286, 206, 282,206,ILI9341_BLACK);
//tooth
tft.fillRect(270, 219, 20, 8, ILI9341_WHITE);
tft.fillRect(275, 221, 10, 6, ILI9341_BLACK);
tft.fillRect(278, 219, 4, 8, ILI9341_WHITE);
// tft.drawCircle(20, 30, 50, ILI9341_GREEN);
}
void displayLifeSec(){
tft.setCursor(2, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(4);
pn1 = age_s % 1000;
pn2 = age_s / 1000 % 1000;
pn3 = age_s / 1000000 % 1000;
pn4 = age_s / 1000000000 % 1000;
char s1[20], s2[20], s3[20], s4[20];
sprintf(s1, "%d", pn1);
sprintf(s2, "%d", pn2);
sprintf(s3, "%d", pn3);
sprintf(s4, "%d", pn4);
strcat(s4, ".");
strcat(s4, s3);
strcat(s4, ".");
strcat(s4, s2);
strcat(s4, ".");
strcat(s4, s1);
tft.println(s4);
}
void setup() {
initTFT();
dispForm();
displayLifeSec();
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
delay(1000);
age_s++;
displayLifeSec();
}