#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
// Couleurs
#define RED 0xF800
#define GREEN 0x07E0
#define WHITE 0xFFFF
// Coordonnées du centre
int cx = 120;
int cy = 120;
// Fonction pour dessiner l’étoile du Maroc ⭐
void drawStar(int x, int y, int r, uint16_t color) {
float angle = -90;
int xPoints[5], yPoints[5];
for (int i = 0; i < 5; i++) {
xPoints[i] = x + r * cos(angle * PI / 180);
yPoints[i] = y + r * sin(angle * PI / 180);
angle += 144;
}
for (int i = 0; i < 5; i++) {
tft.drawLine(xPoints[i], yPoints[i],
xPoints[(i + 2) % 5], yPoints[(i + 2) % 5],
color);
}
}
void setup() {
tft.init(240, 240);
tft.setRotation(0);
}
void loop() {
// Fond rouge (drapeau Maroc)
tft.fillScreen(RED);
// Animation étoile (taille progressive)
for (int r = 10; r <= 60; r += 5) {
drawStar(cx, cy, r, GREEN);
delay(120);
}
// Texte clignotant
for (int i = 0; i < 3; i++) {
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.setCursor(20, 30);
tft.print("CONGRATULATIONS");
delay(500);
tft.fillRect(20, 30, 200, 20, RED);
delay(300);
}
delay(2000);
}