![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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
Diff: IHM/ihm.cpp
- Revision:
- 33:c54841d11156
- Parent:
- 32:7f8e3ee2adac
- Child:
- 34:c314feaa0d3e
--- a/IHM/ihm.cpp Tue May 11 15:02:31 2021 +0000 +++ b/IHM/ihm.cpp Wed May 12 14:40:52 2021 +0000 @@ -19,7 +19,7 @@ /////////////////DEFINITION DES BOUTONS//////////////////// Button COTE_JAUNE(0, 25, 400, 300, "JAUNE"); -Button COTE_VIOLET(0, 350, 400, 300, "VIOLET"); +Button COTE_VIOLET(0, 350, 400, 300, "BLEU"); Button RETOUR (0, 680, 400, 110, "--Precedent--"); Button LANCER (0, 200, 400, 200, "--LANCER--"); Button CHECK (0, 420, 400, 200, "Valider"); @@ -418,7 +418,8 @@ 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 ; + char bras_select_0 = 7, bras_select_1 = 0, bras_select_2 = 0, bras_select_3 = 0, bras_select_4 = 0, bras_select_5 = 0 ; + unsigned char choix_bras; lcd.SetBackColor(LCD_COLOR_WHITE); lcd.SetTextColor(LCD_COLOR_BLACK); lcd.Clear (LCD_COLOR_WHITE); @@ -445,89 +446,292 @@ else if(TEST_SERVO_0.Touched()) { while (TEST_SERVO_0.Touched()); - if(bras_select_0) + if(bras_select_0 == 0) + { + bras_select_0 = 7 ; + TEST_SERVO_0.Draw(BLEU, BLANC); + } + else { 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) + if(bras_select_1 == 1) { bras_select_1 = 0 ; - TEST_SERVO_1.Draw(DIY_GREY, BLANC); + TEST_SERVO_1.Draw(BLEU, BLANC); } else { bras_select_1 = 1 ; - TEST_SERVO_1.Draw(BLEU, BLANC); + TEST_SERVO_1.Draw(DIY_GREY, BLANC); } } else if(TEST_SERVO_2.Touched()) { while (TEST_SERVO_2.Touched()); - if(bras_select_2) + if(bras_select_2 == 2) { bras_select_2 = 0 ; - TEST_SERVO_2.Draw(DIY_GREY, BLANC); + TEST_SERVO_2.Draw(BLEU, BLANC); } else { - bras_select_2 = 1 ; - TEST_SERVO_2.Draw(BLEU, BLANC); + bras_select_2 = 2 ; + TEST_SERVO_2.Draw(DIY_GREY, BLANC); } } else if(TEST_SERVO_3.Touched()) { while (TEST_SERVO_3.Touched()); - if(bras_select_3) + if(bras_select_3 == 3) { bras_select_3 = 0 ; - TEST_SERVO_3.Draw(DIY_GREY, BLANC); + TEST_SERVO_3.Draw(BLEU, BLANC); } else { - bras_select_3 = 1 ; - TEST_SERVO_3.Draw(BLEU, BLANC); + bras_select_3 = 3 ; + TEST_SERVO_3.Draw(DIY_GREY, BLANC); } } else if(TEST_SERVO_4.Touched()) { while (TEST_SERVO_4.Touched()); - if(bras_select_4) + if(bras_select_4 == 4) { bras_select_4 = 0 ; - TEST_SERVO_4.Draw(DIY_GREY, BLANC); + TEST_SERVO_4.Draw(BLEU, BLANC); } else { - bras_select_4 = 1 ; - TEST_SERVO_4.Draw(BLEU, BLANC); + bras_select_4 = 4 ; + TEST_SERVO_4.Draw(DIY_GREY, BLANC); } } else if(TEST_SERVO_5.Touched()) { while (TEST_SERVO_5.Touched()); - if(bras_select_5) + if(bras_select_5 == 5) { bras_select_5 = 0 ; - TEST_SERVO_5.Draw(DIY_GREY, BLANC); + TEST_SERVO_5.Draw(BLEU, BLANC); } else { - bras_select_5 = 1 ; - TEST_SERVO_5.Draw(BLEU, BLANC); + bras_select_5 = 5 ; + TEST_SERVO_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; + message_droit_at = 100 * bras_select_2 + 10 * bras_select_1 + bras_select_0 ; + message_gauche_at = 100 * bras_select_5 + 10 * bras_select_4 + bras_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_bras = 66 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 28 : //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement + choix_bras = 54 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 247 : //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement + choix_bras = 53 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 43 : + choix_bras = 43 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 244 : //on dépasse la taille d'un char donc on met la valeur en comptant le dépassement + choix_bras = 5 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 40 : + choix_bras = 4 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 3 : + choix_bras = 3 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + } + + switch (message_droit_at) + { + case 210 : + choix_bras = 210 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 217 : + choix_bras = 21 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 200 : + choix_bras = 20 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 10 : + choix_bras = 10 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 207 : + choix_bras = 2 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 17 : + choix_bras = 1 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 0 : + choix_bras = 0 ; + SendMsgCan(BRAS_AT, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + 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 * bras_select_2 + 10 * bras_select_1 + bras_select_0 ; + message_gauche_re = 100 * bras_select_5 + 10 * bras_select_4 + bras_select_3 ; + switch (message_droit_re) + { + case 210 : + choix_bras = 210 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 217 : + choix_bras = 21 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 200 : + choix_bras = 20 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 10 : + choix_bras = 10 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 207 : + choix_bras = 2 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 17 : + choix_bras = 1 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 0 : + choix_bras = 0 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + } + + switch (message_gauche_re) + { + case 31 : + choix_bras = 66 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 28 : + choix_bras = 54 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 247 : + choix_bras = 53 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 43 : + choix_bras = 43 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 244 : + choix_bras = 5 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 40 : + choix_bras = 4 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + case 3 : + choix_bras = 3 ; + SendMsgCan(BRAS_RE, &choix_bras,sizeof(choix_bras)); + waitingAckFrom = 0; + waitingAckID =0; + break ; + } + message_droit_re = 0 ; + message_gauche_re = 0 ; + + TEST_RELACHER.Draw(BLEU, BLANC); } }