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:
38:9d6a3ccc0582
Parent:
36:c37dbe2be916
--- a/IHM/ihm.cpp	Mon May 31 13:36:03 2021 +0000
+++ b/IHM/ihm.cpp	Sat Jul 17 11:07:17 2021 +0000
@@ -40,6 +40,10 @@
 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");
+Button TEST_MANCHE(0,245,400,100,"Test manches a air");
+Button TEST_GIROU(0,355,400,100,"Test capteur girouette");
+
+
 //menu demo/demo/
 Button TEST_A(0,25,195,100,"A");
 Button TEST_B(205,25,195,100,"B");
@@ -51,19 +55,19 @@
 
 Button TEST_PLUS(205,355,195,100,"+");
 Button TEST_MOINS(0,355,195,100,"-");
-Button TEST_SERVO_0(280,50,120,100,"Bras 0");
-Button TEST_SERVO_1(140,50,120,100,"Bras 1");
-Button TEST_SERVO_2(0,50,120,100,"Bras 2");
-Button TEST_SERVO_3(0,160,120,100,"Bras 3");
-Button TEST_SERVO_4(140,160,120,100,"Bras 4");
-Button TEST_SERVO_5(280,160,120,100,"Bras 5");
+Button TEST_SERVO_0(0,160,120,100,"Bras 0");
+Button TEST_SERVO_1(140,160,120,100,"Bras 1");
+Button TEST_SERVO_2(280,160,120,100,"Bras 2");
+Button TEST_SERVO_3(280,50,120,100,"Bras 3");
+Button TEST_SERVO_4(140,50,120,100,"Bras 4");
+Button TEST_SERVO_5(0,50,120,100,"Bras 5");
 
-Button TEST_VENT_0(280,50,120,100,"Vent 0");
-Button TEST_VENT_1(140,50,120,100,"Vent 1");
-Button TEST_VENT_2(0,50,120,100,"Vent 2");
-Button TEST_VENT_3(0,160,120,100,"Vent 3");
-Button TEST_VENT_4(140,160,120,100,"Vent 4");
-Button TEST_VENT_5(280,160,120,100,"Vent 5");
+Button TEST_VENT_0(0,160,120,100,"Vent 0");
+Button TEST_VENT_1(140,160,120,100,"Vent 1");
+Button TEST_VENT_2(280,160,120,100,"Vent 2");
+Button TEST_VENT_3(280,50,120,100,"Vent 3");
+Button TEST_VENT_4(140,50,120,100,"Vent 4");
+Button TEST_VENT_5(0,50,120,100,"Vent 5");
 
 Button FORCE_LAUNCH(0, 600, 400, 100, "Force Launch");
 Button SUIVANT(0,380,200,100,"Suivant");
@@ -81,7 +85,7 @@
 /* DESCRIPTION  : Automate de gestion de l'affichage                                    */
 /****************************************************************************************/
 void automate_etat_ihm(void)
-{
+{            
     char toto[12]; 
     int j, old_time=0, actual_time=0, old_score=0, actual_score=0, unique=0;
     unsigned char maximilien=1, choix_groupe;
@@ -167,25 +171,38 @@
             maximilien=0;
             while (strat_etat_s == DEMO) {
                 canProcessRx();
-                if(TEST_VENT.Touched()) {
+                if(TEST_VENT.Touched()) 
+                {
                     while(TEST_VENT.Touched());
                     strat_etat_s = TEST_VENTOUSE;
-                } else if(TEST_MOT.Touched()) {
+                } 
+                else if(TEST_MOT.Touched()) 
+                {
                     while(TEST_MOT.Touched());
                     strat_etat_s = TEST_MOTEUR;
-                } else if(TEST_NEXT.Touched()) {
+                } 
+                else if(TEST_NEXT.Touched()) 
+                {
                     while(TEST_NEXT.Touched());
                     strat_etat_s = DEMO2;
-                } else if (TEST_COUL.Touched()) {
+                } 
+                else if (TEST_COUL.Touched()) 
+                {
                     while(TEST_COUL.Touched());
                     strat_etat_s =TEST_COULEUR ;
-                } else if (TEST_BRAS.Touched()) {
+                } 
+                else if (TEST_BRAS.Touched()) 
+                {
                     while(TEST_BRAS.Touched());
                     strat_etat_s =TEST_SERVO_BRAS ;
-                } else if(TEST_AUDIO.Touched()) {
+                } 
+                else if(TEST_AUDIO.Touched()) 
+                {
                     while(TEST_AUDIO.Touched());
                     strat_etat_s=TEST_AUD;
-                } else if(RETOUR.Touched()) {
+                } 
+                else if(RETOUR.Touched()) 
+                {
                     while(RETOUR.Touched());
                     strat_etat_s = CHOIX;
                 }
@@ -200,26 +217,119 @@
             RETOUR.Draw(0xFFFF0000, 0);
             TEST_DIV.Draw(VERT, 0);
             TEST_ASSERV.Draw(VERT, 0);
+            TEST_MANCHE.Draw(VERT, 0);
+            TEST_GIROU.Draw(VERT, 0);
             TEST_NEXT.Draw(BLEU, 0);
             maximilien=0;
             while (strat_etat_s == DEMO2) {
                 canProcessRx();
-                if(TEST_NEXT.Touched()) {
+                if(TEST_NEXT.Touched()) 
+                {
                     while(TEST_NEXT.Touched());
                     strat_etat_s = DEMO;
-                } else if(TEST_DIV.Touched()) {
+                } 
+                else if(TEST_DIV.Touched()) 
+                {
                     while(TEST_DIV.Touched());
                     strat_etat_s = TEST_DIVE;
-                } else if(TEST_ASSERV.Touched()) {
+                } 
+                else if(TEST_ASSERV.Touched()) 
+                {
                     while(TEST_ASSERV.Touched());
                     strat_etat_s = TEST_ASSERVE;
-                } else if(RETOUR.Touched()) {
+                } 
+                else if(TEST_MANCHE.Touched()) 
+                {
+                    while(TEST_MANCHE.Touched());
+                    strat_etat_s = TEST_MANCHES;
+                }
+                else if(TEST_GIROU.Touched()) 
+                {
+                    while(TEST_GIROU.Touched());
+                    strat_etat_s = TEST_GIROUS;
+                }
+                
+                else if(RETOUR.Touched()) 
+                {
                     while(RETOUR.Touched());
                     strat_etat_s = CHOIX;
                 }
             }
         break;
         
+        case TEST_MANCHES:
+            lcd.SetBackColor(LCD_COLOR_WHITE);
+            lcd.SetTextColor(LCD_COLOR_BLACK);
+            lcd.Clear (LCD_COLOR_WHITE);
+            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Manches a air", LEFT_MODE);
+            
+            RETOUR.Draw(0xFFFF0000,0);
+            TEST_A.Draw(BLEU, BLANC);
+            TEST_B.Draw(BLEU, BLANC);   
+            TEST_C.Draw(BLEU, BLANC);  
+            TEST_D.Draw(BLEU, BLANC) ;
+            
+            while(strat_etat_s==TEST_MANCHES) 
+            {
+                if(RETOUR.Touched()) 
+                {
+                    while (RETOUR.Touched());
+                    strat_etat_s=DEMO2;
+                }
+                else if(TEST_A.Touched()) 
+                {
+                    while (TEST_A.Touched());
+                    TEST_A.Draw(BLEU, BLANC);
+                    SendRawId(TEST_BRAS_1);
+                }  
+                else if(TEST_B.Touched()) 
+                {
+                    while (TEST_B.Touched());
+                    TEST_B.Draw(BLEU, BLANC); 
+                    choix_groupe = 0;
+                    SendMsgCan(AUTOMATE_MANCHE_MOY, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                    SendMsgCan(AUTOMATE_MANCHE_BAS, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                    SendMsgCan(AUTOMATE_MANCHE_HAUT, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                    choix_groupe = 1;
+                    SendMsgCan(AUTOMATE_MANCHE_MOY, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                    SendMsgCan(AUTOMATE_MANCHE_BAS, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                    SendMsgCan(AUTOMATE_MANCHE_HAUT, &choix_groupe, sizeof(choix_groupe)) ;   
+                    wait_ms(500);
+                }
+                 else if(TEST_C.Touched()) 
+                {
+                    while (TEST_A.Touched());
+                    TEST_C.Draw(BLEU, BLANC);
+                    SendRawId(PAVILLON_DEPLOYE);
+                }  
+                
+            }
+            break;
+                    
+        case TEST_GIROUS :
+            SendRawId(LECTURE_GIROUETTE) ;
+            wait_ms(5); 
+            canProcessRx();
+            lcd.SetBackColor(LCD_COLOR_WHITE);
+            lcd.SetTextColor(LCD_COLOR_BLACK);
+            lcd.Clear (LCD_COLOR_WHITE);
+            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Girouette", LEFT_MODE);
+            sprintf(toto,"%hd",val_girou);
+            lcd.DisplayStringAt(0, LINE(10), (unsigned char *)"Valeur Girou :", LEFT_MODE);
+            lcd.DisplayStringAt(0, LINE(11), (unsigned char *)toto, LEFT_MODE);
+            RETOUR.Draw(0xFFFF0000,0);
+                if(RETOUR.Touched()) {
+                    while (RETOUR.Touched());
+                    strat_etat_s=DEMO2;
+                } 
+            wait_ms(200);
+            break ;
+            
         case TEST_ASSERVE:
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
@@ -231,20 +341,26 @@
             TEST_B.Draw(BLEU, BLANC);                
             TEST_C.Draw(BLEU, BLANC) ;
                 
-            while(strat_etat_s==TEST_ASSERVE) {
-                if(RETOUR.Touched()) {
+            while(strat_etat_s==TEST_ASSERVE) 
+            {
+                if(RETOUR.Touched()) 
+                {
                     while (RETOUR.Touched());
                     strat_etat_s=DEMO2;
-                } else if(TEST_A.Touched()) {
+                } 
+                else if(TEST_A.Touched()) 
+                {
                     while (TEST_A.Touched());
-                    GoToPosition(2000,0,0,0);
+                    GoStraight(2000,0,0,0);
                     TEST_A.Draw(BLEU, BLANC);  
-                }  else if(TEST_B.Touched()) {
+                }  
+                else if(TEST_B.Touched()) 
+                {
                     while (TEST_B.Touched());
-                    Rotate(3599);
+                    Rotate(3600*5);
                     TEST_B.Draw(BLEU, BLANC);
                 }  
-                  else if(TEST_C.Touched()) 
+                else if(TEST_C.Touched()) 
                 {
                     while (TEST_C.Touched());
                     BendRadius(1000,900,1,0);
@@ -868,18 +984,21 @@
                             break ;
                         case 217 :
                             choix_bras = 21 ;
+                            GoStraight(-40, 0, 0, 0);
                             SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras));
                             waitingAckFrom = 0;
                             waitingAckID =0;
                             break ;
                         case 200 :
                             choix_bras = 20 ;
+                            GoStraight(-50, 0, 0, 0);
                             SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras));
                             waitingAckFrom = 0;
                             waitingAckID =0;
                             break ;
                         case 10 :
                             choix_bras = 10 ;
+                            GoStraight(-45, 0, 0, 0);
                             SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras));
                             waitingAckFrom = 0;
                             waitingAckID =0;
@@ -1249,49 +1368,47 @@
                 lcd.DisplayStringAt(100, LINE(8), (unsigned char *)"Score :", LEFT_MODE);
                 lcd.SetTextColor(LCD_COLOR_RED);
                 lcd.DrawRect(0,400,400,320);
-                lcd.DisplayStringAt(100, LINE(22), (unsigned char *)"Timer :", LEFT_MODE);
+                lcd.DisplayStringAt(100, LINE(28), (unsigned char *)"Timer :", LEFT_MODE);
                 unique = 1;
             }
-            int x_offsetc = -145*cos(theta_robot*M_PI/1800) - 0*sin(theta_robot*M_PI*1800);
-            int y_offsetc = -145*sin(theta_robot*M_PI/1800) + 0*cos(theta_robot*M_PI*1800);
+            
             
             lcd.SetTextColor(LCD_COLOR_BLACK);
-            lcd.DisplayStringAt(100, LINE(14), (unsigned char *)"x_robot :", LEFT_MODE);
-            sprintf(toto,"%04d",(short)(x_robot+x_offsetc));
-            lcd.DisplayStringAt(250, LINE(14), (unsigned char *)toto, LEFT_MODE);
             
-            lcd.DisplayStringAt(100, LINE(15), (unsigned char *)"y_robot :", LEFT_MODE);
-            sprintf(toto,"%04d",(short)(y_robot+y_offsetc));
+            lcd.DisplayStringAt(100, LINE(15), (unsigned char *)"girou :", LEFT_MODE);
+            sprintf(toto,"%02d",val_girou);
             lcd.DisplayStringAt(250, LINE(15), (unsigned char *)toto, LEFT_MODE);
             
-            lcd.DisplayStringAt(100, LINE(16), (unsigned char *)"t_robot :", LEFT_MODE);
-            sprintf(toto,"%04d",theta_robot);
+            lcd.DisplayStringAt(100, LINE(16), (unsigned char *)"debug :", LEFT_MODE);
+            sprintf(toto,"%02d",debug_bon_port);
             lcd.DisplayStringAt(250, LINE(16), (unsigned char *)toto, LEFT_MODE);
             
-            lcd.DisplayStringAt(100, LINE(17), (unsigned char *)"g_vert :", LEFT_MODE);
-            sprintf(toto,"%04d",gobelet_vert);
-            lcd.DisplayStringAt(250, LINE(17), (unsigned char *)toto, LEFT_MODE);
             
-            lcd.DisplayStringAt(100, LINE(18), (unsigned char *)"g_rouge :", LEFT_MODE);
+            lcd.DisplayStringAt(100, LINE(10), (unsigned char *)"g_vert :", LEFT_MODE);
+            sprintf(toto,"%04d",gobelet_vert);
+            lcd.DisplayStringAt(250, LINE(10), (unsigned char *)toto, LEFT_MODE);
+            
+            lcd.DisplayStringAt(100, LINE(11), (unsigned char *)"g_rouge :", LEFT_MODE);
             sprintf(toto,"%04d",gobelet_rouge);
-            lcd.DisplayStringAt(250, LINE(18), (unsigned char *)toto, LEFT_MODE);
+            lcd.DisplayStringAt(250, LINE(11), (unsigned char *)toto, LEFT_MODE);
             
-            lcd.DisplayStringAt(100, LINE(19), (unsigned char *)"g_port :", LEFT_MODE);
+            lcd.DisplayStringAt(100, LINE(12), (unsigned char *)"g_port :", LEFT_MODE);
             sprintf(toto,"%04d",gobelet_port);
-            lcd.DisplayStringAt(250, LINE(19), (unsigned char *)toto, LEFT_MODE);
+            lcd.DisplayStringAt(250, LINE(12), (unsigned char *)toto, LEFT_MODE);
             
+    
             actual_time = gameTimer.read();
-            if(actual_time != old_time)
-            {
+//            if(actual_time != old_time)
+//            {
                 lcd.SetTextColor(LCD_COLOR_BLUE);
                 sprintf(toto,"%hd",score_final);
                 lcd.DisplayStringAt(250, LINE(8), (unsigned char *)toto, LEFT_MODE);
                 
                 lcd.SetTextColor(LCD_COLOR_RED);          
                 sprintf(toto,"%hd",actual_time);
-                lcd.DisplayStringAt(250, LINE(22), (unsigned char *)toto, LEFT_MODE);
-                old_time = actual_time;
-            }
+                lcd.DisplayStringAt(250, LINE(28), (unsigned char *)toto, LEFT_MODE);
+//                old_time = actual_time;
+//            }
             break;