code avec modifs, programme mit dans les robots pour les derniers matchs

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Files at this revision

API Documentation at this revision

Comitter:
gabrieltetar
Date:
Fri Jun 26 13:08:54 2020 +0000
Parent:
21:d137ec53c3a9
Child:
24:1a13c998c7ac
Commit message:
IHM VERSION TETAR

Changed in this revision

Globals/global.h Show annotated file Show diff for this revision Revisions of this file
IHM/ihm.cpp Show annotated file Show diff for this revision Revisions of this file
IHM/ihm.h Show annotated file Show diff for this revision Revisions of this file
Instruction/lecture_repertoire.cpp Show annotated file Show diff for this revision Revisions of this file
Strategie/Strategie.cpp Show annotated file Show diff for this revision Revisions of this file
Strategie/Strategie.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
--- a/Globals/global.h	Wed Jun 24 09:39:42 2020 +0000
+++ b/Globals/global.h	Fri Jun 26 13:08:54 2020 +0000
@@ -36,7 +36,8 @@
 extern char PATH[10][SIZE+8];
 
 extern signed char nbStrat;
-extern unsigned short flag_check_carte;
+extern unsigned short flag_check_carte1;
+extern unsigned short flag_check_carte2;
 extern int ack_bluetooth;
 extern unsigned char Cote;
 extern DigitalOut led1,led2,led3,led4;
--- a/IHM/ihm.cpp	Wed Jun 24 09:39:42 2020 +0000
+++ b/IHM/ihm.cpp	Fri Jun 26 13:08:54 2020 +0000
@@ -1,6 +1,7 @@
 #include "global.h"
 
 #define VERT 0xFF00FF00
+#define VERT_F 0xFF00C400
 #define ROUGE 0xFFFF0000
 #define BLEU 0xFF0000FF
 #define JAUNE 0xFFFDD835//FEFE00
@@ -30,23 +31,27 @@
 Button TEST_COUL(0,245,400,100,"Test capteurs couleur");
 Button TEST_BRAS(0,355,400,100,"Test Bras");
 Button TEST_AUDIO(0,465,400,100,"Test Audio");
-Button TEST_ELECTRV(0,575,400,100,"Test Divers");
+
+Button TEST_NEXT(0,575,400,100,"------>");
+Button TEST_DIV(0,25,400,100,"Test Divers");
+Button TEST_ASSERV(0, 135, 400, 100, "Test asserv");
 //menu demo/demo/
 Button TEST_A(0,25,195,100,"A");
 Button TEST_B(205,25,195,100,"B");
 Button TEST_C(0,135,195,100,"C");
 Button TEST_D(205,135,195,100,"D");
-Button TEST_NUM(0,245,400,100,"Bras num");
+Button TEST_NUM(0,245,400,100,"Num");
 Button TEST_PLUS(205,355,195,100,"+");
 Button TEST_MOINS(0,355,195,100,"-");
-
-
-Button FORCE_LAUNCH(0, 50, 400, 320, "Force Launch");
+Button FORCE_LAUNCH(0, 600, 400, 100, "Force Launch");
 Button SUIVANT(0,380,200,100,"Suivant");
 ////////////////////////////////////////////////////////////
-
+unsigned char flag_sd =0;
 signed char Bouton_Strat (void);
-
+void DrawC (int l,int h,int x, int y, unsigned char fill);
+void DrawR (int l,int h,int x, int y, unsigned char fill);
+void DrawA (int l,int h,int x, int y, unsigned char fill);
+void DrawCheck (int l,int h,int x, int y, int cochage);
 void SelectionStrat (unsigned char numeroStrat);
 
 /****************************************************************************************/
@@ -64,41 +69,22 @@
     }
     ts.GetState(&TS_State);
     switch (strat_etat_s) {
-        case INIT : //intialise l'écran et passe à l'attente d'initialisation des cartes
+        case INIT :
             ts.GetState(&TS_State);
-            canProcessRx();
-            lcd.SetBackColor(LCD_COLOR_WHITE);
-            lcd.SetTextColor(LCD_COLOR_BLACK);
-            lcd.Clear (LCD_COLOR_WHITE);
             wait(0.15);
-            lcd.DisplayStringAt(0, 10, (uint8_t *)"Verification des cartes", LEFT_MODE);
-            //cartes non verifiées////////////////
-            lcd.SetTextColor(DIY_GREY);
-            lcd.FillRect(0,400,400,150); //carte moteur
-            lcd.FillRect(0,600,400,150); //Balise
-            lcd.SetTextColor(LCD_COLOR_BLACK);
-            lcd.SetBackColor(DIY_GREY);
-            lcd.DisplayStringAt(80, 450, (uint8_t *)"Carte Moteur", LEFT_MODE);
-            lcd.DisplayStringAt(110,650, (uint8_t *)"Balise", LEFT_MODE);
-            ////////////////////////////////////////
-            FORCE_LAUNCH.Draw(0xFFFF0000, 0);
-
-            strat_etat_s=ATT;
+            strat_etat_s=INIT2;
             break;
-
-        case ATT :  //Si les cartes sont présentes passe directement à choix sinon attente de force Launch (cette partie est encore buggée mais les cartes affichent bien leur présence donc faut juste force launch tout le temps...)
-            if (flag_check_carte==1) {
-                strat_etat_s = CHOIX;
-                gameEtat = ETAT_CONFIG;
-            } else if (FORCE_LAUNCH.Touched()) {
-                strat_etat_s = CHOIX;
-                gameEtat = ETAT_CONFIG;
-                while(FORCE_LAUNCH.Touched());
+        case INIT2 :
+            canProcessRx();
+            FORCE_LAUNCH.Draw(BLEU, 0);
+            while(strat_etat_s == INIT2) {
+                canProcessRx();
+                if(FORCE_LAUNCH.Touched() || (flag_check_carte1 && flag_check_carte2 && flag_sd)) {
+                    strat_etat_s = CHOIX;
+                    while(FORCE_LAUNCH.Touched());
+                }
             }
-
             break;
-
-
         case CHOIX :    //Match ou DEMO
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
@@ -125,14 +111,14 @@
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
             lcd.Clear (LCD_COLOR_WHITE);
-            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO", LEFT_MODE);
+            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO 1/2", LEFT_MODE);
             RETOUR.Draw(0xFFFF0000, 0);
             TEST_VENT.Draw(VERT, 0);
             TEST_MOT.Draw(VERT, 0);
             TEST_COUL.Draw(VERT, 0);
             TEST_BRAS.Draw(VERT, 0);
             TEST_AUDIO.Draw(VERT, 0);
-            TEST_ELECTRV.Draw(VERT, 0);
+            TEST_NEXT.Draw(BLEU, 0);
             maximilien=0;
             while (strat_etat_s == DEMO) {
                 canProcessRx();
@@ -142,9 +128,9 @@
                 } else if(TEST_MOT.Touched()) {
                     while(TEST_MOT.Touched());
                     strat_etat_s = TEST_MOTEUR;
-                } else if(TEST_ELECTRV.Touched()) {
-                    while(TEST_ELECTRV.Touched());
-                    strat_etat_s = TEST_ELECTROV;
+                } else if(TEST_NEXT.Touched()) {
+                    while(TEST_NEXT.Touched());
+                    strat_etat_s = DEMO2;
                 } else if (TEST_COUL.Touched()) {
                     while(TEST_COUL.Touched());
                     strat_etat_s =TEST_COULEUR ;
@@ -160,7 +146,34 @@
                 }
             }
             break;
-
+            
+            case DEMO2 :
+            lcd.SetBackColor(LCD_COLOR_WHITE);
+            lcd.SetTextColor(LCD_COLOR_BLACK);
+            lcd.Clear (LCD_COLOR_WHITE);
+            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO 2/2", LEFT_MODE);
+            RETOUR.Draw(0xFFFF0000, 0);
+            TEST_DIV.Draw(VERT, 0);
+            TEST_ASSERV.Draw(VERT, 0);
+            TEST_NEXT.Draw(BLEU, 0);
+            maximilien=0;
+            while (strat_etat_s == DEMO2) {
+                canProcessRx();
+                if(TEST_NEXT.Touched()) {
+                    while(TEST_NEXT.Touched());
+                    strat_etat_s = DEMO;
+                } else if(TEST_DIV.Touched()) {
+                    while(TEST_DIV.Touched());
+                    strat_etat_s = TEST_DIVE;
+                } else if(TEST_ASSERV.Touched()) {
+                    while(TEST_ASSERV.Touched());
+                    strat_etat_s = TEST_ASSERVE;
+                } else if(RETOUR.Touched()) {
+                    while(RETOUR.Touched());
+                    strat_etat_s = CHOIX;
+                }
+            }
+            break;
 
         case TEST_VENTOUSE:   
             lcd.SetBackColor(LCD_COLOR_WHITE);
@@ -226,7 +239,7 @@
             }
             break;
         
-        case TEST_ELECTROV:
+        case TEST_DIVE:
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
             lcd.Clear (LCD_COLOR_WHITE);   
@@ -235,10 +248,10 @@
             RETOUR.Draw(0xFFFF0000,0);
             TEST_A.Draw(BLEU, BLANC);
             TEST_B.Draw(BLEU, BLANC);
-            while(strat_etat_s==TEST_ELECTROV) {
+            while(strat_etat_s==TEST_DIVE) {
                 if(RETOUR.Touched()) {
                     while (RETOUR.Touched());
-                    strat_etat_s=DEMO;
+                    strat_etat_s=DEMO2;
                 } else if(TEST_A.Touched()) {
                     while (TEST_A.Touched());
                     //SendRawId(TEST_ELECTROV_A);
@@ -250,7 +263,30 @@
                 }  
             }
             break;
-            
+        case TEST_ASSERVE:
+            lcd.SetBackColor(LCD_COLOR_WHITE);
+            lcd.SetTextColor(LCD_COLOR_BLACK);
+            lcd.Clear (LCD_COLOR_WHITE);   
+            lcd.Clear (LCD_COLOR_WHITE);
+            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Asservissements", LEFT_MODE);
+            RETOUR.Draw(0xFFFF0000,0);
+            TEST_A.Draw(BLEU, BLANC);
+            TEST_B.Draw(BLEU, BLANC);
+            while(strat_etat_s==TEST_ASSERVE) {
+                if(RETOUR.Touched()) {
+                    while (RETOUR.Touched());
+                    strat_etat_s=DEMO2;
+                } else if(TEST_A.Touched()) {
+                    while (TEST_A.Touched());
+                    //SendRawId(TEST_ELECTROV_A);
+                    TEST_A.Draw(BLEU, BLANC);
+                }  else if(TEST_B.Touched()) {
+                    while (TEST_B.Touched());
+                    //SendRawId(TEST_ELECTROV_A);
+                    TEST_B.Draw(BLEU, BLANC);
+                }  
+            }
+            break; 
         case TEST_AUD:  
               
             lcd.SetBackColor(LCD_COLOR_WHITE);
@@ -425,6 +461,7 @@
             while (strat_etat_s == SELECT_SIDE) {
                 canProcessRx();
                 if(COTE_JAUNE.Touched()) {
+                    
                     Cote = 0x0;
                     InversStrat = Cote;
                     strat_etat_s = TACTIQUE;
@@ -738,4 +775,85 @@
             lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
             break;
     }
+}
+void demarrage(unsigned char num){
+    switch(num){
+        case 0:
+        lcd.SetBackColor(DIY_GREY);
+        lcd.SetTextColor(NOIR);
+        lcd.Clear (DIY_GREY);
+        DrawC(95,150,0,50,0);
+        DrawR(95,150,105,50,0);
+        DrawA(95,150,210,50,0);
+        DrawC(95,150,315,50,0);
+        DrawCheck(30,30,50,243,0);
+        DrawCheck(30,30,50,293,0);
+        DrawCheck(30,30,50,343,0);
+        DrawCheck(30,30,50,393,0);
+        lcd.DisplayStringAt(100, 250, (uint8_t *)"Init CAN", LEFT_MODE);
+        lcd.DisplayStringAt(100, 300, (uint8_t *)"Micro SD", LEFT_MODE);
+        lcd.DisplayStringAt(100, 350, (uint8_t *)"Carte Moteur", LEFT_MODE);
+        lcd.DisplayStringAt(100, 400, (uint8_t *)"Balise IR", LEFT_MODE);
+        break;
+        case 1://can
+        DrawCheck(30,30,50,250,1);
+        break;
+        case 2://SD
+        DrawCheck(30,30,50,300,1);
+        flag_sd=1;
+        break;
+        case 3://moteur
+        DrawCheck(30,30,50,350,1);
+        break;
+        case 4://balise
+        DrawCheck(30,30,50,400,1);
+        break;
+        default:
+        break;
+}
+}
+void DrawC (int l,int h,int x, int y, unsigned char fill){
+    Point c[8]={{l,0},{l,h/6},{l/5,h/3},{l/5,2*(h/3)},{l,5*(h/6)},{l,h},{0,5*(h/6)},{0,h/6}};
+    for(int a=0;a<8;a++){
+        c[a].X+=x;
+        c[a].Y+=y;
+    }
+    lcd.DrawPolygon(c, 8);
+    
+}
+void DrawR (int l,int h,int x, int y, unsigned char fill){
+    Point r[10]={{0,0},{5*(l/6),0},{l,h/3},{5*(l/6),h/2},{l/2,h/2},{l,h},{2*(l/3),h},{l/4,h/2},{l/4,h},{0,h}};
+    for(int a=0;a<10;a++){
+        r[a].X+=x;
+        r[a].Y+=y;
+    }
+    lcd.DrawPolygon(r, 10);
+}
+void DrawA (int l,int h,int x, int y, unsigned char fill){
+    Point a[8]={{l/4,0},{3*(l/4),0},{l,h},{5*(l/6),h},{4*(l/6),h/2},{2*(l/6),h/2},{l/6,h},{0,h}};
+    for(int z=0;z<8;z++){
+        a[z].X+=x;
+        a[z].Y+=y;
+    }
+    lcd.DrawPolygon(a, 8);
+}
+void DrawCheck (int l,int h,int x, int y, int cochage){
+    if(x<3)x=3;
+    if(cochage == 1){
+        lcd.SetTextColor(VERT_F);
+        lcd.DrawLine(x,y-(h/2),x+l/2,y+h/2);
+        lcd.DrawLine(x-1,y-(h/2),x+l/2,y+h/2+1);
+        lcd.DrawLine(x-2,y-(h/2),x+l/2,y+h/2+2);
+        lcd.DrawLine(x+l/2,y+h/2,x+(4*(l/3)),y);
+        lcd.DrawLine(x+l/2,y+h/2+1,x+(4*(l/3))+1,y);
+        lcd.DrawLine(x+l/2,y+h/2+2,x+(4*(l/3))+2,y);
+        lcd.SetTextColor(NOIR);
+    } else {
+        Point a[4]={{0,0},{l,0},{l,h},{0,h}};
+        for(int z=0;z<8;z++){
+            a[z].X+=x;
+            a[z].Y+=y;
+        }
+        lcd.DrawPolygon(a, 4);
+    }
 }
\ No newline at end of file
--- a/IHM/ihm.h	Wed Jun 24 09:39:42 2020 +0000
+++ b/IHM/ihm.h	Fri Jun 26 13:08:54 2020 +0000
@@ -2,5 +2,5 @@
 #define CRAC_IHM
 
 void automate_etat_ihm(void);
-
+void demarrage(unsigned char num);
 #endif
\ No newline at end of file
--- a/Instruction/lecture_repertoire.cpp	Wed Jun 24 09:39:42 2020 +0000
+++ b/Instruction/lecture_repertoire.cpp	Fri Jun 26 13:08:54 2020 +0000
@@ -10,10 +10,10 @@
 
     DIR* rep = NULL;
 
-    mkdir("/sd", 0777);
+    if(mkdir("/sd", 0777)==0){//0 SUCCES -1 ECHEC
     strcpy(cheminFileStart,"/sd");
     rep=opendir("/sd");
-    
+    demarrage(2);
     for(i=0;i<20;i++){
         files_name[i]= readdir(rep);  
                 
@@ -34,5 +34,6 @@
             
         }
     }
+    }
 }
         
--- a/Strategie/Strategie.cpp	Wed Jun 24 09:39:42 2020 +0000
+++ b/Strategie/Strategie.cpp	Fri Jun 26 13:08:54 2020 +0000
@@ -37,7 +37,7 @@
 unsigned short x;
 unsigned short y;
 unsigned char isStopEnable = 1;//Permet de savoir si il faut autoriser le stop via les balises
-unsigned short flag_check_carte = 0, flag_strat = 0, flag_timer;
+unsigned short flag_check_carte1 = 0,flag_check_carte2 = 0, flag_strat = 0, flag_timer;
 int flagReceptionTelemetres = 0, flagNonRepriseErrorMot = 0;
 
 
@@ -199,7 +199,7 @@
                     if(countAliveCard >= NOMBRE_CARTES) {
                         gameEtat = ETAT_CONFIG;
                         SendRawId(ECRAN_ALL_CHECK);
-                        flag_check_carte=1;
+                        flag_check_carte1=1;
 
                         //tactile_printf("Selection couleur et strategie");
                     } else {
@@ -218,7 +218,7 @@
                     if(checkCurrent >= NOMBRE_CARTES) {
                         if(countAliveCard == NOMBRE_CARTES) {
                             gameEtat = ETAT_CONFIG;
-                            flag_check_carte=1;
+                            flag_check_carte1=1;
                         } else {
                             gameEtat = ETAT_WAIT_FORCE;
                             waitingAckFrom = ECRAN_ALL_CHECK;
@@ -963,25 +963,15 @@
         switch(identifiant) {
 
             case ALIVE_MOTEUR:
-                if (strat_etat_s == ATT) {
-
-                    lcd.SetTextColor(LCD_COLOR_LIGHTGREEN);
-                    lcd.FillRect(0,400,400,150);
-                    lcd.SetTextColor(LCD_COLOR_BLACK);
-                    lcd.SetBackColor(LCD_COLOR_LIGHTGREEN);
-                    lcd.DisplayStringAt(80, 450, (uint8_t *)"Carte Moteur", LEFT_MODE);
-                }
+                if (strat_etat_s == INIT2)
+                    demarrage(3);
+                flag_check_carte1=1;
                 break;
 
             case ALIVE_BALISE:
-                if (strat_etat_s == ATT) {
-
-                    lcd.SetTextColor(LCD_COLOR_LIGHTGREEN);
-                    lcd.FillRect(0,600,400,150); //carte AX12
-                    lcd.SetTextColor(LCD_COLOR_BLACK);
-                    lcd.SetBackColor(LCD_COLOR_LIGHTGREEN);
-                    lcd.DisplayStringAt(110, 650, (uint8_t *)"Balise", LEFT_MODE);
-                }
+                if (strat_etat_s == INIT2)
+                    demarrage(4);
+                flag_check_carte2=1;
                 break;
 
             case RESET_IHM:
@@ -1003,7 +993,7 @@
                 if(waitingAckFrom == msgRxBuffer[FIFO_lecture].id) {
                     waitingAckFrom = 0;//C'est la bonne carte qui indique qu'elle est en ligne
                 }
-                flag_check_carte=1;
+                flag_check_carte1=1;
                 break;
 
             case ASSERVISSEMENT_ERROR_MOTEUR://erreur asservissement
--- a/Strategie/Strategie.h	Wed Jun 24 09:39:42 2020 +0000
+++ b/Strategie/Strategie.h	Fri Jun 26 13:08:54 2020 +0000
@@ -13,15 +13,17 @@
 }E_Stratposdebut;
     
 typedef enum {
-    INIT, 
-    ATT, 
+    INIT,
+    INIT2,
     CHOIX, 
-    DEMO, 
+    DEMO,
+    DEMO2, 
     TEST_MOTEUR, 
     TEST_COULEUR, 
     TEST_SERVO_BRAS, 
     TEST_VENTOUSE, 
-    TEST_ELECTROV,
+    TEST_DIVE,
+    TEST_ASSERVE,
     TEST_AUD, 
     SELECT_SIDE, 
     TACTIQUE, 
--- a/main.cpp	Wed Jun 24 09:39:42 2020 +0000
+++ b/main.cpp	Fri Jun 26 13:08:54 2020 +0000
@@ -40,10 +40,11 @@
 /* DESCRIPTION  : Fonction principal du programme                                 */
 /**********************************************************************************/
 int main() {
+    demarrage(0);
     can1.frequency(1000000); // fréquence de travail 1Mbit/s
     can2.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
     can2.frequency(1000000);
-    lcd.DisplayStringAt(0, 0,(uint8_t *)"Initialisation", LEFT_MODE);
+    demarrage(1);
     led1 = 1;
     lecture_fichier(); //bloquant si pas de carte SD
     led1 = 0;