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:
- 7:44eec996a76e
- Parent:
- 5:81aac085516f
- Child:
- 10:1964bb91b925
--- a/Strategie/Strategie.cpp Fri Jan 31 15:12:18 2020 +0000 +++ b/Strategie/Strategie.cpp Mon Feb 03 10:07:50 2020 +0000 @@ -82,7 +82,6 @@ signed short x_robot,y_robot,theta_robot;//La position du robot signed short target_x_robot, target_y_robot, target_theta_robot; E_InstructionType actionPrecedente; -signed short start_move_x,start_move_y,start_move_theta;//La position du robot lors du début d'un mouvement, utilisé pour reprendre le mouvement apres stop balise //unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN int flagSendCan=1; unsigned char Cote = 0; //0 -> JAUNE | 1 -> VIOLET @@ -119,7 +118,7 @@ float cptf; int cpt,cpt1; -typedef enum {INIT, ATT, CHOIX, DEMO, TEST_TELEMETRE, TEST_CAPTEURS, TEST_SERVO, TEST_TIR, DEMO_IMMEUBLE,DEMO_TRIEUR, 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, 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; @@ -127,8 +126,6 @@ E_Stratposdebut etat_pos=RECALAGE_1; /////////////////DEFINITION DES BOUTONS//////////////////// -Button COTE_VERT(0, 25, 400, 300, "JAUNE"); -Button COTE_ORANGE(0, 350, 400, 300, "VIOLET"); Button COTE_JAUNE(0, 25, 400, 300, "JAUNE"); Button COTE_VIOLET(0, 350, 400, 300, "VIOLET"); Button RETOUR (0, 680, 400, 110, "--Precedent--"); @@ -136,33 +133,19 @@ Button CHECK (0, 420, 400, 200, "Valider"); Button MATCH (0, 50, 400, 320, "Match"); Button DEMONSTRATION (0, 400, 400, 320, "Demo"); -Button TEST_HERKULEX(0, 25, 400, 100, "Test servos"); -Button TEST_LASER(0, 135, 400, 100, "Test telemetre"); -Button TEST_COULEURS(0,245,400,100,"Test capteurs"); -Button TEST_TIR_BALLE(0,355,400,100,"Test Lanceur"); -Button TEST_IMMEUBLE(0,465,400,100,"Test immeuble"); -Button TEST_TRIEUR(0,575,400,100,"Test aiguilleur"); -Button TIR_CHATEAU(0, 25, 400, 100, "Tir chateau"); -Button EPURATION(0, 150, 400, 100, "epuration"); -Button LANCEUR_ON(0,275,400,100,"allumer le lanceur"); -Button LANCEUR_OFF(0,400,400,100,"eteindre le lanceur"); -Button ABAISSE_BLOC(0, 25, 400, 100, "Ramasser blocs"); -Button RELEVE_BLOC(0, 135, 400, 100, "lacher blocs"); -Button BRAS_ABEILLE_ON(0,245,400,100,"bras abeille"); -Button BRAS_ABEILLE_OFF(0,355,400,100,"baisser bras abeille"); -Button INTERRUPTEUR_ON(0,465,400,100,"baisser bras interrupt"); -Button INTERRUPTEUR_OFF(0,575,400,100,"baisser bras interrupt"); + +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 FORCE_LAUNCH(0, 50, 400, 320, "Force Launch"); -Button TRI(0, 25, 400, 100, "Test tri"); -Button AIGUILLEUR_D(0, 150, 400, 100, "aiguilleur droite"); -Button AIGUILLEUR_G(0,275,400,100,"aiguilleur gauche"); -Button AIGUILLEUR_CTRE(0,400,400,100,"aiguilleur centre"); Button SUIVANT(0,380,200,100,"Suivant"); -Button COLOR_ORANGE (0, 230, 190, 110,""); -Button COLOR_JAUNE (210, 230, 190, 110,""); -Button COLOR_VERT (0, 350, 190, 110,""); -Button COLOR_BLEU (210, 350, 190, 110,""); -Button COLOR_NOIR (105, 470, 190, 110,""); //////////////////////////////////////////////////////////// void SendRawId (unsigned short id); @@ -407,140 +390,88 @@ break; case DEMO : - lcd.Clear(LCD_COLOR_WHITE); + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO", LEFT_MODE); RETOUR.Draw(0xFFFF0000, 0); - TEST_HERKULEX.Draw(VERT, 0); - TEST_LASER.Draw(VERT, 0); - TEST_COULEURS.Draw(VERT, 0); - TEST_TIR_BALLE.Draw(VERT, 0); - TEST_IMMEUBLE.Draw(VERT,0); - TEST_TRIEUR.Draw(VERT,0); - if(gameEtat == ETAT_CONFIG) {//C'est bon on a le droit de modifier les config// - InversStrat = 0;//Pas d'inversion de la couleur - } - while (etat == DEMO) { ////////////////////////////LISTE DES DIFFERENTES DEMOS POSSIBLES/////////////////////////////////////////// + TEST_VENT.Draw(VERT, 0); + TEST_TELE.Draw(VERT, 0); + TEST_COUL.Draw(VERT, 0); + TEST_BRAS.Draw(VERT, 0); + while (etat == DEMO) { canProcessRx(); - if(TEST_HERKULEX.Touched()) { - //Strat = 0x10; - while(TEST_HERKULEX.Touched()); - CANMessage trame_Tx = CANMessage(); - trame_Tx.len = 1; - trame_Tx.format = CANStandard; - trame_Tx.type = CANData; - trame_Tx.id=CHOICE_COLOR; - trame_Tx.data[0]=0x2; - can2.write(trame_Tx); - TEST_HERKULEX.Draw(0xFFF0F0F0, 0); - etat = TEST_SERVO; - lcd.Clear(LCD_COLOR_WHITE); - ModeDemo=1; - } else if(TEST_LASER.Touched()) { - //Strat = 0x11; - while(TEST_LASER.Touched()); - TEST_LASER.Draw(0xFFF0F0F0, 0); + if(TEST_VENT.Touched()) { + while(TEST_VENT.Touched()); + etat = TEST_VENTOUSE; + } else if(TEST_TELE.Touched()) { + while(TEST_TELE.Touched()); etat = TEST_TELEMETRE; - } else if (TEST_COULEURS.Touched()) { - while(TEST_COULEURS.Touched()); - TEST_LASER.Draw(0xFFF0F0F0, 0); - etat =TEST_CAPTEURS ; - } - - else if (TEST_TIR_BALLE.Touched()) { - while(TEST_TIR_BALLE.Touched()); - while(1) { - TEST_TIR_BALLE.Draw(0xFFF0F0F0, 0); - // rn42_Tx.printf("A");//experience - liaison_Tx.envoyer_short(0x30,666); - pc.printf("data\r"); - - } - //ModeDemo=1; - } else if(TEST_IMMEUBLE.Touched()) { - while(TEST_IMMEUBLE.Touched()); - TEST_IMMEUBLE.Draw(0xFFF0F0F0, 0); - etat =DEMO_IMMEUBLE; - lcd.Clear(LCD_COLOR_WHITE); - } else if(TEST_TRIEUR.Touched()) { - while(TEST_TRIEUR.Touched()); - etat=DEMO_TRIEUR; - lcd.Clear(LCD_COLOR_WHITE); - } - if(RETOUR.Touched()) { + } 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(RETOUR.Touched()) { + while(RETOUR.Touched()); etat = CHOIX; - while(RETOUR.Touched()); - - } - if(gameEtat == ETAT_CONFIG) {//C'est bon on a le droit de modifier les config - Ack_strat = 1; - wait_ms(10); } } break; - case TEST_SERVO: //TEST DU RESTE DES SERVOS DISPO HORS TIR - lcd.SetBackColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); - ABAISSE_BLOC.Draw(VERT, 0); - RELEVE_BLOC.Draw(VERT, 0); - BRAS_ABEILLE_ON.Draw(VERT, 0); - BRAS_ABEILLE_OFF.Draw(VERT, 0); - INTERRUPTEUR_ON.Draw(VERT, 0); - INTERRUPTEUR_OFF.Draw(VERT, 0); + case TEST_VENTOUSE: + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Ventouse", LEFT_MODE); RETOUR.Draw(0xFFFF0000,0); - while(etat==TEST_SERVO) { + while(etat==TEST_VENTOUSE) { + if(RETOUR.Touched()) { + while (RETOUR.Touched()); + etat=DEMO; + } + } + break; + + case TEST_SERVO_BRAS: + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Bras", LEFT_MODE); + RETOUR.Draw(0xFFFF0000,0); + TEST_BRAS_PRESENTOIR.Draw(BLEU, BLANC); + TEST_BRAS_GABARIT.Draw(BLEU, BLANC); + TEST_BRAS_GABARITD.Draw(BLEU, BLANC); + while(etat==TEST_SERVO_BRAS) { if(RETOUR.Touched()) { while (RETOUR.Touched()); etat=DEMO; - } else if(ABAISSE_BLOC.Touched()) { - while (ABAISSE_BLOC.Touched()); - SendRawId(GABARIT_PETIT_ROBOT); - break; - } else if(RELEVE_BLOC.Touched()) { - while (RELEVE_BLOC.Touched()); - SendRawId(PRESENTOIR_AVANT); - break; - } else if(BRAS_ABEILLE_ON.Touched()) { - while (BRAS_ABEILLE_ON.Touched()); - //SendRawId(BRAS_ABEILLE_UP); - break; - - } else if(BRAS_ABEILLE_OFF.Touched()) { - while (BRAS_ABEILLE_OFF.Touched()); - //SendRawId(BRAS_ABEILLE_DOWN); - break; - } else if(INTERRUPTEUR_ON.Touched()) { - while (INTERRUPTEUR_ON.Touched()); - //SendRawId(ALLUMER_PANNEAU_UP); - break; - } else if(INTERRUPTEUR_OFF.Touched()) { - while (INTERRUPTEUR_OFF.Touched()); - //SendRawId(ALLUMER_PANNEAU_DOWN); - break; + } 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); } } break; - - case TEST_TIR: // TEST DES FONCTIONS LIEES AUX TIRS - lcd.SetBackColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); - TIR_CHATEAU.Draw(VERT, 0); - EPURATION.Draw(VERT, 0); - LANCEUR_ON.Draw(VERT, 0); - LANCEUR_OFF.Draw(VERT, 0); - RETOUR.Draw(ROUGE, 0); - - etat=DEMO; - + + case TEST_COULEUR: + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Couleur", LEFT_MODE); + RETOUR.Draw(0xFFFF0000,0); + while(etat==TEST_COULEUR) { + if(RETOUR.Touched()) { + while (RETOUR.Touched()); + etat=DEMO; + lcd.Clear (LCD_COLOR_WHITE); + } + } break; - - case TEST_TELEMETRE: //AFFICHAGE DE LA VALEUR LUE PAR LES 4 TELEMETRES ModeDemo=1; - lcd.Clear(LCD_COLOR_WHITE); - lcd.SetBackColor(LCD_COLOR_WHITE); - lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); + lcd.Clear (LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Telemetre", LEFT_MODE); RETOUR.Draw(0xFFFF0000, 0); while(etat==TEST_TELEMETRE) { SendRawId(DATA_RECALAGE); @@ -550,7 +481,7 @@ if(RETOUR.Touched()) { while( RETOUR.Touched()); etat=DEMO; - lcd.Clear(LCD_COLOR_WHITE); + ModeDemo=0; } } break; ///////////////////////////////////////////FIN DES DEMOS///////////////////////////////////////////////// @@ -841,7 +772,7 @@ SendRawId(GLOBAL_START); gameEtat = ETAT_GAME_WAIT_FOR_JACK; - if (etat == TEST_TELEMETRE|| etat ==TEST_CAPTEURS || etat == TEST_SERVO || etat ==TEST_TIR || etat == DEMO_IMMEUBLE) { + if (etat == TEST_TELEMETRE|| etat ==TEST_VENTOUSE || etat == TEST_COULEUR || etat ==TEST_SERVO_BRAS) { SendRawId(DEBUG_FAKE_JAKE); } else { etat = AFF_WAIT_JACK;