code de la carte IHM avant les bugs et avant le travail effectué avec Melchior

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Revision:
22:c7763a7ec6c7
Parent:
21:d137ec53c3a9
Child:
24:1a13c998c7ac
--- 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