// STM32 Blue Pill SPI LCD Example
// Simulation: https://wokwi.com/projects/374780854731040769
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC PB7
#define TFT_CS PB6
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
int x = 160;
int y = 120;
int vx = 3;
int vy = 2;
int rayon = 10;
int rayon_large = 11;
void setup() {
Serial.begin(115200);
Serial.println("Wokwi Blue Pill SPI Demo Starting...");
tft.begin();
tft.fillScreen(ILI9341_BLACK);
}
void loop() {
// Effacer l'ancien ballon
tft.fillCircle(x, y, rayon_large, ILI9341_BLACK);
// Déplacement
x += vx;
y += vy;
// Rebond gauche/droite
if (x <= rayon || x >= 320 - rayon) {
vx = -vx;
}
// Rebond haut/bas
if (y <= rayon || y >= 240 - rayon) {
vy = -vy;
}
// Dessiner le ballon
tft.fillCircle(x, y, rayon, ILI9341_RED);
tft.fillScreen(ILI9341_BLACK);
Serial.println (x + " : " + y);
}