carte esclave Petit Robot
Dependencies: mbed Herkulex_Library_2019 actions_Gr ident_crac actions_Pr
Diff: main.cpp
- Revision:
- 14:b1abd2f6df75
- Parent:
- 13:9e19048eb065
- Child:
- 15:119fc452dcaf
diff -r 9e19048eb065 -r b1abd2f6df75 main.cpp --- a/main.cpp Tue May 21 08:56:49 2019 +0000 +++ b/main.cpp Tue May 21 14:37:51 2019 +0000 @@ -17,11 +17,12 @@ unsigned char EtatGameEnd=0; char fpresentoir_avant=0, fpresentoir_arriere=0; -char fgoldenium_avant=0, fgoldenium_arriere=0; +char fgoldenium_avant=0, fgoldenium_arriere=0; char fsol_avant=0,fsol_arriere=0; char fsol_avant_relache=0,fsol_arriere_relache=0; char fbalance_avant=0,fbalance_arriere=0; char favant_relache=0,farriere_relache=0; +char faccelerateur_avant=0,faccelerateur_arriere=0;; @@ -51,8 +52,10 @@ void automate_ventouse_relache_avant(void); void automate_ventouse_relache_arriere (void); -void automate_ventouse_sol_avant_relache (void); -void automate_ventouse_sol_arriere_relache (void); +void automate_ventouse_accelerateur_avant(void); +void automate_ventouse_accelerateur_arriere(void); + + /*********************************************************************************************/ /* FUNCTION NAME: canRx_ISR */ /* DESCRIPTION : lit les messages sur le can et les stocke dans la FIFO */ @@ -173,9 +176,12 @@ automate_ventouse_relache_avant(); automate_ventouse_relache_arriere(); - + automate_ventouse_sol_avant_relache(); - automate_ventouse_sol_arriere_relache(); + automate_ventouse_sol_arriere_relache(); + + automate_ventouse_accelerateur_avant(); + automate_ventouse_accelerateur_arriere(); if(EtatGameEnd==1) { while(1); @@ -271,15 +277,11 @@ break; case ACCELERATEUR_AVANT: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - accelerateur_avant(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + faccelerateur_avant=1; break; case ACCELERATEUR_ARRIERE: - SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); - accelerateur_arriere(); - SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + faccelerateur_arriere=1; break; case GOLDENIUM_AVANT: @@ -312,6 +314,13 @@ case ARRIERE_RELACHE: farriere_relache=1; break; + case RECROQUEVILLER: + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + recroqueviller_avant(); + recroqueviller_arriere(); + verification(); + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + break; //--------------------------------------------------------------------------ACK carte pompe---------------------------------------------- @@ -427,11 +436,13 @@ case envoi_instruction://envoi instruction SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); goldenium_avant(); - SendRawId(HACHEUR_STATUT_VENTOUSES); + char pompe=AV_CENTRE; + can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1)); etat = attente_ack_ventouse; break; case attente_ack_ventouse: + SendRawId(HACHEUR_STATUT_VENTOUSES); if((status_pompe&MASK_GOLDENIUM_AV)== MASK_GOLDENIUM_AV) { fgoldenium_avant=0; SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); @@ -457,11 +468,13 @@ case envoi_instruction://envoi instruction SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); goldenium_arriere(); - SendRawId(HACHEUR_STATUT_VENTOUSES); + char pompe=AR_CENTRE; + can.write(CANMessage(HACHEUR_GET_ATOM, &pompe,1)); etat = attente_ack_ventouse; break; case attente_ack_ventouse: + SendRawId(HACHEUR_STATUT_VENTOUSES); if((status_pompe&MASK_GOLDENIUM_AR)== MASK_GOLDENIUM_AR) { fgoldenium_arriere=0; SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); @@ -750,4 +763,50 @@ } -} \ No newline at end of file +} +void automate_ventouse_accelerateur_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(faccelerateur_avant) + etat=envoi_instruction; + break; + + case envoi_instruction://envoi instruction + SendAck(ACKNOWLEDGE_HERKULEX, ACK_ACTION); + accelerateur_avant(); + GoStraight(200,1,35,0);//35epaisseur accelerateur + etat = attente_ack_ventouse; + break; + + case attente_ack_ventouse: + char pompe=AV_DROIT; + can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1)); + pompe=AV_GAUCHE; + can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1)); + SendRawId(HACHEUR_STATUT_VENTOUSES); + if((status_pompe&MASK_AV_DROIT_GAUCHE)== 0) { + faccelerateur_avant=0; + presentoir_avant(); + can.write(CANMessage(HACHEUR_RELEASE_ATOM, &pompe,1));//on arrete la pompe car elle est réactivé par presentoir_avant(); + SendAck(ACKNOWLEDGE_HERKULEX, ACK_FIN_ACTION); + etat = init; + } + break; + + } + + +} + + +void automate_ventouse_accelerateur_arriere (void) +{ + + +} + +