![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
Diff: main.cpp
- Revision:
- 23:7f62f27c028f
- Parent:
- 22:f104afbecb98
- Child:
- 24:3fb41d2b91af
diff -r f104afbecb98 -r 7f62f27c028f main.cpp --- a/main.cpp Sun Mar 08 23:05:13 2020 +0000 +++ b/main.cpp Mon Jul 13 11:31:08 2020 +0000 @@ -41,7 +41,8 @@ /* FUNCTION NAME: canProcessRx */ /* DESCRIPTION : Fonction de traitement des messages CAN */ /*********************************************************************************************************/ -void canProcessRx(void){ +void canProcessRx(void) +{ static signed char FIFO_occupation=0,FIFO_max_occupation=0; CANMessage msgTx=CANMessage(); FIFO_occupation=FIFO_ecriture-FIFO_lecture; @@ -51,41 +52,46 @@ FIFO_max_occupation=FIFO_occupation; if(FIFO_occupation!=0) { int identifiant=msgRxBuffer[FIFO_lecture].id; - char BRAS = 0; + char BRAS_VENTOUSE = 0; switch(identifiant) - { - //BRAS=data: donc savoir si data peut être envoyé - case VENTOUSE_ATTRAPER: - BRAS = msgRxBuffer[FIFO_lecture].data[0]; - ventouse[BRAS]->action(1); + { + + case VENT_AT: + BRAS_VENTOUSE = msgRxBuffer[FIFO_lecture].data[0]; + ventouse[BRAS_VENTOUSE]->action(1); break; - case VENTOUSE_RELACHER: - BRAS = msgRxBuffer[FIFO_lecture].data[0]; - ventouse[BRAS]->action(0); + case VENT_RE: + BRAS_VENTOUSE = msgRxBuffer[FIFO_lecture].data[0]; + ventouse[BRAS_VENTOUSE]->action(0); break; - /*case HACHEUR_STATUT_VENTOUSES: + case VENT_ETAT: get_etat_ventouses(); - break;*/ + break; case GLOBAL_GAME_END: end_game = 1; break; - /*case HACHEUR_ETAT_CONTACTS: - char contacts_tmp = contacts; - can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&contacts_tmp,1)); - break; - case TEST_VENT_1_ON: ventouse[AV_DROIT]->action(1); + ventouse[AV_CENTRE]->action(1); + ventouse[AV_GAUCHE]->action(1); + ventouse[AR_DROIT]->action(1); + ventouse[AR_CENTRE]->action(1); + ventouse[AR_GAUCHE]->action(1); break; case TEST_VENT_1_OFF: + ventouse[AV_CENTRE]->action(0); ventouse[AV_GAUCHE]->action(0); - break;*/ + ventouse[AR_DROIT]->action(0); + ventouse[AR_CENTRE]->action(0); + ventouse[AR_GAUCHE]->action(0); + ventouse[AV_DROIT]->action(0); + break; default: break; @@ -99,15 +105,16 @@ can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN wait_ms(100); - ventouse[AR_DROIT] = new Ventouse(PB_7, PB_6, PC_0, AV_DROIT); + ventouse[AR_DROIT] = new Ventouse(PB_7, PB_6, PC_0, AR_DROIT); ventouse[AR_CENTRE] = new Ventouse(PC_9, PA_8, PB_0, AR_CENTRE); ventouse[AR_GAUCHE] = new Ventouse(PA_9, PA_10, PB_1, AR_GAUCHE); - ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4, AV_DROIT); + ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4, AV_DROIT); //PA_6, PA_5, PA_7, + ventouse[AV_CENTRE] = new Ventouse(PB_10, PB_2, PC_4, AV_CENTRE); ventouse[AV_GAUCHE] = new Ventouse(PC_7,PC_8 , PC_5, AV_GAUCHE); - ventouse[AV_CENTRE] = new Ventouse(PB_10, PB_2, PC_4, AR_CENTRE); pc.printf("Launched carte ventouse"); + //on force les ventouses à être éteintes au début ventouse[AV_DROIT]->action(0); ventouse[AV_CENTRE]->action(0); ventouse[AV_GAUCHE]->action(0); @@ -121,8 +128,7 @@ { ventouse[i]->automate(); } - lecture_contacts(); - + //lecture_contacts(); if(end_game) { for(int i=0; i<NB_VENTOUSES;i++) @@ -141,7 +147,6 @@ if(contacts != prev_contacts) { prev_contacts = contacts; - //can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&prev_contacts,1)); } } @@ -153,7 +158,8 @@ etat_ventouses.type=CANData; etat_ventouses.data[0]=0; etat_ventouses.data[0]=1; - for(int i = (NB_VENTOUSES - 1); i >= 0; i--){ + for(int i = (NB_VENTOUSES - 1); i >= 0; i--) + { etat_ventouses.data[0] = (etat_ventouses.data[0]<<1) + ventouse[i]->getPompe(); etat_ventouses.data[1] = (etat_ventouses.data[1]<<1) + ventouse[i]->getPression(); }