Strategie_13h30
Fork of CRAC-Strat_2017_homologation_gros_rob by
Diff: Strategie/Strategie.cpp
- Revision:
- 8:0edc7dfb7f7e
- Parent:
- 6:eddfa414fd11
- Child:
- 9:d0042422d95a
--- a/Strategie/Strategie.cpp Tue Apr 26 15:30:54 2016 +0000 +++ b/Strategie/Strategie.cpp Wed Apr 27 13:05:03 2016 +0000 @@ -21,9 +21,11 @@ #ifdef ROBOT_BIG unsigned short id_check[NOMBRE_CARTES]= {CHECK_BALISE,CHECK_MOTEUR}; unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_BALISE,ALIVE_MOTEUR}; +InterruptIn jack(p24); // entrée analogique en interruption pour le jack #else unsigned short id_check[NOMBRE_CARTES]= {CHECK_BALISE,CHECK_MOTEUR}; unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_BALISE,ALIVE_MOTEUR}; +InterruptIn jack(p24); // entrée analogique en interruption pour le jack #endif unsigned char checkCurrent = 0; unsigned char countAliveCard = 0; @@ -50,6 +52,18 @@ } /****************************************************************************************/ +/* FUNCTION NAME: jack_ISR */ +/* DESCRIPTION : Interruption en changement d'état sur le Jack */ +/****************************************************************************************/ +void jack_ISR (void) +{ + if(gameEtat == ETAT_GAME_WAIT_FOR_JACK) { + led4=1; + gameEtat = ETAT_GAME_START;//On débute le match + } +} + +/****************************************************************************************/ /* FUNCTION NAME: automate_process */ /* DESCRIPTION : Automate de gestion de la stratégie du robot */ /****************************************************************************************/ @@ -189,15 +203,17 @@ gameEtat = ETAT_GAME_WAIT_FOR_JACK; SendRawId(ECRAN_ACK_START_MATCH); tactile_printf("Attente du JACK."); + jack.fall(&jack_ISR); // création de l'interrupt attachée au changement d'état (front descendant) sur le jack break; case ETAT_GAME_WAIT_FOR_JACK: //TODO Attendre le jack break; case ETAT_GAME_START: + chronoEnd.attach(&chronometre_ISR,90); gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; gameTimer.reset(); gameTimer.start(); - chronoEnd.attach(&chronometre_ISR,90); + jack.fall(NULL); break; case ETAT_GAME_LOAD_NEXT_INSTRUCTION: /* @@ -501,14 +517,17 @@ } break; case SERVO_AX12_SETGOAL: + SendAck(0x114, SERVO_AX12_SETGOAL); if(AX12_isLocal(msgRxBuffer[FIFO_lecture].data[0])) AX12_setGoal(msgRxBuffer[FIFO_lecture].data[0], msgRxBuffer[FIFO_lecture].data[1]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[2])<<8), msgRxBuffer[FIFO_lecture].data[3]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[4])<<8)); break; case SERVO_AX12_PROCESS: + SendAck(0x114, SERVO_AX12_PROCESS); AX12_processChange(1); break; case SERVO_AX12_DONE: + SendAck(0x114, SERVO_AX12_DONE); AX12_notifyCANEnd(((unsigned short)(msgRxBuffer[FIFO_lecture].data[0]))); break; case ECRAN_CHOICE_COLOR://Choix de la couleur