#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);
// Ekranın boyutları
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
void setup() {
tft.begin();
tft.fillScreen(ILI9341_BLACK); // Ekranı siyah renkle doldur
// Dinamik mesajlar ve animasyonlar
displayMessage("Merhaba!", ILI9341_WHITE, ILI9341_BLACK, 26, 120, 3);
delay(2000); // 2 saniye bekle
displayMessage("Ne yapabilirim?", ILI9341_GREEN, ILI9341_BLACK, 20, 160, 2);
delay(2000); // 2 saniye bekle
// Basit animasyonlar
animateRectangle();
animateLine();
colorTransition();
}
void loop() {
// Ekranı sürekli olarak güncellemek veya yeni animasyonlar eklemek için burayı kullanabilirsiniz
}
void displayMessage(String message, uint16_t textColor, uint16_t bgColor, int x, int y, int textSize) {
tft.fillScreen(bgColor); // Arka plan rengini ayarla
tft.setCursor(x, y);
tft.setTextColor(textColor);
tft.setTextSize(textSize);
tft.println(message);
}
void animateRectangle() {
int x = 0;
int y = 0;
int w = 30;
int h = 30;
int speedX = 2;
int speedY = 2;
for (int i = 0; i < 50; i++) {
tft.fillScreen(ILI9341_BLACK); // Ekranı temizle
tft.fillRect(x, y, w, h, ILI9341_RED); // Kırmızı bir kare çiz
x += speedX;
y += speedY;
// Kare ekranın kenarlarına çarptığında yön değiştirir
if (x > SCREEN_WIDTH - w || x < 0) {
speedX = -speedX;
}
if (y > SCREEN_HEIGHT - h || y < 0) {
speedY = -speedY;
}
delay(30); // Animasyon hızı
}
}
void animateLine() {
int x1 = 0;
int y1 = 0;
int x2 = SCREEN_WIDTH;
int y2 = SCREEN_HEIGHT;
int speed = 2;
for (int i = 0; i < 100; i++) {
tft.fillScreen(ILI9341_BLACK); // Ekranı temizle
tft.drawLine(x1, y1, x2, y2, ILI9341_BLUE); // Mavi bir çizgi çiz
x1 += speed;
y1 += speed;
x2 -= speed;
y2 -= speed;
if (x1 > SCREEN_WIDTH || y1 > SCREEN_HEIGHT || x2 < 0 || y2 < 0) {
x1 = 0;
y1 = 0;
x2 = SCREEN_WIDTH;
y2 = SCREEN_HEIGHT;
}
delay(50); // Animasyon hızı
}
}
void colorTransition() {
int r = 0;
int g = 0;
int b = 0;
for (int i = 0; i < 255; i++) {
tft.fillScreen(tft.color565(r, g, b));
r += 1;
g += 1;
b += 1;
delay(20); // Renk geçişi hızı
}
for (int i = 0; i < 255; i++) {
tft.fillScreen(tft.color565(r, g, b));
r -= 1;
g -= 1;
b -= 1;
delay(20); // Renk geçişi hızı
}
}