PINOUT à jour, trame CAN OK
Dependencies: mbed ident_crac
Code carte pompe
main.cpp@18:972d29c668a5, 2019-05-25 (annotated)
- Committer:
- kyxstark
- Date:
- Sat May 25 14:08:48 2019 +0000
- Revision:
- 18:972d29c668a5
- Parent:
- 17:fcfdd7de9039
ralentissement courroies du haut;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kyxstark | 12:2491a5b0f90b | 1 | |
marwanesaich | 4:82c90657da4a | 2 | #include "extern.h" |
kyxstark | 8:a25a9c22ba91 | 3 | #define SIZE_FIFO 50 |
marwanesaich | 1:8a55f1d5cb26 | 4 | |
kyxstark | 8:a25a9c22ba91 | 5 | |
marwanesaich | 0:84a8c24e29ae | 6 | |
kyxstark | 8:a25a9c22ba91 | 7 | |
marwanesaich | 0:84a8c24e29ae | 8 | CANMessage msgRxBuffer[SIZE_FIFO]; |
marwanesaich | 0:84a8c24e29ae | 9 | unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN |
marwanesaich | 0:84a8c24e29ae | 10 | signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN |
kyxstark | 8:a25a9c22ba91 | 11 | char end_game = 0; |
marwanesaich | 0:84a8c24e29ae | 12 | |
kyxstark | 8:a25a9c22ba91 | 13 | Ventouse* ventouse[NB_VENTOUSES]; |
kyxstark | 8:a25a9c22ba91 | 14 | |
kyxstark | 17:fcfdd7de9039 | 15 | BusIn contacts(PC_11, PC_12, PB_4, PB_5, PC_13, PC_14, PC_2, PC_3); |
kyxstark | 17:fcfdd7de9039 | 16 | DigitalIn Contact1(PC_11, PullNone); |
kyxstark | 17:fcfdd7de9039 | 17 | DigitalIn Contact2(PC_12, PullNone); |
kyxstark | 17:fcfdd7de9039 | 18 | DigitalIn Contact3(PB_4, PullNone); |
kyxstark | 17:fcfdd7de9039 | 19 | DigitalIn Contact4(PB_5, PullNone); |
kyxstark | 17:fcfdd7de9039 | 20 | DigitalIn Contact5(PC_13, PullNone); |
kyxstark | 17:fcfdd7de9039 | 21 | DigitalIn Contact6(PC_14, PullNone); |
kyxstark | 17:fcfdd7de9039 | 22 | DigitalIn Contact7(PC_2, PullNone); |
kyxstark | 17:fcfdd7de9039 | 23 | DigitalIn Contact8(PC_3, PullNone); |
kyxstark | 17:fcfdd7de9039 | 24 | |
kyxstark | 17:fcfdd7de9039 | 25 | void lecture_contacts(void); |
kyxstark | 17:fcfdd7de9039 | 26 | |
kyxstark | 8:a25a9c22ba91 | 27 | #ifdef ROBOT_SMALL |
kyxstark | 8:a25a9c22ba91 | 28 | |
kyxstark | 8:a25a9c22ba91 | 29 | #endif |
kyxstark | 8:a25a9c22ba91 | 30 | |
kyxstark | 8:a25a9c22ba91 | 31 | #ifdef ROBOT_BIG |
kyxstark | 17:fcfdd7de9039 | 32 | |
kyxstark | 8:a25a9c22ba91 | 33 | PwmOut ascenseur[8] = {PC_9, PA_8, PA_9, PA_10, PC_7, PC_8, PB_10 ,PB_2}; |
kyxstark | 18:972d29c668a5 | 34 | PwmOut* ascenseur_D = ascenseur; |
kyxstark | 18:972d29c668a5 | 35 | PwmOut* ascenseur_G = ascenseur+4; |
kyxstark | 8:a25a9c22ba91 | 36 | |
kyxstark | 18:972d29c668a5 | 37 | //ascenseur_D = ascenseur; |
kyxstark | 18:972d29c668a5 | 38 | //ascenseur_G = ascenseur + 4; |
kyxstark | 18:972d29c668a5 | 39 | |
kyxstark | 18:972d29c668a5 | 40 | #define VIT_COURROIE_HAUT_V 0.5 |
kyxstark | 18:972d29c668a5 | 41 | #define VIT_COURROIE_HAUT_L 0.4 |
kyxstark | 18:972d29c668a5 | 42 | #define VIT_COURROIE_BAS_V 0.6 |
kyxstark | 18:972d29c668a5 | 43 | #define VIT_COURROIE_BAS_L 0.5 |
kyxstark | 8:a25a9c22ba91 | 44 | |
kyxstark | 8:a25a9c22ba91 | 45 | void set_ascensseur(int allume); |
kyxstark | 8:a25a9c22ba91 | 46 | #endif |
kyxstark | 8:a25a9c22ba91 | 47 | |
marwanesaich | 0:84a8c24e29ae | 48 | |
marwanesaich | 0:84a8c24e29ae | 49 | |
marwanesaich | 0:84a8c24e29ae | 50 | void get_etat_ventouses(); |
marwanesaich | 0:84a8c24e29ae | 51 | |
kyxstark | 8:a25a9c22ba91 | 52 | |
marwanesaich | 2:4cc8fa2f64be | 53 | CAN can(PB_8,PB_9,1000000); |
marwanesaich | 2:4cc8fa2f64be | 54 | Serial pc(USBTX,USBRX); |
marwanesaich | 0:84a8c24e29ae | 55 | |
marwanesaich | 0:84a8c24e29ae | 56 | /*********************************************************************************************************/ |
marwanesaich | 0:84a8c24e29ae | 57 | /* FUNCTION NAME: canRx_ISR */ |
marwanesaich | 0:84a8c24e29ae | 58 | /* DESCRIPTION : lit les messages sur le can et les stocke dans la FIFO */ |
marwanesaich | 0:84a8c24e29ae | 59 | /*********************************************************************************************************/ |
marwanesaich | 0:84a8c24e29ae | 60 | void canRx_ISR (void) |
marwanesaich | 0:84a8c24e29ae | 61 | { |
marwanesaich | 0:84a8c24e29ae | 62 | if (can.read(msgRxBuffer[FIFO_ecriture])) |
marwanesaich | 0:84a8c24e29ae | 63 | FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO; |
marwanesaich | 0:84a8c24e29ae | 64 | } |
marwanesaich | 0:84a8c24e29ae | 65 | |
marwanesaich | 0:84a8c24e29ae | 66 | |
marwanesaich | 0:84a8c24e29ae | 67 | /*********************************************************************************************************/ |
marwanesaich | 0:84a8c24e29ae | 68 | /* FUNCTION NAME: canProcessRx */ |
marwanesaich | 0:84a8c24e29ae | 69 | /* DESCRIPTION : Fonction de traitement des messages CAN */ |
marwanesaich | 0:84a8c24e29ae | 70 | /*********************************************************************************************************/ |
marwanesaich | 0:84a8c24e29ae | 71 | void canProcessRx(void){ |
marwanesaich | 0:84a8c24e29ae | 72 | static signed char FIFO_occupation=0,FIFO_max_occupation=0; |
marwanesaich | 0:84a8c24e29ae | 73 | CANMessage msgTx=CANMessage(); |
marwanesaich | 0:84a8c24e29ae | 74 | FIFO_occupation=FIFO_ecriture-FIFO_lecture; |
marwanesaich | 0:84a8c24e29ae | 75 | if(FIFO_occupation<0) |
marwanesaich | 0:84a8c24e29ae | 76 | FIFO_occupation=FIFO_occupation+SIZE_FIFO; |
marwanesaich | 0:84a8c24e29ae | 77 | if(FIFO_max_occupation<FIFO_occupation) |
marwanesaich | 0:84a8c24e29ae | 78 | FIFO_max_occupation=FIFO_occupation; |
marwanesaich | 0:84a8c24e29ae | 79 | if(FIFO_occupation!=0) { |
marwanesaich | 0:84a8c24e29ae | 80 | int identifiant=msgRxBuffer[FIFO_lecture].id; |
marwanesaich | 1:8a55f1d5cb26 | 81 | char BRAS = 0; |
marwanesaich | 1:8a55f1d5cb26 | 82 | |
marwanesaich | 0:84a8c24e29ae | 83 | switch(identifiant){ |
marwanesaich | 0:84a8c24e29ae | 84 | |
marwanesaich | 0:84a8c24e29ae | 85 | case HACHEUR_GET_ATOM: |
marwanesaich | 1:8a55f1d5cb26 | 86 | BRAS = msgRxBuffer[FIFO_lecture].data[0]; |
marwanesaich | 2:4cc8fa2f64be | 87 | ventouse[BRAS]->action(1); |
marwanesaich | 0:84a8c24e29ae | 88 | break; |
kyxstark | 8:a25a9c22ba91 | 89 | |
marwanesaich | 0:84a8c24e29ae | 90 | case HACHEUR_RELEASE_ATOM: |
marwanesaich | 1:8a55f1d5cb26 | 91 | BRAS = msgRxBuffer[FIFO_lecture].data[0]; |
marwanesaich | 2:4cc8fa2f64be | 92 | ventouse[BRAS]->action(0); |
kyxstark | 8:a25a9c22ba91 | 93 | break; |
kyxstark | 8:a25a9c22ba91 | 94 | |
kyxstark | 8:a25a9c22ba91 | 95 | case HACHEUR_STATUT_VENTOUSES: |
kyxstark | 8:a25a9c22ba91 | 96 | get_etat_ventouses(); |
kyxstark | 8:a25a9c22ba91 | 97 | break; |
kyxstark | 8:a25a9c22ba91 | 98 | |
kyxstark | 8:a25a9c22ba91 | 99 | case GLOBAL_GAME_END: |
kyxstark | 8:a25a9c22ba91 | 100 | end_game = 1; |
kyxstark | 8:a25a9c22ba91 | 101 | break; |
kyxstark | 17:fcfdd7de9039 | 102 | |
kyxstark | 17:fcfdd7de9039 | 103 | case HACHEUR_ETAT_CONTACTS: |
kyxstark | 17:fcfdd7de9039 | 104 | char contacts_tmp = contacts; |
kyxstark | 17:fcfdd7de9039 | 105 | can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&contacts_tmp,1)); |
kyxstark | 17:fcfdd7de9039 | 106 | break; |
kyxstark | 8:a25a9c22ba91 | 107 | |
kyxstark | 8:a25a9c22ba91 | 108 | #ifdef ROBOT_SMALL |
kyxstark | 8:a25a9c22ba91 | 109 | |
marwanesaich | 0:84a8c24e29ae | 110 | |
marwanesaich | 4:82c90657da4a | 111 | case HACHEUR_GET_PRESENTOIR_AR: |
marwanesaich | 5:176e7353ba1c | 112 | ventouse[AR_GAUCHE]->action(1); |
marwanesaich | 5:176e7353ba1c | 113 | ventouse[AR_CENTRE]->action(1); |
marwanesaich | 5:176e7353ba1c | 114 | ventouse[AR_DROIT]->action(1); |
marwanesaich | 0:84a8c24e29ae | 115 | break; |
marwanesaich | 0:84a8c24e29ae | 116 | |
marwanesaich | 5:176e7353ba1c | 117 | case HACHEUR_RELEASE_AR: |
marwanesaich | 5:176e7353ba1c | 118 | ventouse[AR_GAUCHE]->action(0); |
marwanesaich | 5:176e7353ba1c | 119 | ventouse[AR_CENTRE]->action(0); |
marwanesaich | 5:176e7353ba1c | 120 | ventouse[AR_DROIT]->action(0); |
marwanesaich | 5:176e7353ba1c | 121 | break; |
marwanesaich | 5:176e7353ba1c | 122 | |
marwanesaich | 1:8a55f1d5cb26 | 123 | case HACHEUR_GET_PRESENTOIR_AV : |
marwanesaich | 5:176e7353ba1c | 124 | ventouse[AV_GAUCHE]->action(1); |
marwanesaich | 5:176e7353ba1c | 125 | ventouse[AV_CENTRE]->action(1); |
marwanesaich | 5:176e7353ba1c | 126 | ventouse[AV_DROIT]->action(1); |
marwanesaich | 0:84a8c24e29ae | 127 | break; |
marwanesaich | 0:84a8c24e29ae | 128 | |
marwanesaich | 5:176e7353ba1c | 129 | case HACHEUR_RELEASE_AV : |
marwanesaich | 5:176e7353ba1c | 130 | ventouse[AV_GAUCHE]->action(0); |
marwanesaich | 5:176e7353ba1c | 131 | ventouse[AV_CENTRE]->action(0); |
marwanesaich | 5:176e7353ba1c | 132 | ventouse[AV_DROIT]->action(0); |
marwanesaich | 5:176e7353ba1c | 133 | break; |
marwanesaich | 5:176e7353ba1c | 134 | |
kyxstark | 8:a25a9c22ba91 | 135 | |
kyxstark | 8:a25a9c22ba91 | 136 | |
kyxstark | 8:a25a9c22ba91 | 137 | #endif |
kyxstark | 8:a25a9c22ba91 | 138 | |
kyxstark | 8:a25a9c22ba91 | 139 | #ifdef ROBOT_BIG |
kyxstark | 8:a25a9c22ba91 | 140 | |
kyxstark | 8:a25a9c22ba91 | 141 | case HACHEUR_GET_PRESENTOIR_AV : |
kyxstark | 13:178eaf022d60 | 142 | ventouse[AV_GAUCHE]->action(1); |
kyxstark | 13:178eaf022d60 | 143 | ventouse[AV_CENTRE]->action(1); |
kyxstark | 13:178eaf022d60 | 144 | ventouse[AV_DROIT]->action(1); |
marwanesaich | 0:84a8c24e29ae | 145 | break; |
marwanesaich | 0:84a8c24e29ae | 146 | |
kyxstark | 8:a25a9c22ba91 | 147 | case HACHEUR_RELEASE_AV : |
kyxstark | 13:178eaf022d60 | 148 | ventouse[AV_GAUCHE]->action(0); |
kyxstark | 13:178eaf022d60 | 149 | ventouse[AV_CENTRE]->action(0); |
kyxstark | 13:178eaf022d60 | 150 | ventouse[AV_DROIT]->action(0); |
marwanesaich | 0:84a8c24e29ae | 151 | break; |
kyxstark | 8:a25a9c22ba91 | 152 | |
kyxstark | 9:8193c05bd0a0 | 153 | case HACHEUR_ID_COUROIES : |
kyxstark | 8:a25a9c22ba91 | 154 | set_ascensseur(msgRxBuffer[FIFO_lecture].data[0]); |
kyxstark | 8:a25a9c22ba91 | 155 | break; |
marwanesaich | 0:84a8c24e29ae | 156 | |
marwanesaich | 0:84a8c24e29ae | 157 | #endif |
marwanesaich | 0:84a8c24e29ae | 158 | } |
marwanesaich | 0:84a8c24e29ae | 159 | FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO; |
marwanesaich | 0:84a8c24e29ae | 160 | } |
marwanesaich | 0:84a8c24e29ae | 161 | } |
marwanesaich | 0:84a8c24e29ae | 162 | |
marwanesaich | 0:84a8c24e29ae | 163 | int main() { |
marwanesaich | 0:84a8c24e29ae | 164 | |
marwanesaich | 0:84a8c24e29ae | 165 | can.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN |
marwanesaich | 0:84a8c24e29ae | 166 | wait(1); |
marwanesaich | 1:8a55f1d5cb26 | 167 | #ifdef ROBOT_SMALL |
kyxstark | 10:765b4ff6d721 | 168 | pc.printf("\nPetit robot\n\n"); |
marwanesaich | 16:5e00af31ae8a | 169 | ventouse[AV_GAUCHE] = new Ventouse(PB_7, PB_6, PC_0, AV_GAUCHE); |
marwanesaich | 2:4cc8fa2f64be | 170 | ventouse[AR_CENTRE] = new Ventouse(PC_9, PA_8, PB_0, AR_CENTRE); |
marwanesaich | 2:4cc8fa2f64be | 171 | ventouse[AR_DROIT] = new Ventouse(PA_9, PA_10, PB_1, AR_DROIT); |
marwanesaich | 5:176e7353ba1c | 172 | //ventouse[AR_BAS] = new Ventouse(PA_11, PA_15, PC_1, AR_BAS); |
marwanesaich | 5:176e7353ba1c | 173 | ventouse[AR_BAS] = new Ventouse(PA_11, PC_1, AR_BAS); |
marwanesaich | 0:84a8c24e29ae | 174 | |
marwanesaich | 16:5e00af31ae8a | 175 | ventouse[AV_DROIT] = new Ventouse(PA_0, PA_1, PA_4, AV_DROIT); |
marwanesaich | 2:4cc8fa2f64be | 176 | ventouse[AV_CENTRE] = new Ventouse(PC_7,PC_8 , PC_5, AV_CENTRE); |
marwanesaich | 4:82c90657da4a | 177 | ventouse[AR_GAUCHE] = new Ventouse(PB_10, PB_2, PC_4, AR_GAUCHE); |
marwanesaich | 5:176e7353ba1c | 178 | //ventouse[AV_BAS] = new Ventouse(PA_6, PA_5, PA_7, AV_BAS); |
marwanesaich | 5:176e7353ba1c | 179 | ventouse[AV_BAS] = new Ventouse(PA_6, PA_7, AV_BAS); |
kyxstark | 8:a25a9c22ba91 | 180 | |
marwanesaich | 4:82c90657da4a | 181 | |
kyxstark | 8:a25a9c22ba91 | 182 | #endif |
kyxstark | 8:a25a9c22ba91 | 183 | |
kyxstark | 8:a25a9c22ba91 | 184 | #ifdef ROBOT_BIG |
kyxstark | 10:765b4ff6d721 | 185 | pc.printf("\nGros robot\n\n"); |
kyxstark | 13:178eaf022d60 | 186 | ventouse[AV_GAUCHE] = new Ventouse(PA_6, PA_5, PA_7, AV_GAUCHE); |
kyxstark | 13:178eaf022d60 | 187 | ventouse[AV_CENTRE] = new Ventouse(PA_0, PA_1, PA_4, AV_CENTRE); |
kyxstark | 13:178eaf022d60 | 188 | ventouse[AV_DROIT] = new Ventouse(PA_11, PA_15, PC_1, AV_DROIT); |
kyxstark | 8:a25a9c22ba91 | 189 | |
kyxstark | 8:a25a9c22ba91 | 190 | for (int i=0; i<8; i++){ |
kyxstark | 8:a25a9c22ba91 | 191 | ascenseur[i].period_us(50); |
kyxstark | 8:a25a9c22ba91 | 192 | } |
kyxstark | 8:a25a9c22ba91 | 193 | |
kyxstark | 8:a25a9c22ba91 | 194 | |
kyxstark | 8:a25a9c22ba91 | 195 | |
kyxstark | 8:a25a9c22ba91 | 196 | set_ascensseur(0); |
kyxstark | 8:a25a9c22ba91 | 197 | wait(1); |
marwanesaich | 1:8a55f1d5cb26 | 198 | #endif |
kyxstark | 8:a25a9c22ba91 | 199 | |
marwanesaich | 1:8a55f1d5cb26 | 200 | pc.printf("LAUNCHED"); |
marwanesaich | 0:84a8c24e29ae | 201 | while(1) { |
marwanesaich | 0:84a8c24e29ae | 202 | canProcessRx(); |
kyxstark | 8:a25a9c22ba91 | 203 | for(int i=0; i<NB_VENTOUSES; i++){ |
marwanesaich | 2:4cc8fa2f64be | 204 | ventouse[i]->automate(); |
kyxstark | 17:fcfdd7de9039 | 205 | } |
kyxstark | 17:fcfdd7de9039 | 206 | lecture_contacts(); |
kyxstark | 17:fcfdd7de9039 | 207 | |
kyxstark | 17:fcfdd7de9039 | 208 | |
marwanesaich | 0:84a8c24e29ae | 209 | if(end_game){ |
kyxstark | 8:a25a9c22ba91 | 210 | for(int i=0; i<NB_VENTOUSES;i++){ |
marwanesaich | 0:84a8c24e29ae | 211 | ventouse[i]->setPompe(0.0); |
kyxstark | 8:a25a9c22ba91 | 212 | ventouse[i]->setElectrovanne(0); |
marwanesaich | 0:84a8c24e29ae | 213 | } |
kyxstark | 17:fcfdd7de9039 | 214 | #ifdef ROBOT_BIG |
marwanesaich | 11:98dfe1a61df5 | 215 | set_ascensseur(0); |
kyxstark | 17:fcfdd7de9039 | 216 | #endif |
marwanesaich | 0:84a8c24e29ae | 217 | while(1){;} |
marwanesaich | 0:84a8c24e29ae | 218 | } |
marwanesaich | 0:84a8c24e29ae | 219 | } |
marwanesaich | 0:84a8c24e29ae | 220 | } |
marwanesaich | 0:84a8c24e29ae | 221 | |
kyxstark | 17:fcfdd7de9039 | 222 | void lecture_contacts(void) |
kyxstark | 17:fcfdd7de9039 | 223 | { |
kyxstark | 17:fcfdd7de9039 | 224 | static char prev_contacts = contacts; |
kyxstark | 17:fcfdd7de9039 | 225 | |
kyxstark | 17:fcfdd7de9039 | 226 | if(contacts != prev_contacts) |
kyxstark | 17:fcfdd7de9039 | 227 | { |
kyxstark | 17:fcfdd7de9039 | 228 | prev_contacts = contacts; |
kyxstark | 17:fcfdd7de9039 | 229 | can.write(CANMessage(HACHEUR_ETAT_CONTACTS,&prev_contacts,1)); |
kyxstark | 17:fcfdd7de9039 | 230 | } |
kyxstark | 17:fcfdd7de9039 | 231 | } |
kyxstark | 8:a25a9c22ba91 | 232 | #ifdef ROBOT_BIG |
kyxstark | 8:a25a9c22ba91 | 233 | void set_ascensseur(int allume){ |
kyxstark | 18:972d29c668a5 | 234 | /*PwmOut* vitH, vitL; |
kyxstark | 17:fcfdd7de9039 | 235 | switch(allume){ |
kyxstark | 17:fcfdd7de9039 | 236 | case 1: |
kyxstark | 18:972d29c668a5 | 237 | vitH = ascenseur_G; |
kyxstark | 18:972d29c668a5 | 238 | vitL = ascenseur_D; |
kyxstark | 17:fcfdd7de9039 | 239 | break; |
kyxstark | 17:fcfdd7de9039 | 240 | case 2: |
kyxstark | 18:972d29c668a5 | 241 | vitH = ascenseur_G; |
kyxstark | 18:972d29c668a5 | 242 | vitL = ascenseur_D; |
kyxstark | 17:fcfdd7de9039 | 243 | break; |
kyxstark | 17:fcfdd7de9039 | 244 | default: |
kyxstark | 17:fcfdd7de9039 | 245 | vitG = 0; |
kyxstark | 17:fcfdd7de9039 | 246 | vitD = 0; |
kyxstark | 17:fcfdd7de9039 | 247 | break; |
kyxstark | 8:a25a9c22ba91 | 248 | } |
kyxstark | 18:972d29c668a5 | 249 | for (int i=0; i<3; i++) |
kyxstark | 17:fcfdd7de9039 | 250 | { |
kyxstark | 18:972d29c668a5 | 251 | vitL[i] = VIT_COURROIE_BAS_L; |
kyxstark | 18:972d29c668a5 | 252 | vitH[i] = VIT_COURROIE_BAS_V; |
kyxstark | 8:a25a9c22ba91 | 253 | } |
kyxstark | 18:972d29c668a5 | 254 | |
kyxstark | 18:972d29c668a5 | 255 | vitL[3] = VIT_COURROIE_HEUT_L; |
kyxstark | 18:972d29c668a5 | 256 | vitH[3] = VIT_COURROIE_HAUT_V;*/ |
kyxstark | 18:972d29c668a5 | 257 | |
kyxstark | 18:972d29c668a5 | 258 | |
kyxstark | 18:972d29c668a5 | 259 | |
kyxstark | 18:972d29c668a5 | 260 | // float vitG, vitD, vitHG, vitHD; |
kyxstark | 18:972d29c668a5 | 261 | |
kyxstark | 18:972d29c668a5 | 262 | switch(allume){ |
kyxstark | 18:972d29c668a5 | 263 | case 1: |
kyxstark | 18:972d29c668a5 | 264 | /* |
kyxstark | 18:972d29c668a5 | 265 | vitG = VIT_COURROIE_BAS_V; |
kyxstark | 18:972d29c668a5 | 266 | vitD = VIT_COURROIE_BAS_L; |
kyxstark | 18:972d29c668a5 | 267 | vitHG = VIT_COURROIE_HAUT_V; |
kyxstark | 18:972d29c668a5 | 268 | vitHD = VIT_COURROIE_HEUT_L;*/ |
kyxstark | 18:972d29c668a5 | 269 | for (int i=0; i<3; i++) |
kyxstark | 18:972d29c668a5 | 270 | { |
kyxstark | 18:972d29c668a5 | 271 | ascenseur_D[i] = VIT_COURROIE_BAS_L; |
kyxstark | 18:972d29c668a5 | 272 | ascenseur_G[i] = VIT_COURROIE_BAS_V; |
kyxstark | 18:972d29c668a5 | 273 | } |
kyxstark | 18:972d29c668a5 | 274 | |
kyxstark | 18:972d29c668a5 | 275 | ascenseur_D[3] = VIT_COURROIE_HAUT_L; |
kyxstark | 18:972d29c668a5 | 276 | ascenseur_G[3] = VIT_COURROIE_HAUT_V; |
kyxstark | 18:972d29c668a5 | 277 | break; |
kyxstark | 18:972d29c668a5 | 278 | case 2: |
kyxstark | 18:972d29c668a5 | 279 | /* |
kyxstark | 18:972d29c668a5 | 280 | vitG = VIT_COURROIE_BAS_L; |
kyxstark | 18:972d29c668a5 | 281 | vitD = VIT_COURROIE_BAS_V; |
kyxstark | 18:972d29c668a5 | 282 | vitHG = VIT_COURROIE_HAUT_L; |
kyxstark | 18:972d29c668a5 | 283 | vitHD = VIT_COURROIE_HEUT_V;*/ |
kyxstark | 18:972d29c668a5 | 284 | for (int i=0; i<3; i++) |
kyxstark | 18:972d29c668a5 | 285 | { |
kyxstark | 18:972d29c668a5 | 286 | ascenseur_D[i] = VIT_COURROIE_BAS_V; |
kyxstark | 18:972d29c668a5 | 287 | ascenseur_G[i] = VIT_COURROIE_BAS_L; |
kyxstark | 18:972d29c668a5 | 288 | } |
kyxstark | 18:972d29c668a5 | 289 | |
kyxstark | 18:972d29c668a5 | 290 | ascenseur_D[3] = VIT_COURROIE_HAUT_V; |
kyxstark | 18:972d29c668a5 | 291 | ascenseur_G[3] = VIT_COURROIE_HAUT_L; |
kyxstark | 18:972d29c668a5 | 292 | break; |
kyxstark | 18:972d29c668a5 | 293 | default: |
kyxstark | 18:972d29c668a5 | 294 | for (int i=0; i<4; i++) |
kyxstark | 18:972d29c668a5 | 295 | { |
kyxstark | 18:972d29c668a5 | 296 | ascenseur_D[i] = 0; |
kyxstark | 18:972d29c668a5 | 297 | ascenseur_G[i] = 0; |
kyxstark | 18:972d29c668a5 | 298 | } |
kyxstark | 18:972d29c668a5 | 299 | break; |
kyxstark | 18:972d29c668a5 | 300 | } |
kyxstark | 18:972d29c668a5 | 301 | |
kyxstark | 18:972d29c668a5 | 302 | |
kyxstark | 18:972d29c668a5 | 303 | |
kyxstark | 18:972d29c668a5 | 304 | |
kyxstark | 8:a25a9c22ba91 | 305 | } |
kyxstark | 8:a25a9c22ba91 | 306 | #endif |
kyxstark | 8:a25a9c22ba91 | 307 | |
marwanesaich | 0:84a8c24e29ae | 308 | void get_etat_ventouses() |
marwanesaich | 0:84a8c24e29ae | 309 | { |
marwanesaich | 0:84a8c24e29ae | 310 | CANMessage etat_ventouses = CANMessage(); |
marwanesaich | 0:84a8c24e29ae | 311 | etat_ventouses.id=HACHEUR_STATUT_VENTOUSES; |
marwanesaich | 0:84a8c24e29ae | 312 | etat_ventouses.len=2; |
marwanesaich | 0:84a8c24e29ae | 313 | etat_ventouses.format=CANStandard; |
marwanesaich | 0:84a8c24e29ae | 314 | etat_ventouses.type=CANData; |
marwanesaich | 2:4cc8fa2f64be | 315 | etat_ventouses.data[0]=0; |
marwanesaich | 2:4cc8fa2f64be | 316 | etat_ventouses.data[0]=1; |
kyxstark | 10:765b4ff6d721 | 317 | for(int i = (NB_VENTOUSES - 1); i >= 0; i--){ |
marwanesaich | 0:84a8c24e29ae | 318 | etat_ventouses.data[0] = (etat_ventouses.data[0]<<1) + ventouse[i]->getPompe(); |
marwanesaich | 0:84a8c24e29ae | 319 | etat_ventouses.data[1] = (etat_ventouses.data[1]<<1) + ventouse[i]->getPression(); |
marwanesaich | 0:84a8c24e29ae | 320 | } |
marwanesaich | 0:84a8c24e29ae | 321 | can.write(etat_ventouses); |
marwanesaich | 0:84a8c24e29ae | 322 | |
marwanesaich | 0:84a8c24e29ae | 323 | } |