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:
34:c314feaa0d3e
Parent:
33:c54841d11156
Child:
35:2a745eeb7922
--- a/IHM/ihm.cpp	Wed May 12 14:40:52 2021 +0000
+++ b/IHM/ihm.cpp	Mon May 17 07:19:15 2021 +0000
@@ -46,12 +46,20 @@
 
 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_0(280,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_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_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 FORCE_LAUNCH(0, 600, 400, 100, "Force Launch");
 Button SUIVANT(0,380,200,100,"Suivant");
 ////////////////////////////////////////////////////////////
@@ -258,6 +266,8 @@
         break;
 
         case TEST_VENTOUSE:   
+            char vent_select_0 = 7, vent_select_1 = 0, vent_select_2 = 0, vent_select_3 = 0, vent_select_4 = 0, vent_select_5 = 0 ;
+            unsigned char choix_vent;
             lcd.SetBackColor(LCD_COLOR_WHITE);
             lcd.SetTextColor(LCD_COLOR_BLACK);
             lcd.Clear (LCD_COLOR_WHITE);   
@@ -266,6 +276,260 @@
             sprintf(toto,"%hd",maximilien);
             lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
             RETOUR.Draw(0xFFFF0000,0);
+            TEST_ATTRAPER.Draw(BLEU, BLANC);
+            TEST_RELACHER.Draw(BLEU, BLANC);
+            TEST_VENT_0.Draw(BLEU, BLANC);
+            TEST_VENT_1.Draw(BLEU, BLANC);
+            TEST_VENT_2.Draw(BLEU, BLANC);
+            TEST_VENT_3.Draw(BLEU, BLANC);
+            TEST_VENT_4.Draw(BLEU, BLANC);
+            TEST_VENT_5.Draw(BLEU, BLANC);
+            while(strat_etat_s==TEST_VENTOUSE) 
+            {
+                if(RETOUR.Touched()) 
+                {
+                    while (RETOUR.Touched());
+                    strat_etat_s=DEMO;
+                }  
+                else if(TEST_VENT_0.Touched()) 
+                {
+                    while (TEST_VENT_0.Touched());
+                    if(vent_select_0 == 0)
+                    {
+                        vent_select_0 = 7 ;
+                        TEST_VENT_0.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_0 = 0 ;
+                        TEST_VENT_0.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if(TEST_VENT_1.Touched()) 
+                {
+                    while (TEST_VENT_1.Touched());
+                    if(vent_select_1 == 1)
+                    {
+                        vent_select_1 = 0 ;
+                        TEST_VENT_1.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_1 = 1 ;
+                        TEST_VENT_1.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if(TEST_VENT_2.Touched()) 
+                {
+                    while (TEST_VENT_2.Touched());
+                    if(vent_select_2 == 2)
+                    {
+                        vent_select_2 = 0 ;
+                        TEST_VENT_2.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_2 = 2 ;
+                        TEST_VENT_2.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if(TEST_VENT_3.Touched()) 
+                {
+                    while (TEST_VENT_3.Touched());
+                    if(vent_select_3 == 3)
+                    {
+                        vent_select_3 = 0 ;
+                        TEST_VENT_3.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_3 = 3 ;
+                        TEST_VENT_3.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if(TEST_VENT_4.Touched()) 
+                {
+                    while (TEST_VENT_4.Touched());
+                    if(vent_select_4 == 4)
+                    {
+                        vent_select_4 = 0 ;
+                        TEST_VENT_4.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_4 = 4 ;
+                        TEST_VENT_4.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if(TEST_VENT_5.Touched()) 
+                {
+                    while (TEST_VENT_5.Touched());
+                    if(vent_select_5 == 5)
+                    {
+                        vent_select_5 = 0 ;
+                        TEST_VENT_5.Draw(BLEU, BLANC);
+                    }
+                    else
+                    {
+                        vent_select_5 = 5 ;
+                        TEST_VENT_5.Draw(DIY_GREY, BLANC);
+                    }
+                }
+                else if (TEST_ATTRAPER.Touched())
+                {
+                    while(TEST_ATTRAPER.Touched()) ;
+                    unsigned char message_droit_at, message_gauche_at, nombre_de_chiffre_droite, nombre_de_chiffre_gauche;  //chager pour un short et remettre les valeurs correct (char utiliser pour les test)
+                    message_droit_at = 100 * vent_select_2 + 10 * vent_select_1 + vent_select_0 ;
+                    message_gauche_at = 100 * vent_select_5 + 10 * vent_select_4 + vent_select_3 ;
+                    
+                    switch (message_gauche_at)
+                    {
+                        case 31 :           //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement 
+                            choix_vent = 66 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ; 
+                        case 28 :          //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement
+                            choix_vent = 54 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 247 :         //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement
+                            choix_vent = 53 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 43 :
+                            choix_vent = 43 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 244 :          //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement
+                            choix_vent = 5 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 40 :
+                            choix_vent = 4 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 3 : 
+                            choix_vent = 3 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                    }
+                    
+                    switch (message_droit_at)
+                    {
+                        case 210 :
+                            choix_vent = 210 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 217 :
+                            choix_vent = 21 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 200 :
+                            choix_vent = 20 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 10 :
+                            choix_vent = 10 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 207 :
+                            choix_vent = 2 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 17 :
+                            choix_vent = 1 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 0 : 
+                            choix_vent = 0 ;
+                            SendMsgCan(VENT_AT, &choix_vent,sizeof(choix_vent));
+                            break ;
+                    }
+                    
+                    message_droit_at = 0 ;
+                    message_gauche_at = 0 ;
+                    
+                    TEST_ATTRAPER.Draw(BLEU, BLANC);
+                }
+                else if (TEST_RELACHER.Touched())
+                {
+                    while(TEST_RELACHER.Touched());
+                    unsigned char message_droit_re, message_gauche_re;
+                    message_droit_re = 100 * vent_select_2 + 10 * vent_select_1 + vent_select_0 ;
+                    message_gauche_re = 100 * vent_select_5 + 10 * vent_select_4 + vent_select_3 ;
+                    switch (message_droit_re)
+                    {
+                        case 210 :
+                            choix_vent = 210 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 217 :
+                            choix_vent = 21 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 200 :
+                            choix_vent = 20 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 10 :
+                            choix_vent = 10 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 207 :
+                            choix_vent = 2 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 17 :
+                            choix_vent = 1 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 0 : 
+                            choix_vent = 0 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                    }
+                    
+                    switch (message_gauche_re)
+                    {
+                        case 31 :
+                            choix_vent = 66 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 28 :
+                            choix_vent = 54 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 247 :
+                            choix_vent = 53 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 43 :
+                            choix_vent = 43 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 244 :
+                            choix_vent = 5 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 40 :
+                            choix_vent = 4 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                        case 3 : 
+                            choix_vent = 3 ;
+                            SendMsgCan(VENT_RE, &choix_vent,sizeof(choix_vent));
+                            break ;
+                    }
+                    message_droit_re = 0 ;
+                    message_gauche_re = 0 ;     //on remet les variables de calcul à 0 pour qu'on puisse recalculer correctement
+                    
+                    TEST_RELACHER.Draw(BLEU, BLANC);
+                    
+                }
+            }
+            break;
+            
+            /*
             TEST_A.Draw(BLEU, BLANC);
             TEST_NUM.Draw(BLEU, BLANC);
             TEST_PLUS.Draw(BLEU, BLANC);
@@ -349,7 +613,7 @@
                     lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
                 }
             }
-            break;
+            break;*/
         
         case TEST_ELECTROV:
             lcd.SetBackColor(LCD_COLOR_WHITE);