#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_FT6206.h>
#include <math.h>
// TFT Display Pins
#define TFT_CS 10
#define TFT_RST 4
#define TFT_DC 9
#define TFT_MOSI 11
#define TFT_SCLK 13
#define TFT_MISO 12
// Create TFT and Touch objects
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
Adafruit_FT6206 ts = Adafruit_FT6206();
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(3);
if (!ts.begin()) {
Serial.println("Touchscreen not found!");
} else {
Serial.println("Touchscreen OK");
}
// Display animated text
drawAnimatedText();
// Loading Animation
drawSmoothLoadingAnimation();
}
void loop() {}
// Function to display "Thennal Air" and "Filters" letter-by-letter
void drawAnimatedText() {
tft.fillScreen(ILI9341_BLACK);
String line1 = "Thennal Air";
String line2 = "Filters";
int x1 = 80, y1 = 80;
int x2 = 110, y2 = 140;
int delayTime = 50;
uint16_t colors[] = { ILI9341_ORANGE, ILI9341_WHITE, ILI9341_GREEN };
// Print "Thennal Air"
for (int i = 0; i < line1.length(); i++) {
tft.setTextColor(colors[i % 3]);
tft.setTextSize(3);
tft.setCursor(x1, y1);
tft.print(line1[i]);
x1 += 18;
delay(delayTime);
}
delay(200);
// Print "Filters"
for (int i = 0; i < line2.length(); i++) {
tft.setTextColor(colors[i % 3]);
tft.setTextSize(3);
tft.setCursor(x2, y2);
tft.print(line2[i]);
x2 += 18;
delay(delayTime);
}
delay(1000);
}
// Function to draw a continuously rotating ring animation
void drawSmoothLoadingAnimation() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.setCursor(50, 100);
tft.print("Initializing Setup...");
int cx = 160, cy = 180, radius = 5;
int totalDots = 12;
int ringRadius = 30;
float prevX[12], prevY[12];
int frame = 0;
while (true) {
for (int i = 0; i < totalDots; i++) {
float angle = radians(frame + (i * 360 / totalDots));
int x = cx + cos(angle) * ringRadius;
int y = cy + sin(angle) * ringRadius;
int brightness = 255 - (i * 20);
uint16_t color = tft.color565(brightness, brightness, brightness);
if (frame > 0) {
tft.fillCircle(prevX[i], prevY[i], radius, ILI9341_BLACK);
}
tft.fillCircle(x, y, radius, color);
prevX[i] = x;
prevY[i] = y;
}
frame += 20;
if (frame >= 360) frame = 0;
delay(100);
}
}