carte esclave petit robot
Dependencies: mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr
Diff: main.cpp
- Revision:
- 6:45f9cf44718a
- Parent:
- 5:6e198cdd99ad
- Child:
- 7:553f3f1c2c53
diff -r 6e198cdd99ad -r 45f9cf44718a main.cpp --- a/main.cpp Tue May 14 15:09:14 2019 +0000 +++ b/main.cpp Tue May 14 15:41:32 2019 +0000 @@ -15,8 +15,9 @@ signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN unsigned char EtatGameEnd=0; -char fpresentoir_avant=0; -char fpresentoir_arriere=0; +char fpresentoir_avant=0, fpresentoir_arriere=0; +char fgoldenium_avant=0, fgoldenium_arriere=0; +char fsol_avant=0,fsol_arriere=0; char status_pompe=0; @@ -25,9 +26,16 @@ void SendRawId (unsigned short id); void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement); void canProcessRx(void); + void automate_ventouse_presentoir_avant(void); void automate_ventouse_presentoir_arriere (void); +void automate_ventouse_goldenium_avant (void); +void automate_ventouse_goldenium_arriere (void); + +void automate_ventouse_sol_avant (void); +void automate_ventouse_sol_arriere(void); + /*********************************************************************************************/ /* FUNCTION NAME: canRx_ISR */ /* DESCRIPTION : lit les messages sur le can et les stocke dans la FIFO */ @@ -117,6 +125,10 @@ canProcessRx(); automate_ventouse_presentoir_avant(); automate_ventouse_presentoir_arriere(); + automate_ventouse_goldenium_avant(); + automate_ventouse_goldenium_arriere(); + automate_ventouse_sol_avant(); + automate_ventouse_sol_arriere(); if(EtatGameEnd==1) { while(1); } @@ -225,27 +237,21 @@ accelerateur_arriere(); SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); break; + case GOLDENIUM_AVANT: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - balance_avant(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + fgoldenium_avant=1; break; case GOLDENIUM_ARRIERE: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - balance_arriere(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + fgoldenium_arriere=1; break; + case SOL_AVANT: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - sol_avant(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + fsol_avant=1; break; case SOL_ARRIERE: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - sol_arriere(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + fsol_arriere=1; break; case SOL_AVANT_RELACHE: @@ -354,7 +360,130 @@ break; } +} +void automate_ventouse_goldenium_avant (void) +{ + typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat; + static type_etat etat = init; + + switch(etat) { + case init: //attente d'initialisation + if(fgoldenium_avant) + etat=envoi_instruction; + break; + + case envoi_instruction://envoi instruction + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + goldenium_avant(); + SendRawId(HACHEUR_STATUT_VENTOUSES); + etat = attente_ack_ventouse; + break; + + case attente_ack_ventouse: + if((status_pompe&MASK_GOLDENIUM_AV)== MASK_GOLDENIUM_AV) { + fgoldenium_avant=0; + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + etat = init; + } + break; + + } +} + +void automate_ventouse_goldenium_arriere (void) +{ + + typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat; + static type_etat etat = init; + + switch(etat) { + case init: //attente d'initialisation + if(fgoldenium_arriere) + etat=envoi_instruction; + break; + + case envoi_instruction://envoi instruction + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + goldenium_arriere(); + SendRawId(HACHEUR_STATUT_VENTOUSES); + etat = attente_ack_ventouse; + break; + + case attente_ack_ventouse: + if((status_pompe&MASK_GOLDENIUM_AR)== MASK_GOLDENIUM_AR) { + fgoldenium_arriere=0; + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + etat = init; + } + break; + + } + + +} + +void automate_ventouse_sol_avant (void) +{ + + typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat; + static type_etat etat = init; + + switch(etat) { + case init: //attente d'initialisation + if(fsol_avant) + etat=envoi_instruction; + break; + + case envoi_instruction://envoi instruction + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + sol_avant_baisser(); + SendRawId(HACHEUR_STATUT_VENTOUSES); + etat = attente_ack_ventouse; + break; + + case attente_ack_ventouse: + if((status_pompe&MASK_SOL_AV)== MASK_SOL_AV) { + sol_avant_remonter(); + fsol_avant=0; + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + etat = init; + } + break; + + } + + +} +void automate_ventouse_sol_arriere (void) +{ + + typedef enum {init,envoi_instruction,attente_ack_ventouse} type_etat; + static type_etat etat = init; + + switch(etat) { + case init: //attente d'initialisation + if(fsol_arriere) + etat=envoi_instruction; + break; + + case envoi_instruction://envoi instruction + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + sol_arriere_baisser(); + SendRawId(HACHEUR_STATUT_VENTOUSES); + etat = attente_ack_ventouse; + break; + + case attente_ack_ventouse: + if((status_pompe&MASK_SOL_AR)== MASK_SOL_AR) { + sol_arriere_remonter(); + fsol_arriere=0; + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + etat = init; + } + break; + + } } \ No newline at end of file