carte esclave pompe 2020 V1
Dependencies: mbed ident_crac
Diff: main.cpp
- Revision:
- 22:f104afbecb98
- Parent:
- 21:42d6cead9cc2
- Child:
- 23:7f62f27c028f
diff -r 42d6cead9cc2 -r f104afbecb98 main.cpp --- a/main.cpp Sat Mar 07 17:40:59 2020 +0000 +++ b/main.cpp Sun Mar 08 23:05:13 2020 +0000 @@ -1,5 +1,4 @@ #include "extern.h" -#include "Asservissement.h" #define SIZE_FIFO 50 @@ -21,9 +20,6 @@ DigitalIn Contact8(PC_3, PullNone); void lecture_contacts(void); - - - void get_etat_ventouses(); @@ -58,77 +54,39 @@ char BRAS = 0; switch(identifiant) - { - - case HACHEUR_GET_ATOM: + { + //BRAS=data: donc savoir si data peut être envoyé + case VENTOUSE_ATTRAPER: BRAS = msgRxBuffer[FIFO_lecture].data[0]; ventouse[BRAS]->action(1); break; - case HACHEUR_RELEASE_ATOM: + case VENTOUSE_RELACHER: BRAS = msgRxBuffer[FIFO_lecture].data[0]; ventouse[BRAS]->action(0); break; - case HACHEUR_STATUT_VENTOUSES: + /*case HACHEUR_STATUT_VENTOUSES: get_etat_ventouses(); - break; + break;*/ case GLOBAL_GAME_END: end_game = 1; break; - case HACHEUR_ETAT_CONTACTS: + /*case HACHEUR_ETAT_CONTACTS: char contacts_tmp = contacts; can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&contacts_tmp,1)); - break;*/ + break; case TEST_VENT_1_ON: ventouse[AV_DROIT]->action(1); break; - - case TEST_VENT_2_ON: - ventouse[AV_CENTRE]->action(1); - break; - - case TEST_VENT_3_ON: - ventouse[AV_GAUCHE]->action(1); - break; - - case TEST_VENT_4_ON: - ventouse[AR_DROIT]->action(1); - break; - - case TEST_VENT_5_ON: - ventouse[AR_CENTRE]->action(1); - break; - - case TEST_VENT_6_ON: - ventouse[AR_GAUCHE]->action(1); - break; case TEST_VENT_1_OFF: ventouse[AV_GAUCHE]->action(0); - break; - - case TEST_VENT_2_OFF: - ventouse[AV_CENTRE]->action(0); - break; - - case TEST_VENT_3_OFF: - ventouse[AV_DROIT]->action(0); - break; - - case TEST_VENT_4_OFF: - ventouse[AR_GAUCHE]->action(0); - break; - - case TEST_VENT_5_OFF: - ventouse[AR_CENTRE]->action(0); - break; - - case TEST_VENT_6_OFF: - ventouse[AR_DROIT]->action(0); + break;*/ + default: break; } @@ -139,9 +97,8 @@ int main() { can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN - wait(1); + wait_ms(100); - pc.printf("\nPetit robot\n\n"); ventouse[AR_DROIT] = new Ventouse(PB_7, PB_6, PC_0, AV_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); @@ -150,7 +107,7 @@ 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"); + pc.printf("Launched carte ventouse"); ventouse[AV_DROIT]->action(0); ventouse[AV_CENTRE]->action(0); ventouse[AV_GAUCHE]->action(0); @@ -160,26 +117,27 @@ while(1) { canProcessRx(); - for(int i=0; i<NB_VENTOUSES; i++){ + for(int i=0; i<NB_VENTOUSES; i++) + { ventouse[i]->automate(); } lecture_contacts(); - - if(end_game){ - for(int i=0; i<NB_VENTOUSES;i++){ + if(end_game) + { + for(int i=0; i<NB_VENTOUSES;i++) + { ventouse[i]->setPompe(0.0); ventouse[i]->setElectrovanne(0); } - while(1){;} + while(1); } } } void lecture_contacts(void) { - static char prev_contacts = contacts; - + static char prev_contacts = contacts; if(contacts != prev_contacts) { prev_contacts = contacts; @@ -189,8 +147,7 @@ void get_etat_ventouses() { - CANMessage etat_ventouses = CANMessage(); - //tat_ventouses.id=HACHEUR_STATUT_VENTOUSES; + CANMessage etat_ventouses = CANMessage(); etat_ventouses.len=2; etat_ventouses.format=CANStandard; etat_ventouses.type=CANData; @@ -201,5 +158,4 @@ etat_ventouses.data[1] = (etat_ventouses.data[1]<<1) + ventouse[i]->getPression(); } can.write(etat_ventouses); - -} +} \ No newline at end of file