Pour Marc la mignonne

Dependencies:   BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed

Files at this revision

API Documentation at this revision

Comitter:
Alex_mln
Date:
Thu May 31 06:11:25 2018 +0000
Commit message:
Tiens pd

Changed in this revision

BSP_DISCO_F429ZI.lib Show annotated file Show diff for this revision Revisions of this file
Capteurs.cpp Show annotated file Show diff for this revision Revisions of this file
Capteurs.h Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F429ZI.lib Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F429ZI.lib Show annotated file Show diff for this revision Revisions of this file
Touchescreen.cpp Show annotated file Show diff for this revision Revisions of this file
Touchescreen.h Show annotated file Show diff for this revision Revisions of this file
automatique.cpp Show annotated file Show diff for this revision Revisions of this file
automatique.h Show annotated file Show diff for this revision Revisions of this file
commandes.cpp Show annotated file Show diff for this revision Revisions of this file
commandes.h Show annotated file Show diff for this revision Revisions of this file
fonctions.cpp Show annotated file Show diff for this revision Revisions of this file
fonctions.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
screen.cpp Show annotated file Show diff for this revision Revisions of this file
screen.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F429ZI.lib	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Capteurs.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,212 @@
+#include "fonctions.h"
+#include "Touchescreen.h"
+
+typedef int liste [6];
+liste blanc;
+liste noir;
+liste seuil;
+liste mesure;
+
+
+//Premiere rangée de capteur
+//AnalogIn capt11(PF_7);
+AnalogIn capt12(PF_8);
+AnalogIn capt11(PC_3);
+//AnalogIn capt13(PF_9);
+
+//Deuxieme rangée de capteur
+AnalogIn capt21(PC_4);
+AnalogIn capt22(PC_1);
+//AnalogIn capt23(PC_2);
+
+//Troisième rangée de capteur
+
+AnalogIn capt31(PA_7);
+AnalogIn capt32(PC_5);
+
+
+LCD_DISCO_F429ZI lcd2;
+TS_DISCO_F429ZI ts2;
+TS_StateTypeDef tsState2;
+    uint16_t xc, yc;
+
+
+
+
+void interface_noir(){
+    lcd2.Clear(LCD_COLOR_WHITE);
+    
+    lcd2.SetTextColor(LCD_COLOR_BLUE);
+    lcd2.FillRect(40,25,150,40);
+    lcd2.SetBackColor(LCD_COLOR_BLUE);
+    lcd2.SetTextColor(LCD_COLOR_WHITE);
+    lcd2.DisplayStringAt(0, LINE(2), (uint8_t *)"Calibrage", CENTER_MODE);
+    
+    lcd2.SetBackColor(LCD_COLOR_WHITE);
+    lcd2.SetTextColor(LCD_COLOR_BLACK);
+    lcd2.DisplayStringAt(0, LINE(7), (uint8_t *)"Mesure du noir", CENTER_MODE);
+    
+    lcd2.SetTextColor(LCD_COLOR_BLUE);
+    lcd2.FillCircle(120,235,50);
+    lcd2.SetBackColor(LCD_COLOR_BLUE);
+    lcd2.SetTextColor(LCD_COLOR_BLACK);
+    lcd2.DisplayStringAt(0, 230, (uint8_t *)" OK", CENTER_MODE);
+    }
+
+
+
+void interface_blanc(){
+    lcd2.Clear(LCD_COLOR_WHITE);
+    
+    lcd2.SetTextColor(LCD_COLOR_BLUE);
+    lcd2.FillRect(40,25,150,40);
+    lcd2.SetBackColor(LCD_COLOR_BLUE);
+    lcd2.SetTextColor(LCD_COLOR_WHITE);
+    lcd2.DisplayStringAt(0, LINE(2), (uint8_t *)"Calibrage", CENTER_MODE);
+    
+    lcd2.SetBackColor(LCD_COLOR_WHITE);
+    lcd2.SetTextColor(LCD_COLOR_BLACK);
+    lcd2.DisplayStringAt(0, LINE(7), (uint8_t *)"Mesure du blanc", CENTER_MODE);
+    
+    lcd2.SetTextColor(LCD_COLOR_BLUE);
+    lcd2.FillCircle(120,235,50);
+    lcd2.SetBackColor(LCD_COLOR_BLUE);
+    lcd2.SetTextColor(LCD_COLOR_BLACK);
+    lcd2.DisplayStringAt(0, 230, (uint8_t *)" OK", CENTER_MODE);
+    }
+    
+    
+    
+void detectionc(){
+     xc = tsState2.X;
+        yc = tsState2.Y;
+        uint8_t text[7];
+        sprintf((char*)text, "%d; %d", xc, yc);
+        lcd2.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);   }
+            
+
+int noir11,noir12,noir13,noir21,noir22,noir23,noir31,noir32,noir33;
+int blanc11,blanc12,blanc13,blanc21,blanc22,blanc23,blanc31,blanc32,blanc33;
+
+    
+int * pointeur = (int*)malloc(3*sizeof(int));    
+    
+void calibrage(){
+    uint8_t status2= ts2.Init(lcd2.GetXSize(), lcd2.GetYSize());
+    ts2.GetState(&tsState2); 
+    
+    
+    interface_noir();                                      //Mesure du noir
+    
+    while((xc<72 || xc>172) || (yc>295 || yc<195)){       //Attente de la position
+        ts2.GetState(&tsState2); 
+        detectionc();
+        wait(0.05);}
+    
+    noir[0]=capt11.read()*1000;
+    noir[1]=capt11.read()*1000;
+   // noir[2]=capt13.read()*1000;
+    
+    noir[2]=capt21.read()*1000;
+    noir[3]=capt22.read()*1000;
+  //  noir[5]=capt23.read()*1000;
+    
+    noir[4]=capt31.read()*1000;
+    noir[5]=capt32.read()*1000;
+  ///  noir[8]=capt33.read()*1000;
+    
+    wait(0.1);
+    
+    lcd2.Clear(LCD_COLOR_WHITE);                 //Passage au prochain
+    lcd2.FillRect(50,50,150,50);
+    lcd2.SetBackColor(LCD_COLOR_BLACK);
+    lcd2.SetTextColor(LCD_COLOR_WHITE);
+    lcd2.DisplayStringAt(0, LINE(4), (uint8_t *)"Next ->", CENTER_MODE);
+    
+    
+    
+    while((xc<47 || xc>205) || (yc>100 || yc<50)){
+        ts2.GetState(&tsState2); 
+        detectionc();
+        wait(0.05);}
+        
+        
+    wait(0.01); 
+    interface_blanc();  //Mesure du blanc
+    
+    while((xc<72 || xc>172) || (yc>295 || yc<195)){       //Attente de la position
+        ts2.GetState(&tsState2); 
+        detectionc();
+        wait(0.05);}
+    
+    
+    blanc[0]=capt11.read()*1000;
+    blanc[1]=capt11.read()*1000;
+  //  blanc[2]=capt13.read()*1000;
+    
+    blanc[2]=capt21.read()*1000;
+    blanc[3]=capt22.read()*1000;
+  //  blanc[5]=capt23.read()*1000;
+    
+    blanc[4]=capt31.read()*1000;
+    blanc[5]=capt32.read()*1000;
+ //   blanc[8]=capt33.read()*1000;
+    
+    wait(0.01); 
+    
+
+    for(int k=0;k<6;k++){           //Traduction sous forme d'un pointeur pour le renvoi et calcul du seuil
+        seuil[k]=(blanc[k]+noir[k])/2;} 
+    }
+    
+    
+    
+int* detectionLigne(){
+    for(int k=0;k<3;k++){
+        *(pointeur+k)=0; }
+    mesure[0]=capt11.read()*1000;
+    mesure[1]=capt11.read()*1000;
+   // mesure[2]=capt13.read()*1000;
+    
+    mesure[2]=capt21.read()*1000;
+    mesure[3]=capt22.read()*1000;
+  //  mesure[5]=capt23.read()*1000;
+    
+    mesure[4]=capt31.read()*1000;
+    mesure[5]=capt32.read()*1000;
+  //  mesure[8]=capt33.read()*1000;
+  
+  for(int k=0;k<6;k++){
+    affichage(mesure[k],k); }
+    
+    for(int k=0;k<6;k++){
+        if(mesure[k]<seuil[k]){
+            //*(pointeur+(k/2))=*(pointeur+(k/2))+1; 
+            if(k==1 || k==0){
+             *pointeur=*pointeur + 1;}
+            else if(k==2 || k==3){
+             *(pointeur+1)=*(pointeur+1) + 1;}
+             else if(k==4 || k==5){
+             *(pointeur+2)=*(pointeur+2) + 1;}
+             }}
+    for(int k=0;k<3;k++){
+            if(*(pointeur+k)>=1){
+                *(pointeur+k)=1; } 
+            else{
+                *(pointeur+k)=0;}}
+    return(pointeur);
+    }
+            
+            
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Capteurs.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,5 @@
+void interface_noir();
+void interface_blanc();
+void detectionc();
+void calibrage();
+int* detectionLigne();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F429ZI.lib	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F429ZI.lib	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Touchescreen.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,107 @@
+#include "mbed.h"
+#include "screen.h"
+#include "LCD_DISCO_F429ZI.h"
+#include "Touchescreen.h"
+
+LCD_DISCO_F429ZI lcdt;
+//DigitalOut led1(LED1);
+
+
+// marchent : PF9 PF7 PF8 PC4 PC0 PC1 PC2 PC3 PA7 PC5
+  
+ /* 
+
+//Premiere rangée de capteur
+AnalogIn capt11(PF_7);
+AnalogIn capt12(PF_8);
+AnalogIn capt13(PF_9);
+
+//Deuxieme rangée de capteur
+AnalogIn capt21(PC_4);
+AnalogIn capt22(PC_1);
+AnalogIn capt23(PC_2);
+
+//Troisième rangée de capteur
+AnalogIn capt31(PC_3);
+AnalogIn capt32(PA_7);
+AnalogIn capt33(PC_5);
+
+
+
+
+
+*/
+
+
+
+
+
+/*
+
+DigitalOut led(LED1);
+DigitalOut test(PA_0);
+DigitalOut mot1(PE_12);
+DigitalOut mot2(PE_14);
+int valeur_neg;
+
+void init_neg(){
+    valeur_neg=(capt11.read()*10000+capt12.read()*10000+capt13.read()*10000)/3;
+    wait(0.001);}
+    
+*/
+
+
+
+
+void affichage(int valeur,int place){
+   /* float value=0;
+    float value1=0;
+    float value2=0;
+    float value3=0;
+    screen_init();
+    lcd.Clear(LCD_COLOR_GREEN);
+    init_neg();
+    while(1){
+        value1 = capt11.read()*10000;
+        value2 = capt12.read()*10000;
+        value3 = capt13.read()*10000;*/
+        showIntegerScreen((int)(valeur),place,0,CENTER_MODE);
+      /*  showIntegerScreen((int)(value2),3,0,CENTER_MODE);
+        showIntegerScreen((int)(value3),4,0,CENTER_MODE);
+        showIntegerScreen(valeur_neg,0,0,LEFT_MODE);
+        value=(value1+value2+value3)/3;
+        
+        value1 = capt21.read()*10000;
+        value2 = capt22.read()*10000;
+        value3 = capt23.read()*10000;
+        showIntegerScreen((int)(value1),5,0,CENTER_MODE);
+        showIntegerScreen((int)(value2),6,0,CENTER_MODE);
+        showIntegerScreen((int)(value3),7,0,CENTER_MODE);
+        
+        value1 = capt31.read()*10000;
+        value2 = capt32.read()*10000;
+        value3 = capt33.read()*10000;
+        showIntegerScreen((int)(value1),8,0,CENTER_MODE);
+        showIntegerScreen((int)(value2),9,0,CENTER_MODE);
+        showIntegerScreen((int)(value3),10,0,CENTER_MODE);
+        if(value>valeur_neg){
+            test=1;}
+        else{
+            test=0;}
+        mot1=1;
+        mot2=0;
+        wait(2);
+        mot1=1;
+        mot2=1;
+        wait(0.5);
+        mot1=0;
+        mot2=1;
+        wait(2);
+        mot1=0;
+        mot2=0;
+        wait(1);
+        
+        */
+        
+        wait(0.1);    
+} 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Touchescreen.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,1 @@
+void affichage(int valeur,int place);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/automatique.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+#include "LCD_DISCO_F429ZI.h"
+#include "commandes.h"
+#include "TS_DISCO_F429ZI.h"
+#include <stdlib.h>
+#include "screen.h"
+#include "automatique.h"
+#include "Capteurs.h"
+
+//typedef int tab[3];
+int capteur1,capteur2,capteur3; //gauche, centre, droit
+//tab ligne;
+float delai=1.0;
+
+
+LCD_DISCO_F429ZI lcda;
+TS_DISCO_F429ZI tsa;
+TS_StateTypeDef tsStatea;
+uint16_t xa, ya;
+
+
+
+void detectiona(){
+    xa = tsStatea.X;
+    ya = tsStatea.Y;
+    int8_t text[7];
+    sprintf((char*)text, "%d; %d", xa, ya);
+    lcda.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);   
+}
+
+
+void traitement(){
+    if(capteur1==0 && capteur2==1 && capteur3==0){
+        avancer();
+        wait(delai);
+    }
+    else if(capteur1==1 && capteur2==0 && capteur3==0){
+        tournerDroitVite();
+        wait(delai);
+    }
+    else if(capteur1==1 && capteur2==1 && capteur3==0){
+        tourner_droite();
+        wait(delai);
+    }
+    else if(capteur1==0 && capteur2==0 && capteur3==1){
+        tournerGaucheVite();
+        wait(delai);
+    }
+    else if(capteur1==0 && capteur2==1 && capteur3==1){
+        tourner_gauche();
+        wait(delai);
+    }
+    else if(capteur1==1 && capteur2==1 && capteur3==1){
+        arreter();
+        wait(delai);
+    }
+}
+        
+void go_automatique(){
+
+        uint8_t status = tsa.Init(lcda.GetXSize(), lcda.GetYSize());
+        tsa.GetState(&tsStatea); 
+        detectiona();
+
+        
+        while((xa>225 || xa<12) || (ya<78-20 || ya>288-20)){
+            tsa.GetState(&tsStatea); 
+            detectiona();
+            int* ligne=detectionLigne();
+            capteur1=*ligne;
+            capteur2=*(ligne+1);
+            capteur3=*(ligne+2);
+            traitement();
+            wait(delai);
+            }
+}
+
+
+    
+    
+    
+    
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/automatique.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,3 @@
+void detectiona();
+void traitement();
+void go_automatique();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commandes.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "LCD_DISCO_F429ZI.h"
+#include "commandes.h"
+
+
+AnalogOut moteur1(PA_4); //moteur droit
+AnalogOut moteur2(PA_5); //moteur gauche
+
+
+float vitesse=0.5;
+float vit=vitesse*0.3+0.7;
+
+void recup_vitesse(float pvit){
+    vitesse=pvit; }
+
+
+
+void arreter(){
+    moteur1=0;
+    moteur2=moteur1;
+}
+
+void avancer(){
+    moteur1=vit;
+    moteur2=moteur1;
+}
+
+void tourner_droite(){
+    moteur1=0.70;
+    moteur2=1.0;
+}
+
+void tourner_gauche(){
+    moteur1=1.0;
+    moteur2=0.70;
+}  
+
+void tournerDroitVite(){
+    moteur1=0.0;
+    moteur2=1.0;
+}
+
+void tournerGaucheVite(){
+    moteur1=1.0;
+    moteur2=0.0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commandes.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,7 @@
+void arreter();
+void avancer();
+void tourner_droite();
+void tourner_gauche();
+void tournerDroitVite();
+void tournerGaucheVite();
+void recup_vitesse(float);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fonctions.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,27 @@
+#include "fonctions.h"
+
+DigitalOut ledjaune(LED1);
+DigitalOut ledrouge(LED2);
+
+void erreur(){
+    
+            while(1){
+            
+            ledjaune=1;
+            ledrouge=0;
+            wait(0.2);
+            ledrouge=1;
+            wait(0.2);
+            
+            ledjaune=0;
+            wait(0.1);
+            ledrouge=0;
+            wait(0.1);
+            ledrouge=1;
+            wait(0.1);
+            ledjaune=1;
+            wait(0.2);
+            ledrouge=0;
+            ledjaune=0;
+            
+            }}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fonctions.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,12 @@
+#include "mbed.h"
+#include "LCD_DISCO_F429ZI.h"
+
+#include "TS_DISCO_F429ZI.h"
+#include <stdlib.h>
+#include "screen.h"
+
+
+
+
+
+void erreur();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,294 @@
+#include "mbed.h"
+#include "LCD_DISCO_F429ZI.h"
+#include "TS_DISCO_F429ZI.h"
+
+#include "Capteurs.h"
+#include "fonctions.h"
+#include "automatique.h"
+#include "commandes.h"
+
+
+LCD_DISCO_F429ZI lcd;
+//LCD_DISCO_F429ZI lcd;
+TS_DISCO_F429ZI ts;
+TS_StateTypeDef tsState;
+
+int vol_y=145;
+bool test=false;
+bool indice_depart=false;
+uint16_t x, y;
+
+bool var_manuel=false;
+bool var_automatique=false;
+
+
+
+void initialisation(){
+    lcd.Clear(LCD_COLOR_WHITE);
+      
+      
+    lcd.SetTextColor(LCD_COLOR_BLUE);
+    lcd.FillRect(18,57,104,30);          //Rectangle calibrage
+    lcd.SetTextColor(LCD_COLOR_RED);
+    lcd.FillEllipse(65, 118, 45, 15);   //ellipse des modes
+    lcd.FillRect(20, 180-35, 90, 40);    //Rectangle manuel
+    lcd.FillRect(5, 230-35, 135, 40);    //Rectangle automatique
+      
+    //La vitesse :
+    lcd.SetTextColor(LCD_COLOR_RED); 
+    lcd.FillRect(200,80,2,180);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.FillRect(190,vol_y-15,20,30);
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"V", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"I", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"T", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(10), (uint8_t *)"E", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(11), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(12), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(13), (uint8_t *)"E", RIGHT_MODE);
+    
+    
+    //Départ
+    lcd.SetTextColor(LCD_COLOR_BLACK);
+    lcd.FillEllipse(115, 292, 60, 23);
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.FillEllipse(115, 292, 55, 20); 
+      
+      
+    //Ecriture  
+    
+    lcd.SetTextColor(LCD_COLOR_WHITE); 
+    lcd.SetBackColor(LCD_COLOR_BLUE);
+    lcd.DisplayStringAt(20,67,(uint8_t *)"Calibrage",LEFT_MODE);
+    lcd.SetBackColor(LCD_COLOR_RED); 
+    lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Turbo Poparcalex2", CENTER_MODE);
+   
+    lcd.DisplayStringAt(45, LINE(7), (uint8_t *)"Mode", LEFT_MODE);
+    lcd.DisplayStringAt(35, LINE(10), (uint8_t *)"Manuel", LEFT_MODE);
+    lcd.DisplayStringAt(15, LINE(13), (uint8_t *)"Automatique", LEFT_MODE);
+    
+    lcd.SetBackColor(LCD_COLOR_GREEN);
+    lcd.SetTextColor(LCD_COLOR_BLACK);
+    lcd.DisplayStringAt(0, LINE(18), (uint8_t *)"Depart", CENTER_MODE);
+    
+    test=true;
+    wait(0.1);}
+    
+
+void manuel(){
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.FillRect(20, 180-35, 90, 40); 
+    lcd.SetBackColor(LCD_COLOR_GREEN);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.DisplayStringAt(35, LINE(10), (uint8_t *)"Manuel", LEFT_MODE);
+    var_manuel=true;
+    
+    lcd.SetTextColor(LCD_COLOR_RED);
+    lcd.FillRect(5, 230-35, 135, 40); 
+    lcd.SetBackColor(LCD_COLOR_RED);
+    lcd.SetTextColor(LCD_COLOR_WHITE); 
+    lcd.DisplayStringAt(15, LINE(13), (uint8_t *)"Automatique", LEFT_MODE);
+    var_automatique=false;
+    x=0;
+    y=0;  }
+    
+    
+void automatique(){
+    lcd.SetTextColor(LCD_COLOR_RED);
+    lcd.FillRect(20, 180-35, 90, 40); 
+    lcd.SetBackColor(LCD_COLOR_RED);
+    lcd.SetTextColor(LCD_COLOR_WHITE); 
+    lcd.DisplayStringAt(35, LINE(10), (uint8_t *)"Manuel", LEFT_MODE);
+    var_manuel=false;
+    
+    lcd.SetTextColor(LCD_COLOR_GREEN);
+    lcd.FillRect(5, 230-35, 135, 40); 
+    lcd.SetBackColor(LCD_COLOR_GREEN);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.DisplayStringAt(15, LINE(13), (uint8_t *)"Automatique", LEFT_MODE);
+    var_automatique=true; 
+    x=0;
+    y=0; }
+    
+    
+void vitesse(){
+    lcd.SetTextColor(LCD_COLOR_WHITE); 
+    lcd.FillRect(190,vol_y-15,20,30);
+    lcd.SetTextColor(LCD_COLOR_RED); 
+    lcd.FillRect(200,80,2,180);
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"V", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"I", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"T", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(10), (uint8_t *)"E", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(11), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(12), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(13), (uint8_t *)"E", RIGHT_MODE);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    vol_y=y;
+    lcd.FillRect(190,vol_y-15,20,30);  
+    if(y>999){ y=y/10; }
+    int valeur=((274.0-y)/(274.0-83))*99;
+    uint8_t text[7];
+    sprintf((char*)text, "%d  ", valeur);
+        lcd.DisplayStringAt(0, LINE(4), (uint8_t *)&text, RIGHT_MODE);  
+    lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"% ", RIGHT_MODE); 
+    
+    
+    x=0;
+    y=0; }
+                
+
+void depart(){
+    lcd.Clear(LCD_COLOR_TRANSPARENT);
+    lcd.SetBackColor(LCD_COLOR_TRANSPARENT);
+    lcd.SetTextColor(LCD_COLOR_RED); 
+    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"3", CENTER_MODE);  
+    wait(1);
+    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"2", CENTER_MODE);  
+    wait(1);
+    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"1", CENTER_MODE);  
+    wait(1);
+    lcd.DisplayStringAt(0, LINE(2), (uint8_t *)"EN MARCHE", CENTER_MODE);  
+    
+    lcd.SetBackColor(LCD_COLOR_RED);
+    lcd.FillCircle(120, 180-20, 100);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.DisplayStringAt(0, 170-20, (uint8_t *)"STOP", CENTER_MODE);  
+    wait(0.5);
+    indice_depart=true; 
+    x=0;
+    y=0;  }
+        
+        
+void stop(){
+     lcd.Clear(LCD_COLOR_WHITE);
+         
+     lcd.SetBackColor(LCD_COLOR_RED);
+     lcd.SetTextColor(LCD_COLOR_WHITE); 
+     lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Turbo Poparcalex2", CENTER_MODE);
+         
+        //modes 
+      lcd.SetTextColor(LCD_COLOR_RED);
+      lcd.FillEllipse(65, 118, 45, 15);
+      lcd.SetTextColor(LCD_COLOR_WHITE);
+      lcd.DisplayStringAt(45, LINE(7), (uint8_t *)"Mode", LEFT_MODE);
+      
+        //vitesse
+      lcd.SetTextColor(LCD_COLOR_RED); 
+      lcd.FillRect(200,80,2,180);
+      lcd.SetTextColor(LCD_COLOR_BLACK); 
+      lcd.FillRect(190,vol_y-15,20,30);
+      lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_BLACK); 
+    lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"V", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(8), (uint8_t *)"I", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(9), (uint8_t *)"T", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(10), (uint8_t *)"E", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(11), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(12), (uint8_t *)"S", RIGHT_MODE);
+    lcd.DisplayStringAt(0, LINE(13), (uint8_t *)"E", RIGHT_MODE);
+    
+    //Calibrage
+    lcd.SetTextColor(LCD_COLOR_BLUE);
+    lcd.FillRect(18,57,104,30);
+    lcd.SetTextColor(LCD_COLOR_WHITE); 
+    lcd.SetBackColor(LCD_COLOR_BLUE);
+    lcd.DisplayStringAt(20,67,(uint8_t *)"Calibrage",LEFT_MODE);
+    
+         
+         //depart
+       lcd.SetTextColor(LCD_COLOR_BLACK);
+       lcd.FillEllipse(115, 292, 58, 23);
+       lcd.SetTextColor(LCD_COLOR_GREEN);
+       lcd.FillEllipse(115, 292, 55, 20); 
+       lcd.SetBackColor(LCD_COLOR_GREEN);
+       lcd.SetTextColor(LCD_COLOR_BLACK);
+       lcd.DisplayStringAt(0, LINE(18), (uint8_t *)"Depart", CENTER_MODE);    
+         
+       if(var_manuel==true){
+            manuel();}
+            
+       else if(var_automatique==true){
+            automatique();}
+       
+       else{ 
+            lcd.SetTextColor(LCD_COLOR_RED);
+            lcd.FillRect(20, 180-35, 90, 40);    //Rectangle manuel
+            lcd.FillRect(5, 230-35, 135, 40);    //Rectangle automatique
+             
+            lcd.SetBackColor(LCD_COLOR_RED);
+            lcd.SetTextColor(LCD_COLOR_WHITE);  
+    
+            lcd.DisplayStringAt(35, LINE(10), (uint8_t *)"Manuel", LEFT_MODE);
+            lcd.DisplayStringAt(15, LINE(13), (uint8_t *)"Automatique", LEFT_MODE);}
+        indice_depart=false;
+        x=0;
+        y=0;   }
+
+
+void detection(){
+     x = tsState.X;
+        y = tsState.Y;
+        uint8_t text[7];
+        sprintf((char*)text, "%d; %d", x, y);
+        lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);   }
+
+
+
+
+
+int main()
+{      //screen_init();
+    if(test==false){
+        initialisation();}
+    while(1){
+        
+    uint8_t status= ts.Init(lcd.GetXSize(), lcd.GetYSize());
+    
+        if(status != TS_OK){ erreur(); }
+
+        ts.GetState(&tsState);   
+        if(tsState.TouchDetected){
+            detection();  }
+    
+    
+        if((x<113 && x>13) && (y>189-35 && y<222-35) && indice_depart==false){
+            manuel();}
+       
+        if((x<144 && x>2) && (y>240-35 && y<275-35) && indice_depart==false){
+            automatique();}
+       
+        if((x<217 && x>193) && (y>81 && y<265) && indice_depart==false){
+            vitesse();}
+    
+        if((x<182 && x>59) && (y>273 && y<318) && indice_depart==false){
+            depart();
+            
+            if(var_automatique==true){
+                    recup_vitesse(vol_y);
+                    go_automatique();}
+          //  else if(var_manuel==true){
+          //          test=go_manuel();}}
+            stop(); }
+        
+     /*   if((x<225 && x>12) && (y>78-20 && y<288-20) && indice_depart==true){
+            stop();}
+    */
+    
+    
+    
+        if((x<125 && x>10 ) && (y>61  && y<88) && indice_depart==false){
+             calibrage();
+             stop();}
+    
+    
+        wait(0.05);
+    
+    
+    
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screen.cpp	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,77 @@
+#include "screen.h"
+/**
+ * @brief global object for touchscreen events
+*/
+TS_StateTypeDef TS_State;
+
+/**
+* @fn void screen_init()
+* @brief the screen_init function checks if the LCD Touch screen is ready to use
+* @return nothing
+*/
+void screen_init()
+{
+    BSP_LCD_SetFont(&Font20);
+    BSP_LCD_Init(); // Initializes the LCD
+    BSP_LCD_LayerDefaultInit(0, (uint32_t) LCD_FRAME_BUFFER); // Initializes the LCD layers.*/
+    BSP_LCD_SelectLayer(0); // Selects the LCD Layer
+    BSP_LCD_SetLayerVisible(1, ENABLE); // Sets a LCD Layer visible
+    BSP_LCD_Clear(LCD_COLOR_BLACK);
+    BSP_LCD_DisplayOn();
+    uint8_t status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
+    if (status != TS_OK)
+    {
+      BSP_LCD_Clear(LCD_COLOR_RED);
+      BSP_LCD_SetBackColor(LCD_COLOR_RED);
+      BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+      BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE);
+    }
+    else
+    {
+      BSP_LCD_Clear(LCD_COLOR_GREEN);
+      BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
+      BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+      BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE);
+      BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"INIT OK", CENTER_MODE);
+    }
+}
+
+/**
+ * @fn int isScreenTouched(void)
+ * @brief questions whether the screen is touched or not
+ * @return 1 if touched, 0 otherwise
+**/
+int isScreenTouched(){
+    BSP_TS_GetState(&TS_State);
+    if (TS_State.TouchDetected) {
+        return 1;
+    }
+    return 0;
+}
+
+/**
+* @fn void clearScreen()
+* @brief the clearScreen function clears the screen and set a green background
+* @return nothing
+*/
+void clearScreen(){
+   BSP_LCD_Clear(LCD_COLOR_GREEN);
+}
+
+/**
+* @fn void showIntegerScreen(int x, int nbline, int offset, Text_AlignModeTypdef mode)
+* @brief the clearScreen function clears the screen and set a green background
+* @param x: the integer to print on the LCD screen
+* @param nbline: the line in which the number is to be printed
+* @param offset: the offset with which the number is to be printed
+* @param mode: the align mode
+* @return nothing
+*/
+void showIntegerScreen(int x, int nbline, int offset, Text_AlignModeTypdef mode){
+    TEXT t;
+    sprintf((char *)t, "x=%d", x);
+    BSP_LCD_DisplayStringAt(offset,LINE(nbline),(uint8_t*)"                              ",mode); //clears the line.
+    BSP_LCD_DisplayStringAt(offset,LINE(nbline),(uint8_t*)&t,mode);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screen.h	Thu May 31 06:11:25 2018 +0000
@@ -0,0 +1,10 @@
+#include "stm32f429i_discovery_lcd.h"
+#include "stm32f429i_discovery_ts.h"
+#include "mbed.h"
+
+typedef uint8_t TEXT[30];
+
+void screen_init();
+int isScreenTouched();
+void clearScreen();
+void showIntegerScreen(int x, int nbline, int offset, Text_AlignModeTypdef mode);
\ No newline at end of file