#include <SPI.h>
#include <TFT_eSPI.h>
#include "User_Setup.h"
TFT_eSPI tft = TFT_eSPI();
uint16_t colors[] = {TFT_RED, TFT_GREEN, TFT_BLUE};
uint8_t idx = 0;
unsigned long last = 0;
const unsigned long interval = 500; // ms
void setup(void) {
/* tft.init();
tft.setRotation(1);
Serial.begin(115200); // For debug 57600
tft.fillScreen(TFT_BLACK);*/
Serial.begin(115200);//tft.init();
tft.begin();
tft.setRotation(0);
Serial.printf("w=%d h=%d\n", tft.width(), tft.height());
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
int x1 = 16; int x2 = 92; int x3 = 168; int x4 = 244;
int y1 = 17; int y2 = 94; int y3 = 171; int y4 = 248; int y5 = 325; int y6 = 402;
int t = 5;
tft.fillRect(x1, y1, 60, 60, TFT_NAVY);
tft.fillRect(x2, y1, 60, 60, TFT_DARKGREEN);
tft.fillRect(x3, y1, 60, 60, TFT_DARKCYAN);
tft.fillRect(x4, y1, 60, 60, TFT_MAROON);
tft.fillRect(x1, y2, 60, 60, TFT_PURPLE);
tft.fillRect(x2, y2, 60, 60, TFT_OLIVE);
tft.fillRect(x3, y2, 60, 60, TFT_LIGHTGREY);
tft.fillRect(x4, y2, 60, 60, TFT_DARKGREY);
tft.fillRect(x1, y3, 60, 60, TFT_BLUE);
tft.fillRect(x2, y3, 60, 60, TFT_GREEN);
tft.fillRect(x3, y3, 60, 60, TFT_CYAN);
tft.fillRect(x4, y3, 60, 60, TFT_RED);
tft.fillRect(x1, y4, 60, 60, TFT_MAGENTA);
tft.fillRect(x2, y4, 60, 60, TFT_YELLOW);
tft.fillRect(x3, y4, 60, 60, TFT_WHITE);
tft.fillRect(x4, y4, 60, 60, TFT_ORANGE);
tft.fillRect(x1, y5, 60, 60, TFT_GREENYELLOW);
tft.fillRect(x2, y5, 60, 60, TFT_PINK);
tft.fillRect(x3, y5, 60, 60, TFT_BROWN);
tft.fillRect(x4, y5, 60, 60, TFT_GOLD);
tft.fillRect(x1, y6, 60, 60, TFT_SILVER);
tft.fillRect(x2, y6, 60, 60, TFT_SKYBLUE);
tft.fillRect(x3, y6, 60, 60, TFT_VIOLET);
tft.fillRect(x4, y6, 60, 60, TFT_LIME);
tft.drawString("NAVY", x1+t, y1+t);
tft.drawString("DARKGREEN", x2+t, y1+t);
tft.drawString("DARKCYAN", x3+t, y1+t);
tft.drawString("MAROON", x4+t, y1+t);
tft.drawString("PURPLE", x1+t, y2+t);
tft.drawString("OLIVE", x2+t, y2+t);
tft.drawString("LIGHTGREY", x3+t, y2+t);
tft.drawString("DARKGREY", x4+t, y2+t);
tft.drawString("BLUE", x1+t, y3+t);
tft.drawString("GREEN", x2+t, y3+t);
tft.drawString("CYAN", x3+t, y3+t);
tft.drawString("RED", x4+t, y3+t);
tft.drawString("MAGENTA", x1+t, y4+t);
tft.drawString("YELLOW", x2+t, y4+t);
tft.drawString("WHITE", x3+t, y4+t);
tft.drawString("ORANGE", x4+t, y4+t);
tft.drawString("GREENYELLOW", x1+t, y5+t);
tft.drawString("PINK", x2+t, y5+t);
tft.drawString("BROWN", x3+t, y5+t);
tft.drawString("GOLD", x4+t, y5+t);
tft.drawString("SILVER", x1+t, y6+t);
tft.drawString("SKYBLUE", x2+t, y6+t);
tft.drawString("VIOLET", x3+t, y6+t);
tft.drawString("LIME", x4+t, y6+t);
tft.drawFastHLine(0, tft.height() / 2, tft.width(), TFT_MAGENTA);
tft.drawFastVLine(tft.width() / 2, 0, tft.height(), TFT_MAGENTA);
/*
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextDatum(CC_DATUM);
tft.drawString("Hello, ILI9486", tft.width() / 2, tft.height() / 2, 4);*/
}
void loop() {
/*
unsigned long now = millis();
if (now - last >= interval) {
last = now;
tft.fillScreen(colors[idx]);
idx = (idx + 1) % (sizeof(colors) / sizeof(colors[0]));
}*/
}