From 1cd5b2b6da24f678136f2077feb29d47ab8f7132 Mon Sep 17 00:00:00 2001 From: anperederi Date: Fri, 12 May 2023 20:24:34 +0200 Subject: [PATCH] update project file --- Projet.ino | 87 ------------------------------------------ Projet/Projet.ino | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 87 deletions(-) delete mode 100644 Projet.ino create mode 100644 Projet/Projet.ino diff --git a/Projet.ino b/Projet.ino deleted file mode 100644 index ea56652..0000000 --- a/Projet.ino +++ /dev/null @@ -1,87 +0,0 @@ -#include "TFT_eSPI.h" -#include"LIS3DHTR.h" - -TFT_eSPI tft; -LIS3DHTR lis; - - -unsigned int tabPiecesNov[5][2]={{150, 150}, {2, 15}, {100, 5}, {45, 120}, {30, 20}}, -tabPiecesCon[5][2]={{4, 35}, {2, 15}, {100, 5}, {45, 120}, {450, 120}}, -tabPiecesExp[5][2]={{4, 35}, {2, 15}, {100, 5}, {45, 120}, {450, 120}}; - - -unsigned int x=100; -unsigned int y=100; -const unsigned int rayonBoule = 7, rayonPiece = 5; -const unsigned int vitesse = 8; - -const unsigned int xMax = 307; -const unsigned int yMax = 226; - -bool start = false; - - -void setup() { - tft.begin(); - tft.setRotation(3); // (0,0) à l'oppossé du joyssitck - tft.fillScreen(TFT_DARKGREY); // fond blanc - - Serial.begin(115200); - pinMode(WIO_BUZZER, OUTPUT); - - tft.setTextColor(TFT_BLACK); - - tft.fillCircle(x, y, rayonBoule, TFT_RED); - - pinMode(WIO_KEY_C, INPUT_PULLUP); - tft.fillRect(0,0,320,40,TFT_BLUE); - tft.drawString("Mode 1", 10, 10); //prints strings from (10, 10) - - lis.begin(Wire1); - lis.setOutputDataRate(LIS3DHTR_DATARATE_25HZ); // Setting output data rage to 25Hz, can be set up tp 5kHz - lis.setFullScaleRange(LIS3DHTR_RANGE_2G); // Setting scale range to 2g, select from 2,4,8,16g - - // attachInterrupt(0, depart, FALLING); -} - -void afficherPiece(int posTab) { - tft.fillCircle(tabPiecesNov[posTab][0], tabPiecesNov[posTab][1],rayonPiece,TFT_YELLOW); - tft.drawCircle(tabPiecesNov[posTab][0], tabPiecesNov[posTab][1],rayonPiece,TFT_BLACK); - tft.drawString("$", (tabPiecesNov[posTab][0] - 2), (tabPiecesNov[posTab][1] - 3)); -} - -// void depart() { -// tft.drawString("3", 100, 100); //prints strings from (10, 10) -// delay(1000); -// tft.drawString("2", 100, 100); //prints strings from (10, 10) -// delay(1000); -// tft.drawNumber("1", 100, 100); //prints strings from (10, 10) -// delay(1000); -// tft.drawString("GO", 100, 100); //prints strings from (10, 10) -// analogWrite(WIO_BUZZER, 128); -// delay(1000); -// analogWrite(WIO_BUZZER, 0); -// go = millis(); -// } - -void Giroscope() { - float x_values, y_values ; - x_values = lis.getAccelerationX(); - y_values = lis.getAccelerationY(); - - if(y>yMax || y<(rayonBoule+40) || x>xMax || x lis; + + +unsigned int tabPiecesNov[5][2]={{150, 150}, {2, 15}, {100, 5}, {45, 120}, {30, 20}}, // tableau des pieces du mode novice + tabPiecesCon[5][2]={{4, 35}, {2, 15}, {100, 5}, {45, 120}, {450, 120}}, // tableau des pieces du mode confirmé + tabPiecesExp[5][2]={{4, 35}, {2, 15}, {100, 5}, {45, 120}, {450, 120}}; // tableau des pieces du mode expert + + +unsigned int xBoule=100; // position x de départ de la boule +unsigned int yBoule=100; // position y de départ de la boule +const unsigned int rayonBoule = 7, rayonPiece = 5; // rayon de la boule et des pieces +const unsigned int vitesseBoule = 8; // vitesse de déplacement de la boule + +enum mode {novice, confirme, expert}; + +const unsigned int xMax = 307; +const unsigned int yMax = 226; + +bool start = false; + + +void setup() { + tft.begin(); + tft.setRotation(3); // (0,0) à l'oppossé du joyssitck + Serial.begin(115200); + + // Mise en place des éléments sur l'écran : + tft.fillScreen(TFT_DARKGREY); // fond gris foncé + tft.fillCircle(xBoule, yBoule, rayonBoule, TFT_RED); // Dessin de la boule en rouge + tft.fillRect(0,0,320,40,TFT_BLUE); // Rectangle du bandeau de scores en bleu + tft.setTextColor(TFT_BLACK); // couleur du text en noir + tft.drawString("Mode novice", 10, 10); // affiche le texte en position (10, 10) + + // Paramétrage du giroscope : + lis.begin(Wire1); + lis.setOutputDataRate(LIS3DHTR_DATARATE_25HZ); // Setting output data rage to 25Hz, can be set up tp 5kHz + lis.setFullScaleRange(LIS3DHTR_RANGE_2G); // Setting scale range to 2g, select from 2,4,8,16g + + // Déclaration des capteurs : + pinMode(WIO_KEY_C, INPUT_PULLUP); // Déclaration du bouton C en INPUT + pinMode(WIO_BUZZER, OUTPUT); // Déclaration du buzzer en OUTPUT +} + +// fonction d'affichage d'une piece +void afficherPiece(int posTab) { + tft.fillCircle(tabPiecesNov[posTab][0], tabPiecesNov[posTab][1],rayonPiece,TFT_YELLOW); // Dessin du cercle plein en jaune de la piece + tft.drawCircle(tabPiecesNov[posTab][0], tabPiecesNov[posTab][1],rayonPiece,TFT_BLACK); // Contour noir sur la piece + tft.drawString("$", (tabPiecesNov[posTab][0] - 2), (tabPiecesNov[posTab][1] - 3)); // Icon dollar sur le centre de la piece +} + +// void depart() { +// tft.drawString("3", 100, 100); //prints strings from (10, 10) +// delay(1000); +// tft.drawString("2", 100, 100); //prints strings from (10, 10) +// delay(1000); +// tft.drawNumber("1", 100, 100); //prints strings from (10, 10) +// delay(1000); +// tft.drawString("GO", 100, 100); //prints strings from (10, 10) +// analogWrite(WIO_BUZZER, 128); +// delay(1000); +// analogWrite(WIO_BUZZER, 0); +// go = millis(); +// } + +void Giroscope() { + float x_values, y_values ; + x_values = lis.getAccelerationX(); + y_values = lis.getAccelerationY(); + + if(yBoule>yMax || yBoule<(rayonBoule+40) || xBoule>xMax || xBoule