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

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Revision:
32:7f8e3ee2adac
Parent:
29:ff575aff301f
Child:
33:c54841d11156
--- a/IHM/ihm.cpp	Mon May 10 09:14:28 2021 +0000
+++ b/IHM/ihm.cpp	Tue May 11 15:02:31 2021 +0000
@@ -41,8 +41,17 @@
 Button TEST_C(0,135,195,100,"C");
 Button TEST_D(205,135,195,100,"D");
 Button TEST_NUM(0,245,400,100,"Num");
+Button TEST_ATTRAPER(0,300,400,100,"Attraper");
+Button TEST_RELACHER(0,450,400,100,"Relacher");
+
 Button TEST_PLUS(205,355,195,100,"+");
 Button TEST_MOINS(0,355,195,100,"-");
+Button TEST_SERVO_0(0,50,120,100,"Bras 0");
+Button TEST_SERVO_1(140,50,120,100,"Bras 1");
+Button TEST_SERVO_2(280,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 FORCE_LAUNCH(0, 600, 400, 100, "Force Launch");
 Button SUIVANT(0,380,200,100,"Suivant");
 ////////////////////////////////////////////////////////////
@@ -60,9 +69,9 @@
 /****************************************************************************************/
 void automate_etat_ihm(void)
 {
-    char toto[2]; 
+    char toto[12]; 
     int j;
-    unsigned char maximilien=1;
+    unsigned char maximilien=1, choix_groupe;
     if (j==0) {
         ts.Init(lcd.GetXSize(), lcd.GetYSize());
         j++;
@@ -274,22 +283,52 @@
                     TEST_NUM.Draw(BLEU, BLANC);
                     switch(maximilien){
                     case 1:
-                    SendRawId(TEST_VENT_1_ON);
+                    choix_groupe = 0 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     case 2:
-                    SendRawId(TEST_VENT_1_OFF);
+                    choix_groupe = 0 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     case 3:
-                    //SendRawId(TEST_VENT_3);
+                    choix_groupe = 1 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     case 4:
-                    //SendRawId(TEST_VENT_4);
+                    choix_groupe = 1 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     case 5:
-                    //SendRawId(TEST_VENT_5);
+                    choix_groupe = 2 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     case 6:
-                    //SendRawId(TEST_VENT_6);
+                    choix_groupe = 2 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 7:
+                    choix_groupe = 3 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 8:
+                    choix_groupe = 3 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 9:
+                    choix_groupe = 4 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 10:
+                    choix_groupe = 4 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 11:
+                    choix_groupe = 5 ;
+                    SendMsgCan(VENT_AT, &choix_groupe, sizeof(choix_groupe)) ;
+                    break;
+                    case 12:
+                    choix_groupe = 5 ;
+                    SendMsgCan(VENT_RE, &choix_groupe, sizeof(choix_groupe)) ;
                     break;
                     }
                 } else if(TEST_PLUS.Touched()) {
@@ -379,7 +418,7 @@
             break;
             
         case TEST_SERVO_BRAS:  
-              
+            char bras_select_0 = 0, bras_select_1 = 0, bras_select_2 = 0, bras_select_3 = 0, bras_select_4 = 0, bras_select_5 = 0 ;
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
             lcd.Clear (LCD_COLOR_WHITE);   
@@ -388,72 +427,108 @@
             sprintf(toto,"%hd",maximilien);
             lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, 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);
-            TEST_NUM.Draw(BLEU, BLANC);
-            TEST_PLUS.Draw(BLEU, BLANC);
-            TEST_MOINS.Draw(BLEU, BLANC);
-            while(strat_etat_s==TEST_SERVO_BRAS) {
-                if(RETOUR.Touched()) {
+            TEST_ATTRAPER.Draw(BLEU, BLANC);
+            TEST_RELACHER.Draw(BLEU, BLANC);
+            TEST_SERVO_0.Draw(BLEU, BLANC);
+            TEST_SERVO_1.Draw(BLEU, BLANC);
+            TEST_SERVO_2.Draw(BLEU, BLANC);
+            TEST_SERVO_3.Draw(BLEU, BLANC);
+            TEST_SERVO_4.Draw(BLEU, BLANC);
+            TEST_SERVO_5.Draw(BLEU, BLANC);
+            while(strat_etat_s==TEST_SERVO_BRAS) 
+            {
+                if(RETOUR.Touched()) 
+                {
                     while (RETOUR.Touched());
                     strat_etat_s=DEMO;
-                } else if(TEST_A.Touched()) {
-                    while (TEST_A.Touched());
-                    SendRawId(TEST_BRAS_A);
-                    TEST_A.Draw(BLEU, BLANC);
-                } else if(TEST_B.Touched()) {
-                    while (TEST_B.Touched());
-                    SendRawId(TEST_BRAS_B);
-                    TEST_B.Draw(BLEU, BLANC);
-                } else if(TEST_C.Touched()) {
-                    while (TEST_C.Touched());
-                    SendRawId(TEST_BRAS_C);
-                    TEST_C.Draw(BLEU, BLANC);
-                } else if(TEST_D.Touched()) {
-                    while (TEST_D.Touched());
-                    SendRawId(TEST_BRAS_D);
-                    TEST_D.Draw(BLEU, BLANC);
-                }  else if(TEST_NUM.Touched()) {
-                    while (TEST_NUM.Touched());
-                    TEST_NUM.Draw(BLEU, BLANC);
-                    switch(maximilien){
-                    case 1:
-                    SendRawId(TEST_BRAS_1);
-                    break;
-                    case 2:
-                    SendRawId(TEST_BRAS_2);
-                    break;
-                    case 3:
-                    SendRawId(TEST_BRAS_3);
-                    break;
-                    case 4:
-                    SendRawId(TEST_BRAS_4);
-                    break;
-                    case 5:
-                    SendRawId(TEST_BRAS_5);
-                    break;
-                    case 6:
-                    SendRawId(TEST_BRAS_6);
-                    break;
+                }  
+                else if(TEST_SERVO_0.Touched()) 
+                {
+                    while (TEST_SERVO_0.Touched());
+                    if(bras_select_0)
+                    {
+                        bras_select_0 = 0 ;
+                        TEST_SERVO_0.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_0 = 1 ;
+                        TEST_SERVO_0.Draw(BLEU, BLANC);
+                    }
+                }
+                else if(TEST_SERVO_1.Touched()) 
+                {
+                    while (TEST_SERVO_1.Touched());
+                    if(bras_select_1)
+                    {
+                        bras_select_1 = 0 ;
+                        TEST_SERVO_1.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_1 = 1 ;
+                        TEST_SERVO_1.Draw(BLEU, BLANC);
+                    }
+                }
+                else if(TEST_SERVO_2.Touched()) 
+                {
+                    while (TEST_SERVO_2.Touched());
+                    if(bras_select_2)
+                    {
+                        bras_select_2 = 0 ;
+                        TEST_SERVO_2.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_2 = 1 ;
+                        TEST_SERVO_2.Draw(BLEU, BLANC);
                     }
-                } else if(TEST_PLUS.Touched()) {
-                    while (TEST_PLUS.Touched());
-                    TEST_PLUS.Draw(BLEU, BLANC);
-                    if(maximilien!=6)maximilien++;
-                    sprintf(toto,"%hd",maximilien);
-                    lcd.SetBackColor(LCD_COLOR_WHITE);
-                    lcd.SetTextColor(LCD_COLOR_BLACK);
-                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
-                } else if(TEST_MOINS.Touched()) {
-                    while (TEST_MOINS.Touched());
-                    TEST_MOINS.Draw(BLEU, BLANC);
-                    if(maximilien!=1)maximilien--;
-                    sprintf(toto,"%hd",maximilien);
-                    lcd.SetBackColor(LCD_COLOR_WHITE);
-                    lcd.SetTextColor(LCD_COLOR_BLACK);
-                    lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
+                }
+                else if(TEST_SERVO_3.Touched()) 
+                {
+                    while (TEST_SERVO_3.Touched());
+                    if(bras_select_3)
+                    {
+                        bras_select_3 = 0 ;
+                        TEST_SERVO_3.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_3 = 1 ;
+                        TEST_SERVO_3.Draw(BLEU, BLANC);
+                    }
+                }
+                else if(TEST_SERVO_4.Touched()) 
+                {
+                    while (TEST_SERVO_4.Touched());
+                    if(bras_select_4)
+                    {
+                        bras_select_4 = 0 ;
+                        TEST_SERVO_4.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_4 = 1 ;
+                        TEST_SERVO_4.Draw(BLEU, BLANC);
+                    }
+                }
+                else if(TEST_SERVO_5.Touched()) 
+                {
+                    while (TEST_SERVO_5.Touched());
+                    if(bras_select_5)
+                    {
+                        bras_select_5 = 0 ;
+                        TEST_SERVO_5.Draw(DIY_GREY, BLANC);
+                    }
+                    else
+                    {
+                        bras_select_5 = 1 ;
+                        TEST_SERVO_5.Draw(BLEU, BLANC);
+                    }
+                }
+                else if (TEST_ATTRAPER.Touched())
+                {
+                    
                 }
             }
             break;