/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <DS3231.h>
#define TFT_DC 9
#define TFT_CS 53//10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define merah tft.setTextColor(tft.color565(255,0,0))
#define hijau tft.setTextColor(tft.color565(0,255,0))
#define biru tft.setTextColor(tft.color565(0,0,255))
#define putih tft.setTextColor(tft.color565(255,255,255))
#define kuning tft.setTextColor(tft.color565(255,255,0))
#define cyan tft.setTextColor(tft.color565(0,255,255))
#define ungu tft.setTextColor(tft.color565(255,0,255))
#define emas tft.setTextColor(tft.color565(255,150,40))
#define plum tft.setTextColor(tft.color565(221, 160, 221))
#define ijonom tft.setTextColor(tft.color565(170, 236, 108))
#define ungunom tft.setTextColor(tft.color565(228, 167, 238))
#define kuningtuo tft.setTextColor(tft.color565(200, 166, 10))
#define ijotuo tft.setTextColor(tft.color565(10,180,10))
#define abuabu tft.setTextColor(tft.color565(176, 196, 222))
#define latarb tft.fillScreen(tft.color565(0,0,0))
#define cetak tft.print
#define pos tft.setCursor
uint8_t hh = 0, mm = 0, ss = 0, dd = 0, bb = 0, ddn = 0;
int yy = 0;
String Day = " ";
String Month = " ";
char hari[7][12] = { "AHAD", "SENIN", "SELASA", "RABU", "KAMIS", "JUM'AT", "SABTU" };
//analog clock
float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers
float sdeg = 0, mdeg = 0, hdeg = 0;
uint16_t osx = 120, osy = 120, omx = 120, omy = 120, ohx = 120, ohy = 120; // Saved H, M, S x & y coords
void setup() {
tft.begin();
tft.setRotation(3);
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can has colors?");
//Set LCD to Lanscape
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
}
void tengah(char *buf, int x, int y) // x center
{
int16_t x1, y1;
uint16_t w = 400, h = 240;
tft.getTextBounds(buf, x, y, &x1, &y1, &w, &h); //calc width of new string
pos(x - w / 2, y);
cetak(buf);
}