carte_strategie_2019
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Diff: Strategie/Strategie.cpp
- Revision:
- 32:1c9ab15c740e
- Parent:
- 31:833fc481b002
- Child:
- 33:388aa0bf6af4
--- a/Strategie/Strategie.cpp Tue Apr 24 18:09:51 2018 +0000 +++ b/Strategie/Strategie.cpp Wed Apr 25 12:36:38 2018 +0000 @@ -99,7 +99,7 @@ float cptf; int cpt,cpt1; -typedef enum {INIT, ATT, CHOIX, DEMO, TEST_TELEMETRE, TEST_CAPTEURS, TEST_SERVO, TEST_TIR, DEMO_IMMEUBLE, SELECT_SIDE, TACTIQUE, DETAILS,LECTURE, LAUNCH, AFF_WAIT_JACK, WAIT_JACK, COMPTEUR, FIN} T_etat; +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; T_etat etat = INIT; E_stratGameEtat gameEtat = ETAT_CHECK_CARTES; E_stratGameEtat lastEtat = ETAT_CHECK_CARTES; @@ -114,10 +114,11 @@ 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, 150, 400, 100, "Test telemetre"); - Button TEST_COULEURS(0,275,400,100,"Test capteurs"); - Button TEST_TIR_BALLE(0,400,400,100,"Test Lanceur"); - Button TEST_IMMEUBLE(0,525,400,100,"Test immeuble"); + 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"); @@ -125,10 +126,14 @@ 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,"lever bras interrupt"); + 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 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,""); @@ -313,10 +318,7 @@ ts.GetState(&TS_State); canProcessRx(); - CANMessage trame_Tx = CANMessage(); - trame_Tx.len = 1; - trame_Tx.format = CANStandard; - trame_Tx.type = CANData; + lcd.SetBackColor(LCD_COLOR_WHITE); @@ -400,6 +402,7 @@ TEST_COULEURS.Draw(BLEU, 0); TEST_TIR_BALLE.Draw(BLEU, 0); TEST_IMMEUBLE.Draw(BLEU,0); + TEST_TRIEUR.Draw(BLEU,0); if(gameEtat == ETAT_CONFIG) {//C'est bon on a le droit de modifier les config // InversStrat = 0;//Pas d'inversion de la couleur // A changer , discussion avec l'ihm } @@ -410,8 +413,12 @@ { //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]=2; + trame_Tx.data[0]=0x2; can2.write(trame_Tx); TEST_HERKULEX.Draw(0xFFF0F0F0, 0); etat = TEST_SERVO; @@ -436,8 +443,12 @@ TEST_TIR_BALLE.Draw(0xFFF0F0F0, 0); etat =TEST_TIR ; lcd.Clear(LCD_COLOR_WHITE); + 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]=2; + trame_Tx.data[0]=0x2; can2.write(trame_Tx); ModeDemo=1; } @@ -447,6 +458,13 @@ 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()) { etat = CHOIX; @@ -467,6 +485,54 @@ //SelectionStrat(Strategie); } break; + case DEMO_TRIEUR: + lcd.SetBackColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); + TRI.Draw(VERT, 0); + AIGUILLEUR_D.Draw(VERT, 0); + AIGUILLEUR_G.Draw(VERT, 0); + AIGUILLEUR_CTRE.Draw(VERT, 0); + while(etat==DEMO_TRIEUR){ + if(RETOUR.Touched()){ + while (RETOUR.Touched()); + etat=DEMO; + } + else if(TRI.Touched()){ + while (TRI.Touched()); + SendRawId(AIGUILLEUR_CENTRE); + wait(0.5); + SendRawId(AIGUILLEUR_DROITE); + wait(0.5); + SendRawId(AIGUILLEUR_GAUCHE); + wait(0.5); + SendRawId(AIGUILLEUR_CENTRE); + + break; + } + else if(AIGUILLEUR_D.Touched()){ + while (AIGUILLEUR_D.Touched()); + SendRawId(AIGUILLEUR_DROITE); + break; + } + else if(AIGUILLEUR_G.Touched()){ + while (AIGUILLEUR_G.Touched()); + SendRawId(AIGUILLEUR_GAUCHE); + break; + + } + else if(BRAS_ABEILLE_OFF.Touched()){ + while (BRAS_ABEILLE_OFF.Touched()); + SendRawId(BRAS_ABEILLE_DOWN); + break; + } + else if(AIGUILLEUR_CTRE.Touched()){ + while (AIGUILLEUR_CTRE.Touched()); + SendRawId(AIGUILLEUR_CENTRE); + break; + } + + } + break; case DEMO_IMMEUBLE: int color=0; lcd.SetBackColor(LCD_COLOR_WHITE); @@ -731,6 +797,7 @@ if(RETOUR.Touched()){ while( RETOUR.Touched()); etat=DEMO; + lcd.Clear(LCD_COLOR_WHITE); } } break; @@ -756,6 +823,10 @@ Cote = 0x0; InversStrat = Cote; etat = TACTIQUE; + 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]=Cote; can2.write(trame_Tx); @@ -768,6 +839,10 @@ Cote = 0x1; InversStrat= Cote; etat = TACTIQUE; + 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]=Cote; can2.write(trame_Tx);