![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
projet de Monsieur Flipo BULLY et Barrocas
Dependencies: BSP_DISCO_F746NG L3GD20H LCD_DISCO_F746NG TS_DISCO_F746NG mbed
main.cpp@0:490c09b75550, 2018-06-12 (annotated)
- Committer:
- SamSF
- Date:
- Tue Jun 12 12:50:01 2018 +0000
- Revision:
- 0:490c09b75550
- Child:
- 1:262ed79fa7d7
Projet interface avec capteur L3GD20H
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SamSF | 0:490c09b75550 | 1 | #include "mbed.h" |
SamSF | 0:490c09b75550 | 2 | #include "TS_DISCO_F746NG.h" |
SamSF | 0:490c09b75550 | 3 | #include "LCD_DISCO_F746NG.h" |
SamSF | 0:490c09b75550 | 4 | #include"L3GD20H.h" |
SamSF | 0:490c09b75550 | 5 | #define GYR_ADDRESS 0xD6 |
SamSF | 0:490c09b75550 | 6 | |
SamSF | 0:490c09b75550 | 7 | LCD_DISCO_F746NG lcd; |
SamSF | 0:490c09b75550 | 8 | TS_DISCO_F746NG ts; |
SamSF | 0:490c09b75550 | 9 | |
SamSF | 0:490c09b75550 | 10 | L3GD20H gyro(PB_9, PB_8); |
SamSF | 0:490c09b75550 | 11 | |
SamSF | 0:490c09b75550 | 12 | int main() |
SamSF | 0:490c09b75550 | 13 | { |
SamSF | 0:490c09b75550 | 14 | TS_StateTypeDef TS_State; |
SamSF | 0:490c09b75550 | 15 | ts.Init(420, 272); |
SamSF | 0:490c09b75550 | 16 | // uint32_t pY= 272.0, pX=480.0; //nombre de pixel sur notre écran |
SamSF | 0:490c09b75550 | 17 | |
SamSF | 0:490c09b75550 | 18 | //Interface d'initilisation |
SamSF | 0:490c09b75550 | 19 | int circle_X = 234; // position d'init du cercle en X |
SamSF | 0:490c09b75550 | 20 | int circle_Y = 159; // position d'init du cercle en Y |
SamSF | 0:490c09b75550 | 21 | short g[3]; |
SamSF | 0:490c09b75550 | 22 | bool tampon = false; |
SamSF | 0:490c09b75550 | 23 | int i; |
SamSF | 0:490c09b75550 | 24 | lcd.Clear(LCD_COLOR_BLUE); |
SamSF | 0:490c09b75550 | 25 | lcd.SetBackColor(LCD_COLOR_BLUE); |
SamSF | 0:490c09b75550 | 26 | lcd.SetTextColor(LCD_COLOR_WHITE); |
SamSF | 0:490c09b75550 | 27 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"INTERFACAGE POUR L3GD20H", CENTER_MODE); // Initialisation |
SamSF | 0:490c09b75550 | 28 | lcd.SetFont(&Font16); |
SamSF | 0:490c09b75550 | 29 | lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"Cree par", CENTER_MODE); |
SamSF | 0:490c09b75550 | 30 | lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"Flipo Samuel", CENTER_MODE); |
SamSF | 0:490c09b75550 | 31 | lcd.DisplayStringAt(0, LINE(10), (uint8_t *)"Bully Jerome", CENTER_MODE); |
SamSF | 0:490c09b75550 | 32 | lcd.DisplayStringAt(0, LINE(11), (uint8_t *)"Barrocas Miguel", CENTER_MODE); |
SamSF | 0:490c09b75550 | 33 | wait(2); |
SamSF | 0:490c09b75550 | 34 | //Interface définitive |
SamSF | 0:490c09b75550 | 35 | lcd.Clear(LCD_COLOR_WHITE); //Couleur d'arrière plan |
SamSF | 0:490c09b75550 | 36 | lcd.SetFont(&Font24); //Taille de police @24 |
SamSF | 0:490c09b75550 | 37 | lcd.SetBackColor(LCD_COLOR_WHITE); //Fond d'écran du texte en bleu |
SamSF | 0:490c09b75550 | 38 | lcd.SetTextColor(LCD_COLOR_BLUE); //Texte en blanc |
SamSF | 0:490c09b75550 | 39 | lcd.DisplayStringAt(0,LINE(0),(uint8_t *)"GYROSCOPE L3GD20H", CENTER_MODE); // TITRE |
SamSF | 0:490c09b75550 | 40 | lcd.SetFont(&Font12); // Taille de police @12 |
SamSF | 0:490c09b75550 | 41 | lcd.DisplayStringAt(0,236,(uint8_t *)"Flipo Samuel", LEFT_MODE); //Auteur 1 |
SamSF | 0:490c09b75550 | 42 | lcd.DisplayStringAt(0,248,(uint8_t *)"Bully Jerome", LEFT_MODE); //Auteur 2 |
SamSF | 0:490c09b75550 | 43 | lcd.DisplayStringAt(0,260,(uint8_t *)"Barrocas Miguel", LEFT_MODE); //Auteur 3 |
SamSF | 0:490c09b75550 | 44 | lcd.SetFont(&Font16); // Taille de police @16 |
SamSF | 0:490c09b75550 | 45 | while (1) { |
SamSF | 0:490c09b75550 | 46 | ts.GetState(&TS_State); |
SamSF | 0:490c09b75550 | 47 | gyro.read(g); //acquisition des données du gyroscope |
SamSF | 0:490c09b75550 | 48 | /*sprintf(tmp, "%5d %5d %5d" , g[0], g[1],g[2]); //%hd uint16_t |
SamSF | 0:490c09b75550 | 49 | lcd.SetTextColor(LCD_COLOR_BLUE); |
SamSF | 0:490c09b75550 | 50 | lcd.DisplayStringAt(0, LINE(2),(uint8_t *)tmp,CENTER_MODE); // Affichage des valeurs*/ //utilité d'afficher les valeurs?? |
SamSF | 0:490c09b75550 | 51 | |
SamSF | 0:490c09b75550 | 52 | //------------------------------GESTION DE LA BOULE----------------------------------\\ |
SamSF | 0:490c09b75550 | 53 | //affichage de la zone de déplacement |
SamSF | 0:490c09b75550 | 54 | BSP_LCD_DrawRect(5,40,460,190); //XPOS , YPOS, TAILLE X, TAILLE Y |
SamSF | 0:490c09b75550 | 55 | for (i=0; i<=3; i++) { |
SamSF | 0:490c09b75550 | 56 | g[i]=g[i]/1000; //"mise à l'échelle" data/pixel |
SamSF | 0:490c09b75550 | 57 | } |
SamSF | 0:490c09b75550 | 58 | lcd.SetTextColor(LCD_COLOR_WHITE); |
SamSF | 0:490c09b75550 | 59 | BSP_LCD_FillCircle(circle_X,circle_Y,10); //effacement de l'ancien cercle |
SamSF | 0:490c09b75550 | 60 | circle_X=circle_X+g[0];//déplacement sur l'axe X |
SamSF | 0:490c09b75550 | 61 | circle_Y=circle_Y+g[2];//déplacement sur l'axe Y |
SamSF | 0:490c09b75550 | 62 | if (circle_X <15) { |
SamSF | 0:490c09b75550 | 63 | circle_X=15; //limite vers la gauche |
SamSF | 0:490c09b75550 | 64 | } |
SamSF | 0:490c09b75550 | 65 | if (circle_X >450) { |
SamSF | 0:490c09b75550 | 66 | circle_X=450; //limite vers la droite |
SamSF | 0:490c09b75550 | 67 | } |
SamSF | 0:490c09b75550 | 68 | if (circle_Y <50) { |
SamSF | 0:490c09b75550 | 69 | circle_Y=50; //limite vers le haut |
SamSF | 0:490c09b75550 | 70 | } |
SamSF | 0:490c09b75550 | 71 | if (circle_Y >220) { |
SamSF | 0:490c09b75550 | 72 | circle_Y=220; //limite vers le bas |
SamSF | 0:490c09b75550 | 73 | } |
SamSF | 0:490c09b75550 | 74 | if (TS_State.touchDetected) { //ecran touché |
SamSF | 0:490c09b75550 | 75 | tampon =not(tampon); //inversion de la variable tampon; |
SamSF | 0:490c09b75550 | 76 | do {//Blocaque pour effectuer une seule inversion |
SamSF | 0:490c09b75550 | 77 | ts.GetState(&TS_State); //récup du TS |
SamSF | 0:490c09b75550 | 78 | } while(TS_State.touchDetected !=0); |
SamSF | 0:490c09b75550 | 79 | } //fin Touch Screen |
SamSF | 0:490c09b75550 | 80 | if (tampon ==false) { |
SamSF | 0:490c09b75550 | 81 | lcd.SetTextColor(LCD_COLOR_RED); //boule en couleur rouge |
SamSF | 0:490c09b75550 | 82 | } else if (tampon ==true) { |
SamSF | 0:490c09b75550 | 83 | lcd.SetTextColor(LCD_COLOR_WHITE); //boule en blanc |
SamSF | 0:490c09b75550 | 84 | |
SamSF | 0:490c09b75550 | 85 | } |
SamSF | 0:490c09b75550 | 86 | BSP_LCD_FillCircle(circle_X,circle_Y,10); //écriture de la boule rouge |
SamSF | 0:490c09b75550 | 87 | wait(0.01); //attente pour le calcul |
SamSF | 0:490c09b75550 | 88 | |
SamSF | 0:490c09b75550 | 89 | } //fin while |
SamSF | 0:490c09b75550 | 90 | }//fin main |