![](/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: Strategie/Strategie.cpp
- Revision:
- 10:1964bb91b925
- Parent:
- 7:44eec996a76e
- Child:
- 11:848ea39838bf
diff -r 5c8be2a80d35 -r 1964bb91b925 Strategie/Strategie.cpp --- a/Strategie/Strategie.cpp Mon Feb 10 08:07:17 2020 +0000 +++ b/Strategie/Strategie.cpp Tue Mar 03 16:41:33 2020 +0000 @@ -118,7 +118,7 @@ float cptf; int cpt,cpt1; -typedef enum {INIT, ATT, CHOIX, DEMO, TEST_TELEMETRE, TEST_COULEUR, TEST_SERVO_BRAS, TEST_VENTOUSE, SELECT_SIDE, TACTIQUE, DETAILS,LECTURE, LAUNCH, AFF_WAIT_JACK, WAIT_JACK, COMPTEUR, FIN} T_etat; +typedef enum {INIT, ATT, CHOIX, DEMO, TEST_TELEMETRE, TEST_COULEUR, TEST_SERVO_BRAS, TEST_VENTOUSE, TEST_ELECTROV, SELECT_SIDE, TACTIQUE, DETAILS,LECTURE, LAUNCH, AFF_WAIT_JACK, WAIT_JACK, COMPTEUR, FIN} T_etat; T_etat etat = INIT; E_stratGameEtat gameEtat = ETAT_CHECK_CARTES; E_stratGameEtat memGameEtat= gameEtat; @@ -133,15 +133,21 @@ Button CHECK (0, 420, 400, 200, "Valider"); Button MATCH (0, 50, 400, 320, "Match"); Button DEMONSTRATION (0, 400, 400, 320, "Demo"); - +//menu demo Button TEST_VENT(0, 25, 400, 100, "Test ventouses"); Button TEST_TELE(0, 135, 400, 100, "Test telemetre"); Button TEST_COUL(0,245,400,100,"Test capteurs couleur"); Button TEST_BRAS(0,355,400,100,"Test Bras"); - -Button TEST_BRAS_GABARIT(0,25,400,100,"Test Gabarit"); -Button TEST_BRAS_GABARITD(0,135,400,100,"Test Gabarit deploye"); -Button TEST_BRAS_PRESENTOIR(0,245,400,100,"Test Presentoir"); +Button TEST_AUDIO(0,465,400,100,"Test Audio"); +Button TEST_ELECTRV(0,465,400,100,"Test Electro Vannes"); +//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_PLUS(205,355,195,100,"+"); +Button TEST_MOINS(0,355,195,100,"-"); Button FORCE_LAUNCH(0, 50, 400, 320, "Force Launch"); @@ -275,7 +281,7 @@ void Setflag(void) { - flagSendCan = 1; + flagSendCan = 1;//gab le zgeg } @@ -325,7 +331,9 @@ /****************************************************************************************/ void automate_etat_ihm(void) { + char toto[2]; int j; + unsigned char maximilien=1; if (j==0) { ts.Init(lcd.GetXSize(), lcd.GetYSize()); j++; @@ -390,6 +398,8 @@ break; case DEMO : + 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); RETOUR.Draw(0xFFFF0000, 0); @@ -397,6 +407,8 @@ TEST_TELE.Draw(VERT, 0); TEST_COUL.Draw(VERT, 0); TEST_BRAS.Draw(VERT, 0); + TEST_AUDIO.Draw(VERT, 0); + TEST_ELECTRV.Draw(VERT, 0); while (etat == DEMO) { canProcessRx(); if(TEST_VENT.Touched()) { @@ -405,12 +417,19 @@ } else if(TEST_TELE.Touched()) { while(TEST_TELE.Touched()); etat = TEST_TELEMETRE; + } else if(TEST_ELECTRV.Touched()) { + while(TEST_ELECTRV.Touched()); + etat = TEST_ELECTROV; } else if (TEST_COUL.Touched()) { while(TEST_COUL.Touched()); etat =TEST_COULEUR ; } else if (TEST_BRAS.Touched()) { while(TEST_BRAS.Touched()); etat =TEST_SERVO_BRAS ; + } else if(TEST_AUDIO.Touched()) { + while(TEST_AUDIO.Touched()); + TEST_AUDIO.Draw(VERT, 0); + Debug_Audio(3,2); } else if(RETOUR.Touched()) { while(RETOUR.Touched()); etat = CHOIX; @@ -419,38 +438,210 @@ break; - case TEST_VENTOUSE: + case TEST_VENTOUSE: + 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 *)"Test Ventouse", LEFT_MODE); + sprintf(toto,"%hd",maximilien); + lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE); RETOUR.Draw(0xFFFF0000,0); - while(etat==TEST_VENTOUSE) { + TEST_A.Draw(BLEU, BLANC); + TEST_NUM.Draw(BLEU, BLANC); + TEST_PLUS.Draw(BLEU, BLANC); + TEST_MOINS.Draw(BLEU, BLANC); + while(etat==TEST_SERVO_BRAS) { if(RETOUR.Touched()) { while (RETOUR.Touched()); etat=DEMO; - } + } else if(TEST_A.Touched()) { + while (TEST_A.Touched()); + SendRawId(TEST_VENT_A); + TEST_A.Draw(BLEU, BLANC); + } else if(TEST_NUM.Touched()) { + while (TEST_NUM.Touched()); + TEST_NUM.Draw(BLEU, BLANC); + switch(maximilien){ + case 1: + SendRawId(TEST_VENT_1); + break; + case 2: + SendRawId(TEST_VENT_2); + break; + case 3: + SendRawId(TEST_VENT_3); + break; + case 4: + SendRawId(TEST_VENT_4); + break; + case 5: + SendRawId(TEST_VENT_5); + break; + case 6: + SendRawId(TEST_VENT_6); + break; + } + } 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); + } } break; - - case TEST_SERVO_BRAS: + + case TEST_ELECTROV: + 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 *)"Test Bras", LEFT_MODE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Electro Vannes", LEFT_MODE); + sprintf(toto,"%hd",maximilien); + lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE); RETOUR.Draw(0xFFFF0000,0); - TEST_BRAS_PRESENTOIR.Draw(BLEU, BLANC); - TEST_BRAS_GABARIT.Draw(BLEU, BLANC); - TEST_BRAS_GABARITD.Draw(BLEU, BLANC); + TEST_A.Draw(BLEU, BLANC); + TEST_NUM.Draw(BLEU, BLANC); + TEST_PLUS.Draw(BLEU, BLANC); + TEST_MOINS.Draw(BLEU, BLANC); while(etat==TEST_SERVO_BRAS) { if(RETOUR.Touched()) { while (RETOUR.Touched()); etat=DEMO; - } else if(TEST_BRAS_PRESENTOIR.Touched()) { - while (TEST_BRAS_PRESENTOIR.Touched()); - SendRawId(PRESENTOIR); - } else if(TEST_BRAS_GABARIT.Touched()) { - while (TEST_BRAS_GABARIT.Touched()); - SendRawId(GABARIT); - } else if(TEST_BRAS_GABARITD.Touched()) { - while (TEST_BRAS_GABARITD.Touched()); - SendRawId(GABARIT_D); + } else if(TEST_A.Touched()) { + while (TEST_A.Touched()); + SendRawId(TEST_ELECTROV_A); + TEST_A.Draw(BLEU, BLANC); + } else if(TEST_NUM.Touched()) { + while (TEST_NUM.Touched()); + TEST_NUM.Draw(BLEU, BLANC); + switch(maximilien){ + case 1: + SendRawId(TEST_ELECTROV_1); + break; + case 2: + SendRawId(TEST_ELECTROV_2); + break; + case 3: + SendRawId(TEST_ELECTROV_3); + break; + case 4: + SendRawId(TEST_ELECTROV_4); + break; + case 5: + SendRawId(TEST_ELECTROV_5); + break; + case 6: + SendRawId(TEST_ELECTROV_6); + break; + } + } 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); + } + } + break; + + case TEST_SERVO_BRAS: + + 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 *)"Test Bras", LEFT_MODE); + 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(etat==TEST_SERVO_BRAS) { + if(RETOUR.Touched()) { + while (RETOUR.Touched()); + etat=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_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); } } break; @@ -772,6 +963,7 @@ SendRawId(GLOBAL_START); gameEtat = ETAT_GAME_WAIT_FOR_JACK; + Debug_Audio(3,7); if (etat == TEST_TELEMETRE|| etat ==TEST_VENTOUSE || etat == TEST_COULEUR || etat ==TEST_SERVO_BRAS) { SendRawId(DEBUG_FAKE_JAKE); } else { @@ -905,7 +1097,7 @@ break; case ETAT_GAME_START: - + Debug_Audio(3,3); gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; if (ModeDemo == 0) { @@ -1016,6 +1208,7 @@ break; } case MV_COURBURE://C'est un rayon de courbure + Debug_Audio(3,6); float alpha=0, theta=0; unsigned short alph=0; actionPrecedente = MV_COURBURE; @@ -1169,6 +1362,7 @@ case MV_LINE://Ligne droite + Debug_Audio(3,8); waitingAckID = ASSERVISSEMENT_RECALAGE; waitingAckFrom = ACKNOWLEDGE_MOTEUR; if(instruction.nextActionType == ENCHAINEMENT) { @@ -1191,6 +1385,7 @@ break; case MV_TURN: //Rotation sur place + Debug_Audio(3,9); target_x_robot = x_robot; target_y_robot = y_robot; target_theta_robot = theta_robot + localData2; @@ -1217,6 +1412,7 @@ break; case MV_XYT: + Debug_Audio(3,10); if(instruction.direction == BACKWARD) { localData1 = -1; } else { @@ -1286,11 +1482,10 @@ waitingAckID_FIN = 0; waitingAckFrom_FIN = 0; - int tempo = 0; waitingAckID= ACK_ACTION; //On veut un ack de type action waitingAckFrom = ACKNOWLEDGE_HERKULEX; //de la part des herkulex - tempo = doAction(instruction.arg1,instruction.arg2,instruction.arg3); + //tempo = doAction(instruction.arg1,instruction.arg2,instruction.arg3); // unsigned char test=(unsigned char) tempo; // SendMsgCan(0x5BD, &test,1); if(tempo == 1) { @@ -1486,6 +1681,7 @@ break; case ETAT_END: + Debug_Audio(3,4); if (ModeDemo) { gameEtat = ETAT_CHECK_CARTE_SCREEN; ModeDemo = 1; @@ -1752,6 +1948,10 @@ } break; + case SOMO: + break; + default: + break; /* case NO_BLOC: //il n'y a pas de bloc, on saute les étapes liées à l'attrape bloc actual_instruction = instruction.nextLineError;