diff --git a/sketch_mar26a/sketch_may14b/sketch_may14b.ino b/sketch_mar26a/sketch_may14b/sketch_may14b.ino new file mode 100644 index 0000000..1daa26e --- /dev/null +++ b/sketch_mar26a/sketch_may14b/sketch_may14b.ino @@ -0,0 +1,69 @@ + +#include "LIS3DHTR.h" +#include "TFT_eSPI.h" +#define RC 7 +#define RJ 5 +#define XMAX 320 +#define YMAX 240 +#define BANDEAU 40 + + + +TFT_eSPI tft; +int x=XMAX/2,y=(YMAX + BANDEAU)/2; +unsigned int modif=1; + +void setup() { + tft.begin(); + tft.setRotation(3); + + //FOND GRIS FONCE + tft.fillScreen(TFT_DARKGREY); + + //BANDEAU BLUE ET 40 PIXEL + tft.fillRect(0,0,XMAX,BANDEAU,TFT_BLUE); + + //Niveau + tft.setTextColor(TFT_WHITE); + tft.setTextSize(2.5); + tft.drawString("confirme", 15, 10); + //SCORE + tft.setTextSize(2.5); + tft.drawString(" pts", 120, 10); + + //CHRONO + tft.setTextSize(2.5); + tft.drawString("chrono ", 230, 10); + +} + +void loop() { + //PREMIER ROUND + tft.fillCircle(x,y,RC,TFT_RED); + tft.fillCircle(250, 90, RJ, TFT_YELLOW); + tft.fillCircle(90, 200, RJ, TFT_YELLOW); + tft.fillCircle(100, 80, RJ, TFT_YELLOW); + tft.fillCircle(190, 200, RJ, TFT_YELLOW); + tft.fillCircle(40, 100, RJ, TFT_YELLOW); + + //DEUXIEM ROUND + tft.fillCircle(x,y,RC,TFT_RED); + tft.fillCircle(185, 50, RJ , TFT_YELLOW); + tft.fillCircle(310, 230, RJ , TFT_YELLOW); + tft.fillCircle(10, 130, RJ , TFT_YELLOW); + tft.fillCircle(250, 115, RJ , TFT_YELLOW); + tft.fillCircle(130, 200, RJ , TFT_YELLOW); + + //TROISIEME ROUND + tft.fillCircle(185, 50, RJ , TFT_YELLOW); + tft.fillCircle(310, 230, RJ , TFT_YELLOW); + tft.fillCircle(10, 130, RJ , TFT_YELLOW); + tft.fillCircle(250, 115, RJ , TFT_YELLOW); + tft.fillCircle(130, 200, RJ , TFT_YELLOW); + + tft.fillCircle(200, 50, RJ , TFT_BLACK); + tft.fillCircle(300, 200, RJ , TFT_BLACK); + tft.fillCircle(130, 215,RJ , TFT_BLACK); + tft.fillCircle(240, 105, RJ , TFT_BLACK); + tft.fillCircle(10, 100, RJ , TFT_BLACK); +} diff --git a/sketch_mar26a/wino.ino b/sketch_mar26a/wino.ino index 4aa8519..73f1948 100644 --- a/sketch_mar26a/wino.ino +++ b/sketch_mar26a/wino.ino @@ -4,10 +4,13 @@ LIS3DHTR lis; #define R 5 //Rayon de la boule donc diamètre 10 #define XMAX 240 // Définit la taille en longueur de l'écran #define YMAX 320 // Définit la taille en largeur de l'écran +#define BUZZER_PIN WIO_BUZZER TFT_eSPI tft; unsigned int modif=1 ; //si déplacement, on affiche. 1 pour premier affichage int x=XMAX/2, y=YMAX/2; +unsigned long tempsDepart = 0; +bool enCours = false; void setup() { Serial.begin(115200); @@ -26,9 +29,70 @@ void setup() { pinMode(WIO_KEY_A, INPUT_PULLUP); pinMode(WIO_KEY_B, INPUT_PULLUP); pinMode(WIO_KEY_C, INPUT_PULLUP); + + pinMode(WIO_BUZZER, OUTPUT); + +} + +void chrono(int temps) { + int i; + for(i = temps; i>=0; i--) { + Serial.print(i);Serial.print(" secondes."); + delay(1000); + } +} + +void perdu() { + tft.fillScreen(TFT_RED); // fond rouge } void loop() { + + bool demarrer = false; + int temps = 30; + int temps2; + + while (!demarrer) { + if (digitalRead(WIO_KEY_A) == LOW) { + Serial.print("Rajoutter 10 secondes"); + Serial.println(); + } + else if (digitalRead(WIO_KEY_B) == LOW) { + Serial.print("Lancer la partie sur le niveau choisit"); + Serial.println(); + + demarrer = true; + } + else if (digitalRead(WIO_KEY_C) == LOW) { + Serial.print("Choisir le niveau"); + Serial.println(); + } + } + + if (!enCours && digitalRead(WIO_KEY_B) == LOW) { + enCours = true; + tempsDepart = millis(); + Serial.println("Chronomètre démarré !"); + delay(300); // Anti-rebond + } + + // Réinitialiser + if (digitalRead(WIO_KEY_B) == LOW) { + enCours = false; + Serial.println("Chronomètre réinitialisé."); + delay(300); + } + + // Affichage du temps écoulé + if (enCours) { + unsigned long tempsActuel = millis(); + unsigned long secondes = (tempsActuel - tempsDepart) / 1000; + Serial.print("Temps écoulé : "); + Serial.print(secondes); + Serial.println(" s"); + delay(1000); // Affiche chaque seconde + } + float x_a,y_a; x_a = lis.getAccelerationX() * 100-4; y_a = lis.getAccelerationY() * 100+1; @@ -49,7 +113,7 @@ void loop() { x++; if (x >= XMAX) { Serial.print("MUR TOUCHÉ VERS NOUS TOUCHÉ!"); -// perdu(); + perdu(); exit; } } @@ -61,7 +125,7 @@ void loop() { x--; if (x <= 0) { Serial.print("MUR TOUCHÉ A L'ARRIÈRE TOUCHÉ!"); -// perdu(); + perdu(); exit; } } @@ -73,7 +137,7 @@ void loop() { y--; if (y <= 0) { Serial.print("MUR TOUCHÉ VERS LA DROITE TOUCHÉ!"); -// perdu(); + perdu(); exit; } } @@ -85,7 +149,7 @@ void loop() { y++; if (y >= YMAX) { Serial.print("MUR TOUCHÉ VERS LA GAUCHE TOUCHÉ!"); -// perdu(); + perdu(); exit; } } @@ -98,21 +162,9 @@ void loop() { } delay(50); - // put your main code here, to run repeatedly: - if (digitalRead(WIO_KEY_C) == LOW) { - Serial.println("C Key pressed"); - } - else if (digitalRead(WIO_KEY_B) == LOW) { - Serial.println("B Key pressed"); - } - else if (digitalRead(WIO_KEY_A) == LOW) { - Serial.println("A Key pressed"); - } + } -//void perdu() { -// tft.fillScreen(TFT_RED); // fond blanc -//} // déplacement vers l'arrière : x diminue