Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Strategie/Strategie.cpp@36:6dd30780bd8e, 2018-05-02 (annotated)
- Committer:
- Sitkah
- Date:
- Wed May 02 20:40:57 2018 +0000
- Revision:
- 36:6dd30780bd8e
- Parent:
- 35:742dc6b200b0
- Child:
- 37:fca332b64b42
Recalage en une fois
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sitkah | 35:742dc6b200b0 | 1 | #include "global.h" |
Sitkah | 31:833fc481b002 | 2 | #include <string.h> |
Sitkah | 31:833fc481b002 | 3 | #include <sstream> |
Sitkah | 29:41e02746041d | 4 | //#include "StrategieManager.h" |
Sitkah | 29:41e02746041d | 5 | |
Sitkah | 29:41e02746041d | 6 | |
Sitkah | 29:41e02746041d | 7 | |
Sitkah | 29:41e02746041d | 8 | #define M_PI 3.14159265358979323846 |
Sitkah | 35:742dc6b200b0 | 9 | #define VERT 0xFF00FF00 |
Sitkah | 29:41e02746041d | 10 | #define ROUGE 0xFFFF0000 |
Sitkah | 35:742dc6b200b0 | 11 | #define BLEU 0xFF0000FF |
Sitkah | 29:41e02746041d | 12 | #define JAUNE 0xFFFEFE00 |
Sitkah | 29:41e02746041d | 13 | #define BLANC 0xFF000000 |
Sitkah | 31:833fc481b002 | 14 | #define ORANGE 0xFFFFA500 |
Sitkah | 31:833fc481b002 | 15 | #define NOIR 0xFF000000 |
Sitkah | 29:41e02746041d | 16 | #define DIY_GREY 0xFFDFDFDF |
antbig | 0:ad97421fb1fb | 17 | |
Sitkah | 29:41e02746041d | 18 | char tableau_aff[10][50]; |
Sitkah | 29:41e02746041d | 19 | char tableau_etat[22][50]= |
Sitkah | 29:41e02746041d | 20 | { |
Sitkah | 29:41e02746041d | 21 | "Check_carte_screen", |
Sitkah | 29:41e02746041d | 22 | "Check_carte_screen_wait_ack", |
Sitkah | 29:41e02746041d | 23 | "Check_cartes", |
Sitkah | 29:41e02746041d | 24 | "Check_cartes_wait_ack", |
Sitkah | 29:41e02746041d | 25 | "Wait_force", |
Sitkah | 29:41e02746041d | 26 | "Config", |
Sitkah | 29:41e02746041d | 27 | "Game_init", |
Sitkah | 29:41e02746041d | 28 | "Game_wait_for_jack", |
Sitkah | 29:41e02746041d | 29 | "Game_start", |
Sitkah | 29:41e02746041d | 30 | "Game_next_instruction", |
Sitkah | 29:41e02746041d | 31 | "Game_instruction", |
Sitkah | 29:41e02746041d | 32 | "Game_wait_ack", |
Sitkah | 29:41e02746041d | 33 | "Game_jump_time", |
Sitkah | 29:41e02746041d | 34 | "Game_jump_config", |
Sitkah | 29:41e02746041d | 35 | "Game_jump_position", |
Sitkah | 29:41e02746041d | 36 | "Game_wait_end_instruction", |
Sitkah | 29:41e02746041d | 37 | "Warning_timeout", |
Sitkah | 29:41e02746041d | 38 | "Waring_end_balise_wait", |
Sitkah | 29:41e02746041d | 39 | "Warning_end_last_instruction", |
Sitkah | 29:41e02746041d | 40 | "Warning_switch_strategie", |
Sitkah | 29:41e02746041d | 41 | "End", |
Sitkah | 29:41e02746041d | 42 | "End_loop", |
Sitkah | 29:41e02746041d | 43 | }; |
Sitkah | 29:41e02746041d | 44 | |
Sitkah | 34:6aa4b46b102e | 45 | int waitingAckID_FIN; |
Sitkah | 34:6aa4b46b102e | 46 | int waitingAckFrom_FIN; |
Sitkah | 29:41e02746041d | 47 | |
Sitkah | 29:41e02746041d | 48 | Ticker ticker; |
Sitkah | 29:41e02746041d | 49 | TS_DISCO_F469NI ts; |
Sitkah | 29:41e02746041d | 50 | LCD_DISCO_F469NI lcd; |
Sitkah | 29:41e02746041d | 51 | |
Sitkah | 29:41e02746041d | 52 | TS_StateTypeDef TS_State; |
Sitkah | 29:41e02746041d | 53 | |
Sitkah | 29:41e02746041d | 54 | Ticker chrono; |
Sitkah | 29:41e02746041d | 55 | Timeout AffTime; |
Sitkah | 29:41e02746041d | 56 | Timer timer; |
antbig | 0:ad97421fb1fb | 57 | Timer cartesCheker;//Le timer pour le timeout de la vérification des cartes |
antbig | 0:ad97421fb1fb | 58 | Timer gameTimer; |
antbig | 0:ad97421fb1fb | 59 | Timer debugetatTimer; |
antbig | 5:dcd817534b57 | 60 | Timer timeoutWarning; |
antbig | 5:dcd817534b57 | 61 | Timer timeoutWarningWaitEnd; |
antbig | 0:ad97421fb1fb | 62 | Timeout chronoEnd;//permet d'envoyer la trame CAN pour la fin |
antbig | 0:ad97421fb1fb | 63 | |
Sitkah | 29:41e02746041d | 64 | unsigned char screenChecktry = 0; |
Sitkah | 29:41e02746041d | 65 | unsigned char test[32] = {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32}; |
Sitkah | 29:41e02746041d | 66 | |
Sitkah | 29:41e02746041d | 67 | char counter = 0; |
Sitkah | 29:41e02746041d | 68 | char check; |
Sitkah | 29:41e02746041d | 69 | char Jack = 1; |
Sitkah | 29:41e02746041d | 70 | |
Sitkah | 29:41e02746041d | 71 | int flag = 0, flag_strat = 0, flag_timer; |
Sitkah | 29:41e02746041d | 72 | char Ack_strat = 0; |
Sitkah | 29:41e02746041d | 73 | signed char Strat = 0; |
antbig | 0:ad97421fb1fb | 74 | signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN |
antbig | 0:ad97421fb1fb | 75 | |
antbig | 0:ad97421fb1fb | 76 | signed short x_robot,y_robot,theta_robot;//La position du robot |
ClementBreteau | 25:f140c93a8666 | 77 | signed short target_x_robot, target_y_robot, target_theta_robot; |
ClementBreteau | 25:f140c93a8666 | 78 | E_InstructionType actionPrecedente; |
antbig | 12:14729d584500 | 79 | signed short start_move_x,start_move_y,start_move_theta;//La position du robot lors du début d'un mouvement, utilisé pour reprendre le mouvement apres stop balise |
Sitkah | 29:41e02746041d | 80 | //unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN |
Sitkah | 29:41e02746041d | 81 | int flagSendCan=1; |
Sitkah | 34:6aa4b46b102e | 82 | unsigned char Cote = 0; //0 -> VERT | 1 -> jaune |
Sitkah | 35:742dc6b200b0 | 83 | unsigned short angleRecalage = 0; |
antbig | 0:ad97421fb1fb | 84 | unsigned char checkCurrent = 0; |
antbig | 0:ad97421fb1fb | 85 | unsigned char countAliveCard = 0; |
Sitkah | 35:742dc6b200b0 | 86 | unsigned char ligne=0; |
antbig | 0:ad97421fb1fb | 87 | |
Sitkah | 29:41e02746041d | 88 | signed char Strategie = 0; //N° de la strategie (1-10) |
antbig | 1:116040d14164 | 89 | |
ClementBreteau | 14:c8fc06c4887f | 90 | unsigned char ModeDemo = 0; // Si à 1, indique que l'on est dans le mode demo |
ClementBreteau | 14:c8fc06c4887f | 91 | |
antbig | 5:dcd817534b57 | 92 | unsigned char countRobotNear = 0;//Le nombre de robot à proximité |
antbig | 5:dcd817534b57 | 93 | |
antbig | 12:14729d584500 | 94 | unsigned char ingnorBaliseOnce = 0; |
antbig | 12:14729d584500 | 95 | |
antbig | 28:acd18776ed2d | 96 | unsigned char ingnorInversionOnce = 0;//Pour ignorer l'inversion des instruction une fois |
antbig | 28:acd18776ed2d | 97 | |
antbig | 28:acd18776ed2d | 98 | struct S_Instruction instruction; |
antbig | 28:acd18776ed2d | 99 | |
Sitkah | 30:a1e37af4bbde | 100 | char couleur1, couleur2, couleur3; |
Sitkah | 29:41e02746041d | 101 | float cptf; |
Sitkah | 29:41e02746041d | 102 | int cpt,cpt1; |
Sitkah | 29:41e02746041d | 103 | |
Sitkah | 32:1c9ab15c740e | 104 | typedef enum {INIT, ATT, CHOIX, DEMO, TEST_TELEMETRE, TEST_CAPTEURS, TEST_SERVO, TEST_TIR, DEMO_IMMEUBLE,DEMO_TRIEUR, SELECT_SIDE, TACTIQUE, DETAILS,LECTURE, LAUNCH, AFF_WAIT_JACK, WAIT_JACK, COMPTEUR, FIN} T_etat; |
Sitkah | 29:41e02746041d | 105 | T_etat etat = INIT; |
Sitkah | 29:41e02746041d | 106 | E_stratGameEtat gameEtat = ETAT_CHECK_CARTES; |
Sitkah | 29:41e02746041d | 107 | E_stratGameEtat lastEtat = ETAT_CHECK_CARTES; |
Sitkah | 29:41e02746041d | 108 | |
Sitkah | 29:41e02746041d | 109 | |
Sitkah | 29:41e02746041d | 110 | /////////////////DEFINITION DES BOUTONS//////////////////// |
Sitkah | 34:6aa4b46b102e | 111 | Button COTE_VERT(0, 25, 400, 300, "VERT"); |
Sitkah | 34:6aa4b46b102e | 112 | Button COTE_ORANGE(0, 350, 400, 300, "ORANGE"); |
Sitkah | 29:41e02746041d | 113 | Button RETOUR (0, 680, 400, 110, "--Precedent--"); |
Sitkah | 29:41e02746041d | 114 | Button LANCER (0, 200, 400, 200, "--LANCER--"); |
Sitkah | 29:41e02746041d | 115 | Button CHECK (0, 420, 400, 200, "Valider"); |
Sitkah | 29:41e02746041d | 116 | Button MATCH (0, 50, 400, 320, "Match"); |
Sitkah | 29:41e02746041d | 117 | Button DEMONSTRATION (0, 400, 400, 320, "Demo"); |
Sitkah | 31:833fc481b002 | 118 | Button TEST_HERKULEX(0, 25, 400, 100, "Test servos"); |
Sitkah | 32:1c9ab15c740e | 119 | Button TEST_LASER(0, 135, 400, 100, "Test telemetre"); |
Sitkah | 32:1c9ab15c740e | 120 | Button TEST_COULEURS(0,245,400,100,"Test capteurs"); |
Sitkah | 32:1c9ab15c740e | 121 | Button TEST_TIR_BALLE(0,355,400,100,"Test Lanceur"); |
Sitkah | 32:1c9ab15c740e | 122 | Button TEST_IMMEUBLE(0,465,400,100,"Test immeuble"); |
Sitkah | 32:1c9ab15c740e | 123 | Button TEST_TRIEUR(0,575,400,100,"Test aiguilleur"); |
Sitkah | 31:833fc481b002 | 124 | Button TIR_CHATEAU(0, 25, 400, 100, "Tir chateau"); |
Sitkah | 31:833fc481b002 | 125 | Button EPURATION(0, 150, 400, 100, "epuration"); |
Sitkah | 31:833fc481b002 | 126 | Button LANCEUR_ON(0,275,400,100,"allumer le lanceur"); |
Sitkah | 31:833fc481b002 | 127 | Button LANCEUR_OFF(0,400,400,100,"eteindre le lanceur"); |
Sitkah | 31:833fc481b002 | 128 | Button ABAISSE_BLOC(0, 25, 400, 100, "Ramasser blocs"); |
Sitkah | 31:833fc481b002 | 129 | Button RELEVE_BLOC(0, 135, 400, 100, "lacher blocs"); |
Sitkah | 31:833fc481b002 | 130 | Button BRAS_ABEILLE_ON(0,245,400,100,"bras abeille"); |
Sitkah | 32:1c9ab15c740e | 131 | Button BRAS_ABEILLE_OFF(0,355,400,100,"baisser bras abeille"); |
Sitkah | 31:833fc481b002 | 132 | Button INTERRUPTEUR_ON(0,465,400,100,"baisser bras interrupt"); |
Sitkah | 31:833fc481b002 | 133 | Button INTERRUPTEUR_OFF(0,575,400,100,"baisser bras interrupt"); |
Sitkah | 29:41e02746041d | 134 | Button FORCE_LAUNCH(0, 50, 400, 320, "Force Launch"); |
Sitkah | 32:1c9ab15c740e | 135 | Button TRI(0, 25, 400, 100, "Test tri"); |
Sitkah | 32:1c9ab15c740e | 136 | Button AIGUILLEUR_D(0, 150, 400, 100, "aiguilleur droite"); |
Sitkah | 32:1c9ab15c740e | 137 | Button AIGUILLEUR_G(0,275,400,100,"aiguilleur gauche"); |
Sitkah | 32:1c9ab15c740e | 138 | Button AIGUILLEUR_CTRE(0,400,400,100,"aiguilleur centre"); |
Sitkah | 29:41e02746041d | 139 | Button SUIVANT(0,380,200,100,"Suivant"); |
Sitkah | 31:833fc481b002 | 140 | Button COLOR_ORANGE (0, 230, 190, 110,""); |
Sitkah | 31:833fc481b002 | 141 | Button COLOR_JAUNE (210, 230, 190, 110,""); |
Sitkah | 34:6aa4b46b102e | 142 | Button COLOR_VERT (0, 350, 190, 110,""); |
Sitkah | 34:6aa4b46b102e | 143 | Button COLOR_BLEU (210, 350, 190, 110,""); |
Sitkah | 31:833fc481b002 | 144 | Button COLOR_NOIR (105, 470, 190, 110,""); |
Sitkah | 29:41e02746041d | 145 | //////////////////////////////////////////////////////////// |
Sitkah | 29:41e02746041d | 146 | |
Sitkah | 29:41e02746041d | 147 | void SendRawId (unsigned short id); |
Sitkah | 29:41e02746041d | 148 | void SelectionStrat (unsigned char numeroStrat); |
Sitkah | 29:41e02746041d | 149 | void Setflag(void); |
Sitkah | 29:41e02746041d | 150 | void can2Rx_ISR(void); |
Sitkah | 29:41e02746041d | 151 | signed char Bouton_Strat (void); |
Sitkah | 29:41e02746041d | 152 | |
Sitkah | 29:41e02746041d | 153 | void print_segment(int nombre, int decalage); |
Sitkah | 29:41e02746041d | 154 | void affichage_compteur (int nombre); |
Sitkah | 29:41e02746041d | 155 | void effacer_segment(long couleur); |
Sitkah | 29:41e02746041d | 156 | |
Sitkah | 30:a1e37af4bbde | 157 | unsigned short telemetreDistance=0; |
Sitkah | 34:6aa4b46b102e | 158 | unsigned short telemetreDistance_avant_gauche=0; |
Sitkah | 34:6aa4b46b102e | 159 | unsigned short telemetreDistance_avant_droite=0; |
Sitkah | 34:6aa4b46b102e | 160 | unsigned short telemetreDistance_arriere_gauche=0; |
Sitkah | 34:6aa4b46b102e | 161 | unsigned short telemetreDistance_arriere_droite=0; |
Sitkah | 29:41e02746041d | 162 | |
Sitkah | 29:41e02746041d | 163 | #ifdef ROBOT_BIG |
Sitkah | 29:41e02746041d | 164 | |
Sitkah | 29:41e02746041d | 165 | |
Sitkah | 29:41e02746041d | 166 | unsigned short id_check[NOMBRE_CARTES]= {CHECK_MOTEUR,CHECK_BALISE,CHECK_ACTIONNEURS_AVANT,CHECK_ACTIONNEURS_ARRIERE}; |
Sitkah | 29:41e02746041d | 167 | unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_MOTEUR,ALIVE_BALISE,ALIVE_ACTIONNEURS_AVANT,ALIVE_ACTIONNEURS_ARRIERE}; |
Sitkah | 29:41e02746041d | 168 | |
Sitkah | 31:833fc481b002 | 169 | InterruptIn jack(PG_11); // entrée analogique en interruption pour le jack |
Sitkah | 29:41e02746041d | 170 | #else |
Sitkah | 29:41e02746041d | 171 | |
Sitkah | 29:41e02746041d | 172 | |
Sitkah | 29:41e02746041d | 173 | unsigned short id_check[NOMBRE_CARTES]= {CHECK_MOTEUR}; |
Sitkah | 29:41e02746041d | 174 | unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_MOTEUR}; |
Sitkah | 31:833fc481b002 | 175 | InterruptIn jack(PG_11); // entrée analogique en interruption pour le jack |
Sitkah | 29:41e02746041d | 176 | |
Sitkah | 29:41e02746041d | 177 | |
Sitkah | 29:41e02746041d | 178 | #endif |
Sitkah | 29:41e02746041d | 179 | |
Sitkah | 29:41e02746041d | 180 | |
Sitkah | 29:41e02746041d | 181 | |
Sitkah | 29:41e02746041d | 182 | |
Sitkah | 29:41e02746041d | 183 | |
ClementBreteau | 14:c8fc06c4887f | 184 | |
antbig | 4:88431b537477 | 185 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 186 | /* FUNCTION NAME: chronometre_ISR */ |
antbig | 4:88431b537477 | 187 | /* DESCRIPTION : Interruption à la fin des 90s du match */ |
antbig | 4:88431b537477 | 188 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 189 | void chronometre_ISR (void) |
antbig | 0:ad97421fb1fb | 190 | { |
antbig | 0:ad97421fb1fb | 191 | SendRawId(ASSERVISSEMENT_STOP);//On stope les moteurs |
antbig | 0:ad97421fb1fb | 192 | SendRawId(GLOBAL_GAME_END);//Indication fin de match |
Sitkah | 29:41e02746041d | 193 | etat=FIN; |
antbig | 0:ad97421fb1fb | 194 | gameTimer.stop();//Arret du timer |
antbig | 0:ad97421fb1fb | 195 | |
antbig | 1:116040d14164 | 196 | #ifdef ROBOT_BIG |
antbig | 12:14729d584500 | 197 | wait_ms(2000); |
antbig | 0:ad97421fb1fb | 198 | doFunnyAction(); |
antbig | 0:ad97421fb1fb | 199 | #endif |
antbig | 0:ad97421fb1fb | 200 | |
antbig | 1:116040d14164 | 201 | while(1);//On bloque la programme dans l'interruption |
antbig | 0:ad97421fb1fb | 202 | } |
antbig | 0:ad97421fb1fb | 203 | |
Sitkah | 29:41e02746041d | 204 | |
Sitkah | 29:41e02746041d | 205 | |
antbig | 4:88431b537477 | 206 | /****************************************************************************************/ |
antbig | 8:0edc7dfb7f7e | 207 | /* FUNCTION NAME: jack_ISR */ |
antbig | 8:0edc7dfb7f7e | 208 | /* DESCRIPTION : Interruption en changement d'état sur le Jack */ |
antbig | 8:0edc7dfb7f7e | 209 | /****************************************************************************************/ |
antbig | 8:0edc7dfb7f7e | 210 | void jack_ISR (void) |
antbig | 8:0edc7dfb7f7e | 211 | { |
antbig | 8:0edc7dfb7f7e | 212 | if(gameEtat == ETAT_GAME_WAIT_FOR_JACK) { |
antbig | 8:0edc7dfb7f7e | 213 | gameEtat = ETAT_GAME_START;//On débute le match |
Sitkah | 29:41e02746041d | 214 | etat=COMPTEUR; |
antbig | 8:0edc7dfb7f7e | 215 | } |
antbig | 8:0edc7dfb7f7e | 216 | } |
antbig | 8:0edc7dfb7f7e | 217 | |
antbig | 8:0edc7dfb7f7e | 218 | /****************************************************************************************/ |
Sitkah | 29:41e02746041d | 219 | /* FUNCTION NAME: SelectionStrat */ |
Sitkah | 29:41e02746041d | 220 | /* DESCRIPTION : Affiche la Stratégie sélectionnée sur l'ihm */ |
Sitkah | 29:41e02746041d | 221 | /****************************************************************************************/ |
Sitkah | 29:41e02746041d | 222 | |
Sitkah | 29:41e02746041d | 223 | |
Sitkah | 29:41e02746041d | 224 | void SelectionStrat (unsigned char Strategie) |
Sitkah | 29:41e02746041d | 225 | { |
Sitkah | 29:41e02746041d | 226 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 227 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 228 | |
Sitkah | 29:41e02746041d | 229 | switch (Strategie+1) |
Sitkah | 29:41e02746041d | 230 | { |
Sitkah | 29:41e02746041d | 231 | case 0x1 : |
Sitkah | 29:41e02746041d | 232 | //description de Strategie n°1 |
Sitkah | 29:41e02746041d | 233 | lcd.DisplayStringAt(150, 0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 234 | break; |
Sitkah | 29:41e02746041d | 235 | |
Sitkah | 29:41e02746041d | 236 | case 0x2 : |
Sitkah | 29:41e02746041d | 237 | //description de Strategie n°2 |
Sitkah | 29:41e02746041d | 238 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 239 | break; |
Sitkah | 29:41e02746041d | 240 | |
Sitkah | 29:41e02746041d | 241 | case 0x3 : |
Sitkah | 29:41e02746041d | 242 | //description de Strategie n°3 |
Sitkah | 29:41e02746041d | 243 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 244 | break; |
Sitkah | 29:41e02746041d | 245 | |
Sitkah | 29:41e02746041d | 246 | case 0x4 : |
Sitkah | 29:41e02746041d | 247 | //description de Strategie n°4 |
Sitkah | 29:41e02746041d | 248 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 249 | break; |
Sitkah | 29:41e02746041d | 250 | |
Sitkah | 29:41e02746041d | 251 | case 0x5 : |
Sitkah | 29:41e02746041d | 252 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 253 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 254 | break; |
Sitkah | 29:41e02746041d | 255 | |
Sitkah | 29:41e02746041d | 256 | case 0x6 : |
Sitkah | 29:41e02746041d | 257 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 258 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 259 | break; |
Sitkah | 29:41e02746041d | 260 | |
Sitkah | 29:41e02746041d | 261 | case 0x7 : |
Sitkah | 29:41e02746041d | 262 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 263 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 264 | break; |
Sitkah | 29:41e02746041d | 265 | |
Sitkah | 29:41e02746041d | 266 | case 0x8 : |
Sitkah | 29:41e02746041d | 267 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 268 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 269 | break; |
Sitkah | 29:41e02746041d | 270 | |
Sitkah | 29:41e02746041d | 271 | case 0x9 : |
Sitkah | 29:41e02746041d | 272 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 273 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 274 | break; |
Sitkah | 29:41e02746041d | 275 | |
Sitkah | 29:41e02746041d | 276 | case 0xA : |
Sitkah | 29:41e02746041d | 277 | //description de Strategie n°5 |
Sitkah | 29:41e02746041d | 278 | lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE); |
Sitkah | 29:41e02746041d | 279 | break; |
Sitkah | 29:41e02746041d | 280 | } |
Sitkah | 29:41e02746041d | 281 | } |
Sitkah | 29:41e02746041d | 282 | |
Sitkah | 29:41e02746041d | 283 | void Setflag(void) |
Sitkah | 29:41e02746041d | 284 | { |
Sitkah | 29:41e02746041d | 285 | flagSendCan = 1; |
Sitkah | 29:41e02746041d | 286 | } |
Sitkah | 29:41e02746041d | 287 | |
Sitkah | 35:742dc6b200b0 | 288 | void affichage_var(double Var){ |
Sitkah | 35:742dc6b200b0 | 289 | if(ligne==7) |
Sitkah | 35:742dc6b200b0 | 290 | ligne=0; |
Sitkah | 35:742dc6b200b0 | 291 | char aff[10]="toto"; |
Sitkah | 35:742dc6b200b0 | 292 | sprintf(aff,"%lf ",Var); |
Sitkah | 35:742dc6b200b0 | 293 | lcd.DisplayStringAt(120, LINE(5+(ligne)), (uint8_t *)aff, LEFT_MODE); |
Sitkah | 35:742dc6b200b0 | 294 | ligne++; |
Sitkah | 35:742dc6b200b0 | 295 | |
Sitkah | 35:742dc6b200b0 | 296 | } |
Sitkah | 35:742dc6b200b0 | 297 | |
Sitkah | 30:a1e37af4bbde | 298 | void affichage_debug(int Var){ |
Sitkah | 29:41e02746041d | 299 | int i; |
Sitkah | 29:41e02746041d | 300 | int conv=(int)Var; |
Sitkah | 29:41e02746041d | 301 | SUIVANT.Draw(ROUGE, 0); |
Sitkah | 29:41e02746041d | 302 | for(i=0;i<9;i++){ |
Sitkah | 29:41e02746041d | 303 | strcpy(tableau_aff[i],""); |
Sitkah | 29:41e02746041d | 304 | strcpy(tableau_aff[i],tableau_aff[i+1]); |
Sitkah | 29:41e02746041d | 305 | } |
Sitkah | 29:41e02746041d | 306 | strcpy(tableau_aff[9],tableau_etat[conv]); |
Sitkah | 29:41e02746041d | 307 | for(i=0;i<10;i++){ |
Sitkah | 34:6aa4b46b102e | 308 | lcd.SetBackColor(VERT); |
Sitkah | 29:41e02746041d | 309 | lcd.DisplayStringAt(0, LINE(20+i), (uint8_t *)tableau_aff[i], LEFT_MODE); |
Sitkah | 29:41e02746041d | 310 | } |
Sitkah | 30:a1e37af4bbde | 311 | /*while(!ack_bluetooth){ |
Sitkah | 30:a1e37af4bbde | 312 | //liaison_bluetooth(); |
Sitkah | 29:41e02746041d | 313 | } |
Sitkah | 30:a1e37af4bbde | 314 | ack_bluetooth=0;*/ |
Sitkah | 30:a1e37af4bbde | 315 | /*while(SUIVANT.Touched()==0); |
Sitkah | 30:a1e37af4bbde | 316 | while(SUIVANT.Touched());*/ |
Sitkah | 29:41e02746041d | 317 | } |
Sitkah | 29:41e02746041d | 318 | |
Sitkah | 29:41e02746041d | 319 | |
Sitkah | 29:41e02746041d | 320 | void automate_etat_ihm(void) |
Sitkah | 29:41e02746041d | 321 | { |
Sitkah | 29:41e02746041d | 322 | int j; |
Sitkah | 29:41e02746041d | 323 | if (j==0){ |
Sitkah | 29:41e02746041d | 324 | ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
Sitkah | 29:41e02746041d | 325 | j++; |
Sitkah | 29:41e02746041d | 326 | } |
Sitkah | 29:41e02746041d | 327 | ts.GetState(&TS_State); |
Sitkah | 29:41e02746041d | 328 | switch (etat) |
Sitkah | 29:41e02746041d | 329 | { |
Sitkah | 29:41e02746041d | 330 | case INIT : |
Sitkah | 29:41e02746041d | 331 | ts.GetState(&TS_State); |
Sitkah | 29:41e02746041d | 332 | canProcessRx(); |
Sitkah | 30:a1e37af4bbde | 333 | |
Sitkah | 32:1c9ab15c740e | 334 | |
Sitkah | 30:a1e37af4bbde | 335 | |
Sitkah | 30:a1e37af4bbde | 336 | |
Sitkah | 29:41e02746041d | 337 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 338 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 339 | lcd.Clear (LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 340 | wait(0.15); |
Sitkah | 29:41e02746041d | 341 | lcd.DisplayStringAt(0, 10, (uint8_t *)"Verification des cartes", LEFT_MODE); |
Sitkah | 29:41e02746041d | 342 | //cartes non verifiées//////////////// |
Sitkah | 29:41e02746041d | 343 | lcd.SetTextColor(DIY_GREY); |
Sitkah | 29:41e02746041d | 344 | lcd.FillRect(0,400,400,150); //carte moteur |
Sitkah | 29:41e02746041d | 345 | lcd.FillRect(0,600,400,150); //Balise |
Sitkah | 29:41e02746041d | 346 | |
Sitkah | 29:41e02746041d | 347 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 348 | lcd.SetBackColor(DIY_GREY); |
Sitkah | 29:41e02746041d | 349 | lcd.DisplayStringAt(80, 450, (uint8_t *)"Carte Moteur", LEFT_MODE); |
Sitkah | 29:41e02746041d | 350 | lcd.DisplayStringAt(110,650 , (uint8_t *)"Balise", LEFT_MODE); |
Sitkah | 29:41e02746041d | 351 | //////////////////////////////////////// |
Sitkah | 29:41e02746041d | 352 | |
Sitkah | 29:41e02746041d | 353 | FORCE_LAUNCH.Draw(0xFFFF0000, 0); |
Sitkah | 29:41e02746041d | 354 | |
Sitkah | 29:41e02746041d | 355 | /*while(flag == 0) |
Sitkah | 29:41e02746041d | 356 | { |
Sitkah | 29:41e02746041d | 357 | ts.GetState(&TS_State); |
Sitkah | 29:41e02746041d | 358 | canProcessRx(); |
Sitkah | 29:41e02746041d | 359 | if (FORCE_LAUNCH.Touched()) |
Sitkah | 29:41e02746041d | 360 | { |
Sitkah | 29:41e02746041d | 361 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 362 | gameEtat = ETAT_CONFIG; |
Sitkah | 29:41e02746041d | 363 | flag = 1; |
Sitkah | 29:41e02746041d | 364 | while(FORCE_LAUNCH.Touched()); |
Sitkah | 29:41e02746041d | 365 | } |
Sitkah | 29:41e02746041d | 366 | }*/ |
Sitkah | 29:41e02746041d | 367 | |
Sitkah | 29:41e02746041d | 368 | etat=ATT; |
Sitkah | 29:41e02746041d | 369 | break; |
Sitkah | 29:41e02746041d | 370 | |
Sitkah | 29:41e02746041d | 371 | case ATT : |
Sitkah | 29:41e02746041d | 372 | if (flag==1){ |
Sitkah | 29:41e02746041d | 373 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 374 | gameEtat = ETAT_CONFIG; |
Sitkah | 29:41e02746041d | 375 | } |
Sitkah | 29:41e02746041d | 376 | else if (FORCE_LAUNCH.Touched()){ |
Sitkah | 29:41e02746041d | 377 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 378 | gameEtat = ETAT_CONFIG; |
Sitkah | 30:a1e37af4bbde | 379 | while(FORCE_LAUNCH.Touched()); |
Sitkah | 29:41e02746041d | 380 | } |
Sitkah | 29:41e02746041d | 381 | |
Sitkah | 29:41e02746041d | 382 | break; |
Sitkah | 29:41e02746041d | 383 | |
Sitkah | 29:41e02746041d | 384 | |
Sitkah | 29:41e02746041d | 385 | case CHOIX : |
Sitkah | 29:41e02746041d | 386 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 387 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 388 | lcd.Clear (LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 389 | lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", LEFT_MODE); |
Sitkah | 29:41e02746041d | 390 | DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0); |
Sitkah | 29:41e02746041d | 391 | MATCH.Draw(0xFFF01010, 0); |
Sitkah | 29:41e02746041d | 392 | while(etat == CHOIX) |
Sitkah | 29:41e02746041d | 393 | { |
Sitkah | 29:41e02746041d | 394 | canProcessRx(); |
Sitkah | 29:41e02746041d | 395 | if(DEMONSTRATION.Touched()) |
Sitkah | 29:41e02746041d | 396 | { |
Sitkah | 29:41e02746041d | 397 | etat = DEMO; |
Sitkah | 29:41e02746041d | 398 | while(DEMONSTRATION.Touched()); |
Sitkah | 29:41e02746041d | 399 | } |
Sitkah | 29:41e02746041d | 400 | |
Sitkah | 29:41e02746041d | 401 | if(MATCH.Touched()) |
Sitkah | 29:41e02746041d | 402 | { |
Sitkah | 29:41e02746041d | 403 | etat = SELECT_SIDE; |
Sitkah | 29:41e02746041d | 404 | while(MATCH.Touched()); |
Sitkah | 29:41e02746041d | 405 | } |
Sitkah | 29:41e02746041d | 406 | |
Sitkah | 29:41e02746041d | 407 | } |
Sitkah | 29:41e02746041d | 408 | break; |
Sitkah | 29:41e02746041d | 409 | |
Sitkah | 29:41e02746041d | 410 | case DEMO : |
Sitkah | 29:41e02746041d | 411 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 412 | RETOUR.Draw(0xFFFF0000, 0); |
Sitkah | 34:6aa4b46b102e | 413 | TEST_HERKULEX.Draw(VERT, 0); |
Sitkah | 34:6aa4b46b102e | 414 | TEST_LASER.Draw(VERT, 0); |
Sitkah | 34:6aa4b46b102e | 415 | TEST_COULEURS.Draw(VERT, 0); |
Sitkah | 34:6aa4b46b102e | 416 | TEST_TIR_BALLE.Draw(VERT, 0); |
Sitkah | 34:6aa4b46b102e | 417 | TEST_IMMEUBLE.Draw(VERT,0); |
Sitkah | 34:6aa4b46b102e | 418 | TEST_TRIEUR.Draw(VERT,0); |
Sitkah | 29:41e02746041d | 419 | if(gameEtat == ETAT_CONFIG) {//C'est bon on a le droit de modifier les config // |
Sitkah | 29:41e02746041d | 420 | InversStrat = 0;//Pas d'inversion de la couleur // A changer , discussion avec l'ihm |
Sitkah | 29:41e02746041d | 421 | } |
Sitkah | 29:41e02746041d | 422 | while (etat == DEMO) |
Sitkah | 29:41e02746041d | 423 | { |
Sitkah | 29:41e02746041d | 424 | canProcessRx(); |
Sitkah | 31:833fc481b002 | 425 | if(TEST_HERKULEX.Touched()) |
Sitkah | 29:41e02746041d | 426 | { |
Sitkah | 30:a1e37af4bbde | 427 | //Strat = 0x10; |
Sitkah | 31:833fc481b002 | 428 | while(TEST_HERKULEX.Touched()); |
Sitkah | 32:1c9ab15c740e | 429 | CANMessage trame_Tx = CANMessage(); |
Sitkah | 32:1c9ab15c740e | 430 | trame_Tx.len = 1; |
Sitkah | 32:1c9ab15c740e | 431 | trame_Tx.format = CANStandard; |
Sitkah | 32:1c9ab15c740e | 432 | trame_Tx.type = CANData; |
Sitkah | 31:833fc481b002 | 433 | trame_Tx.id=CHOICE_COLOR; |
Sitkah | 32:1c9ab15c740e | 434 | trame_Tx.data[0]=0x2; |
Sitkah | 31:833fc481b002 | 435 | can2.write(trame_Tx); |
Sitkah | 31:833fc481b002 | 436 | TEST_HERKULEX.Draw(0xFFF0F0F0, 0); |
Sitkah | 31:833fc481b002 | 437 | etat = TEST_SERVO; |
Sitkah | 31:833fc481b002 | 438 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 30:a1e37af4bbde | 439 | ModeDemo=1; |
Sitkah | 29:41e02746041d | 440 | } |
Sitkah | 29:41e02746041d | 441 | |
Sitkah | 31:833fc481b002 | 442 | else if(TEST_LASER.Touched()) |
Sitkah | 31:833fc481b002 | 443 | { |
Sitkah | 31:833fc481b002 | 444 | //Strat = 0x11; |
Sitkah | 31:833fc481b002 | 445 | while(TEST_LASER.Touched()); |
Sitkah | 31:833fc481b002 | 446 | TEST_LASER.Draw(0xFFF0F0F0, 0); |
Sitkah | 31:833fc481b002 | 447 | etat = TEST_TELEMETRE; |
Sitkah | 31:833fc481b002 | 448 | } |
Sitkah | 31:833fc481b002 | 449 | else if (TEST_COULEURS.Touched()){ |
Sitkah | 31:833fc481b002 | 450 | while(TEST_COULEURS.Touched()); |
Sitkah | 31:833fc481b002 | 451 | TEST_LASER.Draw(0xFFF0F0F0, 0); |
Sitkah | 31:833fc481b002 | 452 | etat =TEST_CAPTEURS ; |
Sitkah | 31:833fc481b002 | 453 | } |
Sitkah | 31:833fc481b002 | 454 | else if (TEST_TIR_BALLE.Touched()){ |
Sitkah | 31:833fc481b002 | 455 | while(TEST_TIR_BALLE.Touched()); |
Sitkah | 31:833fc481b002 | 456 | TEST_TIR_BALLE.Draw(0xFFF0F0F0, 0); |
Sitkah | 31:833fc481b002 | 457 | etat =TEST_TIR ; |
Sitkah | 31:833fc481b002 | 458 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 32:1c9ab15c740e | 459 | CANMessage trame_Tx = CANMessage(); |
Sitkah | 32:1c9ab15c740e | 460 | trame_Tx.len = 1; |
Sitkah | 32:1c9ab15c740e | 461 | trame_Tx.format = CANStandard; |
Sitkah | 32:1c9ab15c740e | 462 | trame_Tx.type = CANData; |
Sitkah | 31:833fc481b002 | 463 | trame_Tx.id=CHOICE_COLOR; |
Sitkah | 32:1c9ab15c740e | 464 | trame_Tx.data[0]=0x2; |
Sitkah | 31:833fc481b002 | 465 | can2.write(trame_Tx); |
Sitkah | 31:833fc481b002 | 466 | ModeDemo=1; |
Sitkah | 31:833fc481b002 | 467 | } |
Sitkah | 31:833fc481b002 | 468 | else if(TEST_IMMEUBLE.Touched()){ |
Sitkah | 31:833fc481b002 | 469 | while(TEST_IMMEUBLE.Touched()); |
Sitkah | 31:833fc481b002 | 470 | TEST_IMMEUBLE.Draw(0xFFF0F0F0, 0); |
Sitkah | 31:833fc481b002 | 471 | etat =DEMO_IMMEUBLE; |
Sitkah | 31:833fc481b002 | 472 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 473 | } |
Sitkah | 32:1c9ab15c740e | 474 | else if(TEST_TRIEUR.Touched()){ |
Sitkah | 32:1c9ab15c740e | 475 | while(TEST_TRIEUR.Touched()); |
Sitkah | 32:1c9ab15c740e | 476 | etat=DEMO_TRIEUR; |
Sitkah | 32:1c9ab15c740e | 477 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 32:1c9ab15c740e | 478 | } |
Sitkah | 32:1c9ab15c740e | 479 | |
Sitkah | 32:1c9ab15c740e | 480 | |
Sitkah | 29:41e02746041d | 481 | if(RETOUR.Touched()) |
Sitkah | 29:41e02746041d | 482 | { |
Sitkah | 29:41e02746041d | 483 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 484 | while(RETOUR.Touched()); |
Sitkah | 31:833fc481b002 | 485 | |
Sitkah | 29:41e02746041d | 486 | } |
Sitkah | 29:41e02746041d | 487 | if(gameEtat == ETAT_CONFIG) {//C'est bon on a le droit de modifier les config |
Sitkah | 30:a1e37af4bbde | 488 | /*if (Strat< 0x10){ // Si la strat est une strat de match, on desactive le mode demo |
Sitkah | 29:41e02746041d | 489 | ModeDemo = 0; |
Sitkah | 29:41e02746041d | 490 | } |
Sitkah | 29:41e02746041d | 491 | else { // sinon, on active le mode demo, utile pour la fin de la demo |
Sitkah | 29:41e02746041d | 492 | ModeDemo = 1; |
Sitkah | 30:a1e37af4bbde | 493 | }*/ |
Sitkah | 29:41e02746041d | 494 | Ack_strat = 1; |
Sitkah | 29:41e02746041d | 495 | wait_ms(10); |
Sitkah | 30:a1e37af4bbde | 496 | //tactile_printf("Strat %d, Asser desactive",Strat); |
Sitkah | 29:41e02746041d | 497 | } |
Sitkah | 30:a1e37af4bbde | 498 | //SelectionStrat(Strategie); |
Sitkah | 29:41e02746041d | 499 | } |
Sitkah | 29:41e02746041d | 500 | break; |
Sitkah | 32:1c9ab15c740e | 501 | case DEMO_TRIEUR: |
Sitkah | 32:1c9ab15c740e | 502 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 32:1c9ab15c740e | 503 | lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); |
Sitkah | 32:1c9ab15c740e | 504 | TRI.Draw(VERT, 0); |
Sitkah | 32:1c9ab15c740e | 505 | AIGUILLEUR_D.Draw(VERT, 0); |
Sitkah | 32:1c9ab15c740e | 506 | AIGUILLEUR_G.Draw(VERT, 0); |
Sitkah | 32:1c9ab15c740e | 507 | AIGUILLEUR_CTRE.Draw(VERT, 0); |
Sitkah | 32:1c9ab15c740e | 508 | while(etat==DEMO_TRIEUR){ |
Sitkah | 32:1c9ab15c740e | 509 | if(RETOUR.Touched()){ |
Sitkah | 32:1c9ab15c740e | 510 | while (RETOUR.Touched()); |
Sitkah | 32:1c9ab15c740e | 511 | etat=DEMO; |
Sitkah | 32:1c9ab15c740e | 512 | } |
Sitkah | 32:1c9ab15c740e | 513 | else if(TRI.Touched()){ |
Sitkah | 32:1c9ab15c740e | 514 | while (TRI.Touched()); |
Sitkah | 32:1c9ab15c740e | 515 | SendRawId(AIGUILLEUR_CENTRE); |
Sitkah | 32:1c9ab15c740e | 516 | wait(0.5); |
Sitkah | 32:1c9ab15c740e | 517 | SendRawId(AIGUILLEUR_DROITE); |
Sitkah | 32:1c9ab15c740e | 518 | wait(0.5); |
Sitkah | 32:1c9ab15c740e | 519 | SendRawId(AIGUILLEUR_GAUCHE); |
Sitkah | 32:1c9ab15c740e | 520 | wait(0.5); |
Sitkah | 32:1c9ab15c740e | 521 | SendRawId(AIGUILLEUR_CENTRE); |
Sitkah | 32:1c9ab15c740e | 522 | |
Sitkah | 32:1c9ab15c740e | 523 | break; |
Sitkah | 32:1c9ab15c740e | 524 | } |
Sitkah | 32:1c9ab15c740e | 525 | else if(AIGUILLEUR_D.Touched()){ |
Sitkah | 32:1c9ab15c740e | 526 | while (AIGUILLEUR_D.Touched()); |
Sitkah | 32:1c9ab15c740e | 527 | SendRawId(AIGUILLEUR_DROITE); |
Sitkah | 32:1c9ab15c740e | 528 | break; |
Sitkah | 32:1c9ab15c740e | 529 | } |
Sitkah | 32:1c9ab15c740e | 530 | else if(AIGUILLEUR_G.Touched()){ |
Sitkah | 32:1c9ab15c740e | 531 | while (AIGUILLEUR_G.Touched()); |
Sitkah | 32:1c9ab15c740e | 532 | SendRawId(AIGUILLEUR_GAUCHE); |
Sitkah | 32:1c9ab15c740e | 533 | break; |
Sitkah | 32:1c9ab15c740e | 534 | |
Sitkah | 32:1c9ab15c740e | 535 | } |
Sitkah | 32:1c9ab15c740e | 536 | else if(BRAS_ABEILLE_OFF.Touched()){ |
Sitkah | 32:1c9ab15c740e | 537 | while (BRAS_ABEILLE_OFF.Touched()); |
Sitkah | 32:1c9ab15c740e | 538 | SendRawId(BRAS_ABEILLE_DOWN); |
Sitkah | 32:1c9ab15c740e | 539 | break; |
Sitkah | 32:1c9ab15c740e | 540 | } |
Sitkah | 32:1c9ab15c740e | 541 | else if(AIGUILLEUR_CTRE.Touched()){ |
Sitkah | 32:1c9ab15c740e | 542 | while (AIGUILLEUR_CTRE.Touched()); |
Sitkah | 32:1c9ab15c740e | 543 | SendRawId(AIGUILLEUR_CENTRE); |
Sitkah | 32:1c9ab15c740e | 544 | break; |
Sitkah | 32:1c9ab15c740e | 545 | } |
Sitkah | 32:1c9ab15c740e | 546 | |
Sitkah | 32:1c9ab15c740e | 547 | } |
Sitkah | 32:1c9ab15c740e | 548 | break; |
Sitkah | 31:833fc481b002 | 549 | case DEMO_IMMEUBLE: |
Sitkah | 31:833fc481b002 | 550 | int color=0; |
Sitkah | 31:833fc481b002 | 551 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 552 | lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"Choix du code couleur", LEFT_MODE); |
Sitkah | 29:41e02746041d | 553 | |
Sitkah | 31:833fc481b002 | 554 | CANMessage msgTx=CANMessage(); |
Sitkah | 31:833fc481b002 | 555 | msgTx.id=MONTER_IMMEUBLE; // Monter immeuble |
Sitkah | 31:833fc481b002 | 556 | msgTx.len=3; |
Sitkah | 31:833fc481b002 | 557 | msgTx.format=CANStandard; |
Sitkah | 31:833fc481b002 | 558 | msgTx.type=CANData; |
Sitkah | 29:41e02746041d | 559 | |
Sitkah | 29:41e02746041d | 560 | |
Sitkah | 31:833fc481b002 | 561 | while(etat==DEMO_IMMEUBLE){ |
Sitkah | 31:833fc481b002 | 562 | switch(color){ |
Sitkah | 31:833fc481b002 | 563 | case 0: |
Sitkah | 31:833fc481b002 | 564 | |
Sitkah | 31:833fc481b002 | 565 | RETOUR.Draw(ROUGE,0); |
Sitkah | 31:833fc481b002 | 566 | COLOR_NOIR.Draw(NOIR,1); |
Sitkah | 31:833fc481b002 | 567 | COLOR_ORANGE.Draw(ORANGE,0); |
Sitkah | 31:833fc481b002 | 568 | COLOR_JAUNE.Draw(JAUNE,0); |
Sitkah | 31:833fc481b002 | 569 | COLOR_VERT.Draw(VERT,0); |
Sitkah | 34:6aa4b46b102e | 570 | COLOR_BLEU.Draw(VERT,0); |
Sitkah | 31:833fc481b002 | 571 | |
Sitkah | 31:833fc481b002 | 572 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 573 | lcd.SetTextColor(NOIR); |
Sitkah | 31:833fc481b002 | 574 | lcd.DisplayStringAt(100, LINE(4), (uint8_t *)"COULEUR 1", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 575 | while(color==0){ |
Sitkah | 31:833fc481b002 | 576 | if(COLOR_ORANGE.Touched()){ |
Sitkah | 31:833fc481b002 | 577 | while(COLOR_ORANGE.Touched()); |
Sitkah | 31:833fc481b002 | 578 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 579 | msgTx.data[color]=1; |
Sitkah | 31:833fc481b002 | 580 | color++; |
Sitkah | 31:833fc481b002 | 581 | } |
Sitkah | 31:833fc481b002 | 582 | else if (COLOR_NOIR.Touched()){ |
Sitkah | 31:833fc481b002 | 583 | while(COLOR_NOIR.Touched()); |
Sitkah | 31:833fc481b002 | 584 | COLOR_NOIR.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 585 | msgTx.data[color]=2; |
Sitkah | 31:833fc481b002 | 586 | color++; |
Sitkah | 31:833fc481b002 | 587 | } |
Sitkah | 31:833fc481b002 | 588 | else if (COLOR_VERT.Touched()){ |
Sitkah | 31:833fc481b002 | 589 | while(COLOR_VERT.Touched()); |
Sitkah | 31:833fc481b002 | 590 | COLOR_VERT.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 591 | |
Sitkah | 31:833fc481b002 | 592 | msgTx.data[color]=3; |
Sitkah | 31:833fc481b002 | 593 | color++; |
Sitkah | 31:833fc481b002 | 594 | } |
Sitkah | 31:833fc481b002 | 595 | else if (COLOR_JAUNE.Touched()){ |
Sitkah | 31:833fc481b002 | 596 | while(COLOR_JAUNE.Touched()); |
Sitkah | 31:833fc481b002 | 597 | COLOR_JAUNE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 598 | msgTx.data[color]=4; |
Sitkah | 31:833fc481b002 | 599 | color++; |
Sitkah | 31:833fc481b002 | 600 | } |
Sitkah | 31:833fc481b002 | 601 | else if (COLOR_BLEU.Touched()){ |
Sitkah | 31:833fc481b002 | 602 | while(COLOR_BLEU.Touched()); |
Sitkah | 31:833fc481b002 | 603 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 604 | msgTx.data[color]=5; |
Sitkah | 31:833fc481b002 | 605 | color++; |
Sitkah | 31:833fc481b002 | 606 | } |
Sitkah | 31:833fc481b002 | 607 | } |
Sitkah | 31:833fc481b002 | 608 | break; |
Sitkah | 31:833fc481b002 | 609 | |
Sitkah | 31:833fc481b002 | 610 | case 1: |
Sitkah | 31:833fc481b002 | 611 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 612 | lcd.SetTextColor(NOIR); |
Sitkah | 31:833fc481b002 | 613 | lcd.DisplayStringAt(100, LINE(4), (uint8_t *)"COULEUR 2", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 614 | if(COLOR_ORANGE.Touched()){ |
Sitkah | 31:833fc481b002 | 615 | while(COLOR_ORANGE.Touched()); |
Sitkah | 31:833fc481b002 | 616 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 617 | msgTx.data[color]=1; |
Sitkah | 31:833fc481b002 | 618 | color++; |
Sitkah | 31:833fc481b002 | 619 | } |
Sitkah | 31:833fc481b002 | 620 | else if (COLOR_NOIR.Touched()){ |
Sitkah | 31:833fc481b002 | 621 | while(COLOR_NOIR.Touched()); |
Sitkah | 31:833fc481b002 | 622 | COLOR_NOIR.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 623 | msgTx.data[color]=2; |
Sitkah | 31:833fc481b002 | 624 | color++; |
Sitkah | 31:833fc481b002 | 625 | } |
Sitkah | 31:833fc481b002 | 626 | else if (COLOR_VERT.Touched()){ |
Sitkah | 31:833fc481b002 | 627 | while(COLOR_VERT.Touched()); |
Sitkah | 31:833fc481b002 | 628 | COLOR_VERT.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 629 | |
Sitkah | 31:833fc481b002 | 630 | msgTx.data[color]=3; |
Sitkah | 31:833fc481b002 | 631 | color++; |
Sitkah | 31:833fc481b002 | 632 | } |
Sitkah | 31:833fc481b002 | 633 | else if (COLOR_JAUNE.Touched()){ |
Sitkah | 31:833fc481b002 | 634 | while(COLOR_JAUNE.Touched()); |
Sitkah | 31:833fc481b002 | 635 | COLOR_JAUNE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 636 | msgTx.data[color]=4; |
Sitkah | 31:833fc481b002 | 637 | color++; |
Sitkah | 31:833fc481b002 | 638 | } |
Sitkah | 31:833fc481b002 | 639 | else if (COLOR_BLEU.Touched()){ |
Sitkah | 31:833fc481b002 | 640 | while(COLOR_BLEU.Touched()); |
Sitkah | 31:833fc481b002 | 641 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 642 | msgTx.data[color]=5; |
Sitkah | 31:833fc481b002 | 643 | color++; |
Sitkah | 31:833fc481b002 | 644 | } |
Sitkah | 31:833fc481b002 | 645 | break; |
Sitkah | 31:833fc481b002 | 646 | |
Sitkah | 31:833fc481b002 | 647 | case 2: |
Sitkah | 31:833fc481b002 | 648 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 649 | lcd.SetTextColor(NOIR); |
Sitkah | 31:833fc481b002 | 650 | lcd.DisplayStringAt(100, LINE(4), (uint8_t *)"COULEUR 3", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 651 | if(COLOR_ORANGE.Touched()){ |
Sitkah | 31:833fc481b002 | 652 | while(COLOR_ORANGE.Touched()); |
Sitkah | 31:833fc481b002 | 653 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 654 | msgTx.data[color]=1; |
Sitkah | 31:833fc481b002 | 655 | color++; |
Sitkah | 31:833fc481b002 | 656 | } |
Sitkah | 31:833fc481b002 | 657 | else if (COLOR_NOIR.Touched()){ |
Sitkah | 31:833fc481b002 | 658 | while(COLOR_NOIR.Touched()); |
Sitkah | 31:833fc481b002 | 659 | COLOR_NOIR.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 660 | msgTx.data[color]=2; |
Sitkah | 31:833fc481b002 | 661 | color++; |
Sitkah | 31:833fc481b002 | 662 | } |
Sitkah | 31:833fc481b002 | 663 | else if (COLOR_VERT.Touched()){ |
Sitkah | 31:833fc481b002 | 664 | while(COLOR_VERT.Touched()); |
Sitkah | 31:833fc481b002 | 665 | COLOR_VERT.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 666 | |
Sitkah | 31:833fc481b002 | 667 | msgTx.data[color]=3; |
Sitkah | 31:833fc481b002 | 668 | color++; |
Sitkah | 31:833fc481b002 | 669 | } |
Sitkah | 31:833fc481b002 | 670 | else if (COLOR_JAUNE.Touched()){ |
Sitkah | 31:833fc481b002 | 671 | while(COLOR_JAUNE.Touched()); |
Sitkah | 31:833fc481b002 | 672 | COLOR_JAUNE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 673 | msgTx.data[color]=4; |
Sitkah | 31:833fc481b002 | 674 | color++; |
Sitkah | 31:833fc481b002 | 675 | } |
Sitkah | 31:833fc481b002 | 676 | else if (COLOR_BLEU.Touched()){ |
Sitkah | 31:833fc481b002 | 677 | while(COLOR_BLEU.Touched()); |
Sitkah | 31:833fc481b002 | 678 | COLOR_ORANGE.Draw(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 679 | msgTx.data[color]=5; |
Sitkah | 31:833fc481b002 | 680 | color++; |
Sitkah | 31:833fc481b002 | 681 | } |
Sitkah | 31:833fc481b002 | 682 | break; |
Sitkah | 31:833fc481b002 | 683 | case 3: |
Sitkah | 31:833fc481b002 | 684 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 685 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 686 | lcd.SetTextColor(NOIR); |
Sitkah | 31:833fc481b002 | 687 | |
Sitkah | 31:833fc481b002 | 688 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"Immeuble en construction", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 689 | RETOUR.Draw(ROUGE,0); |
Sitkah | 31:833fc481b002 | 690 | can2.write(msgTx); |
Sitkah | 31:833fc481b002 | 691 | color++; |
Sitkah | 31:833fc481b002 | 692 | break; |
Sitkah | 31:833fc481b002 | 693 | |
Sitkah | 31:833fc481b002 | 694 | case 4: |
Sitkah | 31:833fc481b002 | 695 | if(RETOUR.Touched()){ |
Sitkah | 31:833fc481b002 | 696 | while(RETOUR.Touched()); |
Sitkah | 31:833fc481b002 | 697 | etat=DEMO; |
Sitkah | 31:833fc481b002 | 698 | } |
Sitkah | 31:833fc481b002 | 699 | break; |
Sitkah | 29:41e02746041d | 700 | } |
Sitkah | 31:833fc481b002 | 701 | if(RETOUR.Touched()){ |
Sitkah | 31:833fc481b002 | 702 | while(RETOUR.Touched()); |
Sitkah | 30:a1e37af4bbde | 703 | etat=DEMO; |
Sitkah | 30:a1e37af4bbde | 704 | } |
Sitkah | 31:833fc481b002 | 705 | } |
Sitkah | 31:833fc481b002 | 706 | break; |
Sitkah | 31:833fc481b002 | 707 | |
Sitkah | 31:833fc481b002 | 708 | |
Sitkah | 31:833fc481b002 | 709 | |
Sitkah | 31:833fc481b002 | 710 | |
Sitkah | 31:833fc481b002 | 711 | |
Sitkah | 31:833fc481b002 | 712 | case TEST_SERVO: |
Sitkah | 31:833fc481b002 | 713 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 714 | lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 715 | ABAISSE_BLOC.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 716 | RELEVE_BLOC.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 717 | BRAS_ABEILLE_ON.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 718 | BRAS_ABEILLE_OFF.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 719 | INTERRUPTEUR_ON.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 720 | INTERRUPTEUR_OFF.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 721 | RETOUR.Draw(0xFFFF0000,0); |
Sitkah | 31:833fc481b002 | 722 | while(etat==TEST_SERVO){ |
Sitkah | 31:833fc481b002 | 723 | if(RETOUR.Touched()){ |
Sitkah | 31:833fc481b002 | 724 | while (RETOUR.Touched()); |
Sitkah | 31:833fc481b002 | 725 | etat=DEMO; |
Sitkah | 31:833fc481b002 | 726 | } |
Sitkah | 31:833fc481b002 | 727 | else if(ABAISSE_BLOC.Touched()){ |
Sitkah | 31:833fc481b002 | 728 | while (ABAISSE_BLOC.Touched()); |
Sitkah | 31:833fc481b002 | 729 | SendRawId(BAISSER_ATTRAPE_BLOC); |
Sitkah | 31:833fc481b002 | 730 | break; |
Sitkah | 31:833fc481b002 | 731 | } |
Sitkah | 31:833fc481b002 | 732 | else if(RELEVE_BLOC.Touched()){ |
Sitkah | 31:833fc481b002 | 733 | while (RELEVE_BLOC.Touched()); |
Sitkah | 31:833fc481b002 | 734 | SendRawId(RELEVER_ATTRAPE_BLOC); |
Sitkah | 31:833fc481b002 | 735 | break; |
Sitkah | 31:833fc481b002 | 736 | } |
Sitkah | 31:833fc481b002 | 737 | else if(BRAS_ABEILLE_ON.Touched()){ |
Sitkah | 31:833fc481b002 | 738 | while (BRAS_ABEILLE_ON.Touched()); |
Sitkah | 31:833fc481b002 | 739 | SendRawId(BRAS_ABEILLE_UP); |
Sitkah | 31:833fc481b002 | 740 | break; |
Sitkah | 31:833fc481b002 | 741 | |
Sitkah | 31:833fc481b002 | 742 | } |
Sitkah | 31:833fc481b002 | 743 | else if(BRAS_ABEILLE_OFF.Touched()){ |
Sitkah | 31:833fc481b002 | 744 | while (BRAS_ABEILLE_OFF.Touched()); |
Sitkah | 31:833fc481b002 | 745 | SendRawId(BRAS_ABEILLE_DOWN); |
Sitkah | 31:833fc481b002 | 746 | break; |
Sitkah | 31:833fc481b002 | 747 | } |
Sitkah | 31:833fc481b002 | 748 | else if(INTERRUPTEUR_ON.Touched()){ |
Sitkah | 31:833fc481b002 | 749 | while (INTERRUPTEUR_ON.Touched()); |
Sitkah | 31:833fc481b002 | 750 | SendRawId(ALLUMER_PANNEAU_UP); |
Sitkah | 31:833fc481b002 | 751 | break; |
Sitkah | 31:833fc481b002 | 752 | } |
Sitkah | 31:833fc481b002 | 753 | else if(INTERRUPTEUR_OFF.Touched()){ |
Sitkah | 31:833fc481b002 | 754 | while (INTERRUPTEUR_OFF.Touched()); |
Sitkah | 31:833fc481b002 | 755 | SendRawId(ALLUMER_PANNEAU_DOWN); |
Sitkah | 31:833fc481b002 | 756 | break; |
Sitkah | 31:833fc481b002 | 757 | } |
Sitkah | 31:833fc481b002 | 758 | } |
Sitkah | 31:833fc481b002 | 759 | break; |
Sitkah | 31:833fc481b002 | 760 | |
Sitkah | 31:833fc481b002 | 761 | case TEST_TIR: |
Sitkah | 31:833fc481b002 | 762 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 763 | lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 764 | TIR_CHATEAU.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 765 | EPURATION.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 766 | LANCEUR_ON.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 767 | LANCEUR_OFF.Draw(VERT, 0); |
Sitkah | 31:833fc481b002 | 768 | RETOUR.Draw(ROUGE, 0); |
Sitkah | 31:833fc481b002 | 769 | while(etat==TEST_TIR){ |
Sitkah | 31:833fc481b002 | 770 | if(TIR_CHATEAU.Touched()){ |
Sitkah | 31:833fc481b002 | 771 | while (TIR_CHATEAU.Touched()); |
Sitkah | 31:833fc481b002 | 772 | SendRawId(INCLINAISON_CHATEAU); |
Sitkah | 31:833fc481b002 | 773 | break; |
Sitkah | 31:833fc481b002 | 774 | } |
Sitkah | 31:833fc481b002 | 775 | else if (EPURATION.Touched()){ |
Sitkah | 31:833fc481b002 | 776 | while (EPURATION.Touched()); |
Sitkah | 31:833fc481b002 | 777 | SendRawId(INCLINAISON_EPURATION); |
Sitkah | 31:833fc481b002 | 778 | break; |
Sitkah | 31:833fc481b002 | 779 | } |
Sitkah | 31:833fc481b002 | 780 | else if(LANCEUR_ON.Touched()){ |
Sitkah | 31:833fc481b002 | 781 | while (LANCEUR_ON.Touched()); |
Sitkah | 36:6dd30780bd8e | 782 | CANMessage msgTx=CANMessage(); |
Sitkah | 36:6dd30780bd8e | 783 | msgTx.format=CANStandard; |
Sitkah | 36:6dd30780bd8e | 784 | msgTx.type=CANData; |
Sitkah | 36:6dd30780bd8e | 785 | msgTx.id=LANCEMENT_MOTEUR_TIR_ON; |
Sitkah | 36:6dd30780bd8e | 786 | |
Sitkah | 36:6dd30780bd8e | 787 | msgTx.len=1; |
Sitkah | 36:6dd30780bd8e | 788 | msgTx.data[0]=0; |
Sitkah | 36:6dd30780bd8e | 789 | can2.write(msgTx); |
Sitkah | 31:833fc481b002 | 790 | break; |
Sitkah | 31:833fc481b002 | 791 | } |
Sitkah | 31:833fc481b002 | 792 | else if(LANCEUR_OFF.Touched()){ |
Sitkah | 31:833fc481b002 | 793 | while (LANCEUR_OFF.Touched()); |
Sitkah | 31:833fc481b002 | 794 | SendRawId(LANCEMENT_MOTEUR_TIR_OFF); |
Sitkah | 31:833fc481b002 | 795 | break; |
Sitkah | 31:833fc481b002 | 796 | } |
Sitkah | 31:833fc481b002 | 797 | else if (RETOUR.Touched()){ |
Sitkah | 31:833fc481b002 | 798 | while (RETOUR.Touched()); |
Sitkah | 31:833fc481b002 | 799 | etat=DEMO; |
Sitkah | 31:833fc481b002 | 800 | |
Sitkah | 31:833fc481b002 | 801 | } |
Sitkah | 31:833fc481b002 | 802 | } |
Sitkah | 31:833fc481b002 | 803 | break; |
Sitkah | 30:a1e37af4bbde | 804 | |
Sitkah | 30:a1e37af4bbde | 805 | |
Sitkah | 31:833fc481b002 | 806 | |
Sitkah | 31:833fc481b002 | 807 | case TEST_TELEMETRE: |
Sitkah | 31:833fc481b002 | 808 | ModeDemo=1; |
Sitkah | 31:833fc481b002 | 809 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 810 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 811 | lcd.DisplayStringAt(20, LINE(2), (uint8_t *)"DEMONSTRATION COURS", LEFT_MODE); |
Sitkah | 31:833fc481b002 | 812 | RETOUR.Draw(0xFFFF0000, 0); |
Sitkah | 31:833fc481b002 | 813 | while(etat==TEST_TELEMETRE){ |
Sitkah | 31:833fc481b002 | 814 | SendRawId(DATA_RECALAGE); |
Sitkah | 31:833fc481b002 | 815 | wait(0.1); |
Sitkah | 31:833fc481b002 | 816 | canProcessRx(); |
Sitkah | 31:833fc481b002 | 817 | if(RETOUR.Touched()){ |
Sitkah | 31:833fc481b002 | 818 | while( RETOUR.Touched()); |
Sitkah | 31:833fc481b002 | 819 | etat=DEMO; |
Sitkah | 32:1c9ab15c740e | 820 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 821 | } |
Sitkah | 29:41e02746041d | 822 | } |
Sitkah | 29:41e02746041d | 823 | break; |
Sitkah | 31:833fc481b002 | 824 | |
Sitkah | 31:833fc481b002 | 825 | |
Sitkah | 29:41e02746041d | 826 | case SELECT_SIDE : |
Sitkah | 29:41e02746041d | 827 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 828 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 829 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 830 | |
Sitkah | 29:41e02746041d | 831 | lcd.DisplayStringAt(70, LINE(0), (uint8_t *)"Choisir le cote", LEFT_MODE); |
Sitkah | 34:6aa4b46b102e | 832 | COTE_VERT.Draw(VERT, 0); |
Sitkah | 34:6aa4b46b102e | 833 | COTE_ORANGE.Draw(ORANGE, 0); |
Sitkah | 29:41e02746041d | 834 | RETOUR.Draw(LCD_COLOR_RED, 0); |
Sitkah | 29:41e02746041d | 835 | |
Sitkah | 29:41e02746041d | 836 | |
Sitkah | 29:41e02746041d | 837 | while (etat == SELECT_SIDE) |
Sitkah | 29:41e02746041d | 838 | { |
Sitkah | 29:41e02746041d | 839 | canProcessRx(); |
Sitkah | 34:6aa4b46b102e | 840 | if(COTE_VERT.Touched()) |
Sitkah | 29:41e02746041d | 841 | { |
Sitkah | 31:833fc481b002 | 842 | liaison_Tx.envoyer(0x30,3,"123"); |
Sitkah | 29:41e02746041d | 843 | Cote = 0x0; |
Sitkah | 29:41e02746041d | 844 | InversStrat = Cote; |
Sitkah | 29:41e02746041d | 845 | etat = TACTIQUE; |
Sitkah | 32:1c9ab15c740e | 846 | CANMessage trame_Tx = CANMessage(); |
Sitkah | 32:1c9ab15c740e | 847 | trame_Tx.len = 1; |
Sitkah | 32:1c9ab15c740e | 848 | trame_Tx.format = CANStandard; |
Sitkah | 32:1c9ab15c740e | 849 | trame_Tx.type = CANData; |
Sitkah | 30:a1e37af4bbde | 850 | trame_Tx.id=CHOICE_COLOR; |
Sitkah | 30:a1e37af4bbde | 851 | trame_Tx.data[0]=Cote; |
Sitkah | 30:a1e37af4bbde | 852 | can2.write(trame_Tx); |
Sitkah | 34:6aa4b46b102e | 853 | while(COTE_VERT.Touched()); |
Sitkah | 30:a1e37af4bbde | 854 | |
Sitkah | 29:41e02746041d | 855 | } |
Sitkah | 29:41e02746041d | 856 | |
Sitkah | 34:6aa4b46b102e | 857 | if(COTE_ORANGE.Touched()) |
Sitkah | 29:41e02746041d | 858 | { |
Sitkah | 29:41e02746041d | 859 | Cote = 0x1; |
Sitkah | 29:41e02746041d | 860 | InversStrat= Cote; |
Sitkah | 29:41e02746041d | 861 | etat = TACTIQUE; |
Sitkah | 32:1c9ab15c740e | 862 | CANMessage trame_Tx = CANMessage(); |
Sitkah | 32:1c9ab15c740e | 863 | trame_Tx.len = 1; |
Sitkah | 32:1c9ab15c740e | 864 | trame_Tx.format = CANStandard; |
Sitkah | 32:1c9ab15c740e | 865 | trame_Tx.type = CANData; |
Sitkah | 30:a1e37af4bbde | 866 | trame_Tx.id=CHOICE_COLOR; |
Sitkah | 30:a1e37af4bbde | 867 | trame_Tx.data[0]=Cote; |
Sitkah | 30:a1e37af4bbde | 868 | can2.write(trame_Tx); |
Sitkah | 34:6aa4b46b102e | 869 | while(COTE_ORANGE.Touched()); |
Sitkah | 29:41e02746041d | 870 | } |
Sitkah | 29:41e02746041d | 871 | |
Sitkah | 29:41e02746041d | 872 | if(RETOUR.Touched()) |
Sitkah | 29:41e02746041d | 873 | { |
Sitkah | 29:41e02746041d | 874 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 875 | while(RETOUR.Touched()); |
Sitkah | 29:41e02746041d | 876 | } |
Sitkah | 29:41e02746041d | 877 | } |
Sitkah | 29:41e02746041d | 878 | |
Sitkah | 29:41e02746041d | 879 | break; |
Sitkah | 29:41e02746041d | 880 | |
Sitkah | 29:41e02746041d | 881 | case TACTIQUE : |
Sitkah | 29:41e02746041d | 882 | if (Cote == 0){ |
Sitkah | 34:6aa4b46b102e | 883 | lcd.Clear(VERT); |
Sitkah | 34:6aa4b46b102e | 884 | lcd.SetBackColor(VERT); |
Sitkah | 29:41e02746041d | 885 | } |
Sitkah | 29:41e02746041d | 886 | else if (Cote == 1){ |
Sitkah | 29:41e02746041d | 887 | lcd.Clear(JAUNE); |
Sitkah | 29:41e02746041d | 888 | lcd.SetBackColor(JAUNE); |
Sitkah | 29:41e02746041d | 889 | } |
Sitkah | 29:41e02746041d | 890 | else { |
Sitkah | 34:6aa4b46b102e | 891 | lcd.Clear(VERT); |
Sitkah | 34:6aa4b46b102e | 892 | lcd.SetBackColor(VERT); |
Sitkah | 29:41e02746041d | 893 | } |
Sitkah | 29:41e02746041d | 894 | |
Sitkah | 29:41e02746041d | 895 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 896 | |
Sitkah | 29:41e02746041d | 897 | lcd.DisplayStringAt(20, LINE(0), (uint8_t *)"Choisir une strategie", LEFT_MODE); |
Sitkah | 29:41e02746041d | 898 | |
Sitkah | 29:41e02746041d | 899 | Strategie = Bouton_Strat(); // retourne valeur de Strategie si bouton strat renvoi -1 on reviens en arriere |
Sitkah | 29:41e02746041d | 900 | if (Strategie == -1) |
Sitkah | 29:41e02746041d | 901 | { |
Sitkah | 29:41e02746041d | 902 | etat = SELECT_SIDE; |
Sitkah | 29:41e02746041d | 903 | } |
Sitkah | 29:41e02746041d | 904 | else |
Sitkah | 29:41e02746041d | 905 | { |
Sitkah | 29:41e02746041d | 906 | etat = DETAILS; |
Sitkah | 29:41e02746041d | 907 | } |
Sitkah | 29:41e02746041d | 908 | wait(0.1); |
Sitkah | 29:41e02746041d | 909 | break; |
Sitkah | 29:41e02746041d | 910 | |
Sitkah | 29:41e02746041d | 911 | case DETAILS : |
Sitkah | 29:41e02746041d | 912 | lcd.Clear(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 913 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 914 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 915 | CHECK.Draw(VERT); |
Sitkah | 29:41e02746041d | 916 | RETOUR.Draw(LCD_COLOR_RED); |
Sitkah | 29:41e02746041d | 917 | |
Sitkah | 29:41e02746041d | 918 | SelectionStrat(Strategie); |
Sitkah | 29:41e02746041d | 919 | |
Sitkah | 29:41e02746041d | 920 | while (etat == DETAILS) |
Sitkah | 29:41e02746041d | 921 | { |
Sitkah | 29:41e02746041d | 922 | canProcessRx(); |
Sitkah | 29:41e02746041d | 923 | if (CHECK.Touched()) |
Sitkah | 29:41e02746041d | 924 | { |
Sitkah | 29:41e02746041d | 925 | if(gameEtat == ETAT_CONFIG) { |
Sitkah | 29:41e02746041d | 926 | gameEtat = ETAT_GAME_INIT; |
Sitkah | 29:41e02746041d | 927 | etat=LECTURE; |
Sitkah | 29:41e02746041d | 928 | |
Sitkah | 29:41e02746041d | 929 | } |
Sitkah | 29:41e02746041d | 930 | while(CHECK.Touched()); |
Sitkah | 29:41e02746041d | 931 | } |
Sitkah | 29:41e02746041d | 932 | |
Sitkah | 29:41e02746041d | 933 | if(RETOUR.Touched()) |
Sitkah | 29:41e02746041d | 934 | { |
Sitkah | 29:41e02746041d | 935 | etat = TACTIQUE; |
Sitkah | 29:41e02746041d | 936 | while(RETOUR.Touched()); |
Sitkah | 29:41e02746041d | 937 | } |
Sitkah | 29:41e02746041d | 938 | } |
Sitkah | 29:41e02746041d | 939 | break; |
Sitkah | 29:41e02746041d | 940 | |
Sitkah | 29:41e02746041d | 941 | |
Sitkah | 29:41e02746041d | 942 | case LECTURE : |
Sitkah | 29:41e02746041d | 943 | break; |
Sitkah | 29:41e02746041d | 944 | case AFF_WAIT_JACK : |
Sitkah | 29:41e02746041d | 945 | lcd.Clear(BLANC); |
Sitkah | 29:41e02746041d | 946 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 947 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 948 | |
Sitkah | 29:41e02746041d | 949 | if (Cote == 0){ |
Sitkah | 34:6aa4b46b102e | 950 | lcd.Clear(VERT); |
Sitkah | 34:6aa4b46b102e | 951 | lcd.SetBackColor(VERT); |
Sitkah | 29:41e02746041d | 952 | } |
Sitkah | 29:41e02746041d | 953 | else if (Cote == 1){ |
Sitkah | 29:41e02746041d | 954 | lcd.Clear(JAUNE); |
Sitkah | 29:41e02746041d | 955 | lcd.SetBackColor(JAUNE); |
Sitkah | 29:41e02746041d | 956 | } |
Sitkah | 29:41e02746041d | 957 | else { |
Sitkah | 34:6aa4b46b102e | 958 | lcd.Clear(VERT); |
Sitkah | 34:6aa4b46b102e | 959 | lcd.SetBackColor(VERT); |
Sitkah | 29:41e02746041d | 960 | } |
Sitkah | 29:41e02746041d | 961 | canProcessRx(); |
Sitkah | 29:41e02746041d | 962 | lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"En attente du Jack", CENTER_MODE); |
Sitkah | 29:41e02746041d | 963 | etat=WAIT_JACK; |
Sitkah | 29:41e02746041d | 964 | break; |
Sitkah | 29:41e02746041d | 965 | |
Sitkah | 29:41e02746041d | 966 | case WAIT_JACK: |
Sitkah | 29:41e02746041d | 967 | break; |
Sitkah | 29:41e02746041d | 968 | |
Sitkah | 29:41e02746041d | 969 | case COMPTEUR: |
Sitkah | 36:6dd30780bd8e | 970 | /*cptf=gameTimer.read(); |
Sitkah | 29:41e02746041d | 971 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 972 | cpt=int(cptf); |
Sitkah | 36:6dd30780bd8e | 973 | if(cpt != cpt1){ |
Sitkah | 34:6aa4b46b102e | 974 | lcd.Clear(VERT); |
Sitkah | 34:6aa4b46b102e | 975 | affichage_compteur(100-cpt); |
Sitkah | 36:6dd30780bd8e | 976 | } |
Sitkah | 29:41e02746041d | 977 | cpt1=cpt; |
Sitkah | 29:41e02746041d | 978 | flag_timer=0; |
Sitkah | 29:41e02746041d | 979 | |
Sitkah | 36:6dd30780bd8e | 980 | affichage_debug(gameEtat); |
Sitkah | 34:6aa4b46b102e | 981 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 36:6dd30780bd8e | 982 | */ |
Sitkah | 29:41e02746041d | 983 | break; |
Sitkah | 29:41e02746041d | 984 | |
Sitkah | 29:41e02746041d | 985 | case FIN : |
Sitkah | 29:41e02746041d | 986 | lcd.Clear (LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 987 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 29:41e02746041d | 988 | lcd.DisplayStringAt(120, 190, (uint8_t *)"LANCEMENT", LEFT_MODE); |
Sitkah | 29:41e02746041d | 989 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 990 | lcd.DisplayStringAt(120, 210, (uint8_t *)"REDEMARAGE", LEFT_MODE); |
Sitkah | 29:41e02746041d | 991 | lcd.DisplayStringAt(120, 230, (uint8_t *)"NECESSAIRE", LEFT_MODE); |
Sitkah | 29:41e02746041d | 992 | while(1); // force le redemarage du robot |
Sitkah | 29:41e02746041d | 993 | //break; |
Sitkah | 29:41e02746041d | 994 | |
Sitkah | 29:41e02746041d | 995 | } |
Sitkah | 29:41e02746041d | 996 | } |
Sitkah | 29:41e02746041d | 997 | |
Sitkah | 29:41e02746041d | 998 | |
Sitkah | 29:41e02746041d | 999 | |
Sitkah | 29:41e02746041d | 1000 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 1001 | /* FUNCTION NAME: automate_process */ |
antbig | 4:88431b537477 | 1002 | /* DESCRIPTION : Automate de gestion de la stratégie du robot */ |
antbig | 4:88431b537477 | 1003 | /****************************************************************************************/ |
Sitkah | 29:41e02746041d | 1004 | void automate_process(void){ |
antbig | 1:116040d14164 | 1005 | static unsigned char AX12_enchainement = 0; |
antbig | 1:116040d14164 | 1006 | static unsigned char MV_enchainement = 0; |
antbig | 0:ad97421fb1fb | 1007 | signed char localData1 = 0; |
antbig | 0:ad97421fb1fb | 1008 | signed short localData2 = 0; |
antbig | 0:ad97421fb1fb | 1009 | unsigned short localData3 = 0; |
ClementBreteau | 14:c8fc06c4887f | 1010 | //signed short localData4 = 0; |
antbig | 1:116040d14164 | 1011 | unsigned char localData5 = 0; |
antbig | 0:ad97421fb1fb | 1012 | |
Sitkah | 34:6aa4b46b102e | 1013 | if(gameTimer.read_ms() >= 99000) {//Fin du match (On autorise 2s pour déposer des éléments |
antbig | 0:ad97421fb1fb | 1014 | gameTimer.stop(); |
antbig | 0:ad97421fb1fb | 1015 | gameTimer.reset(); |
antbig | 0:ad97421fb1fb | 1016 | gameEtat = ETAT_END;//Fin du temps |
Sitkah | 29:41e02746041d | 1017 | etat=FIN; |
antbig | 0:ad97421fb1fb | 1018 | } |
antbig | 0:ad97421fb1fb | 1019 | |
antbig | 0:ad97421fb1fb | 1020 | if(lastEtat != gameEtat || debugetatTimer.read_ms() >= 1000) { |
antbig | 0:ad97421fb1fb | 1021 | lastEtat = gameEtat; |
antbig | 0:ad97421fb1fb | 1022 | debugetatTimer.reset(); |
antbig | 11:ed13a480ddca | 1023 | sendStratEtat((unsigned char)gameEtat, (unsigned char)actual_instruction); |
antbig | 0:ad97421fb1fb | 1024 | } |
antbig | 0:ad97421fb1fb | 1025 | |
antbig | 0:ad97421fb1fb | 1026 | switch(gameEtat) |
antbig | 0:ad97421fb1fb | 1027 | { |
Sitkah | 30:a1e37af4bbde | 1028 | |
Sitkah | 29:41e02746041d | 1029 | case ETAT_CHECK_CARTES: |
antbig | 0:ad97421fb1fb | 1030 | /* |
antbig | 0:ad97421fb1fb | 1031 | Il faut faire une boucle pour verifier toutes les cartes les une apres les autres |
antbig | 0:ad97421fb1fb | 1032 | */ |
antbig | 0:ad97421fb1fb | 1033 | waitingAckFrom = id_alive[checkCurrent];//On indique que l'on attend un ack de la carte IHM |
antbig | 11:ed13a480ddca | 1034 | SendRawId(id_check[checkCurrent]);//On demande à la carte d'indiquer ça présence |
antbig | 0:ad97421fb1fb | 1035 | |
antbig | 0:ad97421fb1fb | 1036 | screenChecktry++;//On incrèment le conteur de tentative de 1 |
antbig | 0:ad97421fb1fb | 1037 | cartesCheker.reset();//On reset le timeOut |
antbig | 0:ad97421fb1fb | 1038 | cartesCheker.start();//On lance le timer pour le timeout |
antbig | 0:ad97421fb1fb | 1039 | gameEtat = ETAT_CHECK_CARTES_WAIT_ACK; |
Sitkah | 29:41e02746041d | 1040 | break; |
ClementBreteau | 14:c8fc06c4887f | 1041 | |
antbig | 0:ad97421fb1fb | 1042 | case ETAT_CHECK_CARTES_WAIT_ACK: |
antbig | 0:ad97421fb1fb | 1043 | /* |
antbig | 0:ad97421fb1fb | 1044 | On attend l'ack de la carte en cours de vérification |
antbig | 0:ad97421fb1fb | 1045 | */ |
antbig | 0:ad97421fb1fb | 1046 | //printf("cartesCheker = %d waitingAckFrom = %d\n",cartesCheker.read_ms(), waitingAckFrom); |
antbig | 0:ad97421fb1fb | 1047 | if(waitingAckFrom == 0) {//C'est bon la carte est en ligne |
antbig | 0:ad97421fb1fb | 1048 | cartesCheker.stop(); |
antbig | 0:ad97421fb1fb | 1049 | screenChecktry = 0; |
antbig | 0:ad97421fb1fb | 1050 | countAliveCard++; |
antbig | 11:ed13a480ddca | 1051 | checkCurrent++; |
antbig | 0:ad97421fb1fb | 1052 | if(checkCurrent >= NOMBRE_CARTES) { |
Sitkah | 29:41e02746041d | 1053 | printf("all card check, missing %d cards\n",(NOMBRE_CARTES-countAliveCard)); |
antbig | 0:ad97421fb1fb | 1054 | if(countAliveCard >= NOMBRE_CARTES) { |
antbig | 0:ad97421fb1fb | 1055 | gameEtat = ETAT_CONFIG; |
Sitkah | 29:41e02746041d | 1056 | flag=1; |
Sitkah | 30:a1e37af4bbde | 1057 | //tactile_printf("Selection couleur et strategie"); |
Sitkah | 29:41e02746041d | 1058 | } |
Sitkah | 29:41e02746041d | 1059 | else { |
antbig | 0:ad97421fb1fb | 1060 | gameEtat = ETAT_WAIT_FORCE;//Passage en attente de forçage du lancement |
antbig | 0:ad97421fb1fb | 1061 | waitingAckFrom = ECRAN_ALL_CHECK; |
antbig | 0:ad97421fb1fb | 1062 | } |
Sitkah | 29:41e02746041d | 1063 | } |
Sitkah | 29:41e02746041d | 1064 | else |
antbig | 0:ad97421fb1fb | 1065 | gameEtat = ETAT_CHECK_CARTES; |
Sitkah | 29:41e02746041d | 1066 | } |
Sitkah | 29:41e02746041d | 1067 | else if(cartesCheker.read_ms () > 100) { |
antbig | 0:ad97421fb1fb | 1068 | cartesCheker.stop(); |
antbig | 0:ad97421fb1fb | 1069 | if(screenChecktry >=3) { |
antbig | 12:14729d584500 | 1070 | //printf("missing card %d\n",id_check[checkCurrent]); |
antbig | 0:ad97421fb1fb | 1071 | screenChecktry = 0; |
antbig | 11:ed13a480ddca | 1072 | checkCurrent++; |
antbig | 12:14729d584500 | 1073 | |
Sitkah | 29:41e02746041d | 1074 | if(checkCurrent >= NOMBRE_CARTES){ |
Sitkah | 29:41e02746041d | 1075 | if(countAliveCard == NOMBRE_CARTES){ |
antbig | 0:ad97421fb1fb | 1076 | gameEtat = ETAT_CONFIG; |
Sitkah | 29:41e02746041d | 1077 | flag=1; |
Sitkah | 29:41e02746041d | 1078 | } |
Sitkah | 29:41e02746041d | 1079 | else{ |
Sitkah | 29:41e02746041d | 1080 | gameEtat = ETAT_WAIT_FORCE; |
antbig | 0:ad97421fb1fb | 1081 | waitingAckFrom = ECRAN_ALL_CHECK; |
antbig | 0:ad97421fb1fb | 1082 | } |
Sitkah | 29:41e02746041d | 1083 | } |
Sitkah | 29:41e02746041d | 1084 | else |
antbig | 0:ad97421fb1fb | 1085 | gameEtat = ETAT_CHECK_CARTES; |
Sitkah | 29:41e02746041d | 1086 | |
Sitkah | 29:41e02746041d | 1087 | } |
Sitkah | 29:41e02746041d | 1088 | else |
antbig | 0:ad97421fb1fb | 1089 | gameEtat = ETAT_CHECK_CARTES; |
Sitkah | 29:41e02746041d | 1090 | |
antbig | 0:ad97421fb1fb | 1091 | } |
Sitkah | 29:41e02746041d | 1092 | break; |
antbig | 0:ad97421fb1fb | 1093 | case ETAT_WAIT_FORCE: |
antbig | 0:ad97421fb1fb | 1094 | /* |
antbig | 0:ad97421fb1fb | 1095 | Attente du forçage de la part de la carte IHM |
antbig | 0:ad97421fb1fb | 1096 | */ |
antbig | 0:ad97421fb1fb | 1097 | if(waitingAckFrom == 0) { |
antbig | 0:ad97421fb1fb | 1098 | gameEtat = ETAT_CONFIG; |
antbig | 0:ad97421fb1fb | 1099 | } |
Sitkah | 29:41e02746041d | 1100 | break; |
antbig | 0:ad97421fb1fb | 1101 | case ETAT_CONFIG: |
antbig | 0:ad97421fb1fb | 1102 | /* |
antbig | 0:ad97421fb1fb | 1103 | Attente de l'odre de choix de mode, |
antbig | 0:ad97421fb1fb | 1104 | Il est possible de modifier la couleur et l'id de la stratégie |
antbig | 0:ad97421fb1fb | 1105 | Il est aussi possible d'envoyer les ordres de debug |
antbig | 0:ad97421fb1fb | 1106 | */ |
ClementBreteau | 14:c8fc06c4887f | 1107 | modeTelemetre = 0; |
Sitkah | 29:41e02746041d | 1108 | break; |
antbig | 1:116040d14164 | 1109 | case ETAT_GAME_INIT: |
antbig | 0:ad97421fb1fb | 1110 | //On charge la liste des instructions |
Sitkah | 29:41e02746041d | 1111 | |
Sitkah | 29:41e02746041d | 1112 | loadAllInstruction(Strategie);//Mise en cache de toute les instructions |
Sitkah | 29:41e02746041d | 1113 | led3=1; |
ClementBreteau | 14:c8fc06c4887f | 1114 | |
antbig | 0:ad97421fb1fb | 1115 | gameEtat = ETAT_GAME_WAIT_FOR_JACK; |
Sitkah | 31:833fc481b002 | 1116 | if (etat == TEST_TELEMETRE|| etat ==TEST_CAPTEURS || etat == TEST_SERVO || etat ==TEST_TIR || etat == DEMO_IMMEUBLE) |
Sitkah | 29:41e02746041d | 1117 | { |
Sitkah | 29:41e02746041d | 1118 | SendRawId(DEBUG_FAKE_JAKE); |
Sitkah | 29:41e02746041d | 1119 | } |
Sitkah | 29:41e02746041d | 1120 | else |
Sitkah | 29:41e02746041d | 1121 | { |
Sitkah | 29:41e02746041d | 1122 | etat = AFF_WAIT_JACK; |
Sitkah | 29:41e02746041d | 1123 | } |
Sitkah | 30:a1e37af4bbde | 1124 | //tactile_printf("Attente du JACK."); |
antbig | 12:14729d584500 | 1125 | setAsservissementEtat(1);//On réactive l'asservissement |
antbig | 12:14729d584500 | 1126 | jack.mode(PullDown); // désactivation de la résistance interne du jack |
antbig | 8:0edc7dfb7f7e | 1127 | jack.fall(&jack_ISR); // création de l'interrupt attachée au changement d'état (front descendant) sur le jack |
antbig | 12:14729d584500 | 1128 | |
antbig | 12:14729d584500 | 1129 | #ifdef ROBOT_BIG //le gros robot n'a pas de recalage bordure pour ce placer au début, on lui envoit donc ça position |
antbig | 12:14729d584500 | 1130 | localData2 = POSITION_DEBUT_T; |
antbig | 12:14729d584500 | 1131 | localData3 = POSITION_DEBUT_Y; |
antbig | 12:14729d584500 | 1132 | if(InversStrat == 1) { |
antbig | 27:76ead555a63d | 1133 | localData2 = 1800-localData2;//Inversion theta |
antbig | 28:acd18776ed2d | 1134 | if(localData2 > 1800) localData2 -= 3600; |
antbig | 28:acd18776ed2d | 1135 | else if(localData2 <= -1800) localData2 += 3600; |
antbig | 12:14729d584500 | 1136 | localData3 = 3000 - POSITION_DEBUT_Y;//Inversion du Y |
antbig | 12:14729d584500 | 1137 | } |
antbig | 12:14729d584500 | 1138 | SetOdometrie(ODOMETRIE_BIG_POSITION, POSITION_DEBUT_X,localData3,localData2); |
ClementBreteau | 18:cc5fec34ed9c | 1139 | #endif |
ClementBreteau | 18:cc5fec34ed9c | 1140 | #ifdef ROBOT_SMALL |
clementlignie | 22:a466d08ac42b | 1141 | localData2 = POSITION_DEBUT_T; |
clementlignie | 22:a466d08ac42b | 1142 | localData3 = POSITION_DEBUT_Y; |
clementlignie | 22:a466d08ac42b | 1143 | if(InversStrat == 1) { |
clementlignie | 22:a466d08ac42b | 1144 | localData2 = -localData2;//Inversion theta |
clementlignie | 22:a466d08ac42b | 1145 | localData3 = 3000 - POSITION_DEBUT_Y;//Inversion du Y |
clementlignie | 22:a466d08ac42b | 1146 | } |
clementlignie | 22:a466d08ac42b | 1147 | SetOdometrie(ODOMETRIE_SMALL_POSITION, POSITION_DEBUT_X,localData3,localData2); |
ClementBreteau | 18:cc5fec34ed9c | 1148 | #endif |
antbig | 0:ad97421fb1fb | 1149 | break; |
antbig | 0:ad97421fb1fb | 1150 | case ETAT_GAME_WAIT_FOR_JACK: |
antbig | 12:14729d584500 | 1151 | //On attend le jack |
antbig | 1:116040d14164 | 1152 | break; |
antbig | 1:116040d14164 | 1153 | case ETAT_GAME_START: |
Sitkah | 29:41e02746041d | 1154 | |
antbig | 1:116040d14164 | 1155 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
ClementBreteau | 14:c8fc06c4887f | 1156 | |
ClementBreteau | 14:c8fc06c4887f | 1157 | if (ModeDemo == 0){ |
Sitkah | 34:6aa4b46b102e | 1158 | chronoEnd.attach(&chronometre_ISR,100);//On lance le chrono de 90s |
ClementBreteau | 14:c8fc06c4887f | 1159 | gameTimer.start(); |
ClementBreteau | 14:c8fc06c4887f | 1160 | } |
antbig | 1:116040d14164 | 1161 | gameTimer.reset(); |
antbig | 12:14729d584500 | 1162 | jack.fall(NULL);//On désactive l'interruption du jack |
Sitkah | 34:6aa4b46b102e | 1163 | //SendRawId(GLOBAL_START); |
Sitkah | 29:41e02746041d | 1164 | Jack=0; //à envoyer sur le CAN et en direct pour l'automate de l'ihm ou sur CANV |
Sitkah | 30:a1e37af4bbde | 1165 | //tactile_printf("Start");//Pas vraiment utile mais bon |
antbig | 0:ad97421fb1fb | 1166 | break; |
antbig | 0:ad97421fb1fb | 1167 | case ETAT_GAME_LOAD_NEXT_INSTRUCTION: |
antbig | 0:ad97421fb1fb | 1168 | /* |
antbig | 0:ad97421fb1fb | 1169 | Chargement de l'instruction suivante ou arret du robot si il n'y a plus d'instruction |
antbig | 0:ad97421fb1fb | 1170 | */ |
antbig | 0:ad97421fb1fb | 1171 | //printf("load next instruction\n"); |
ClementBreteau | 14:c8fc06c4887f | 1172 | |
antbig | 0:ad97421fb1fb | 1173 | if(actual_instruction >= nb_instructions || actual_instruction == 255) { |
antbig | 0:ad97421fb1fb | 1174 | gameEtat = ETAT_END; |
antbig | 0:ad97421fb1fb | 1175 | //Il n'y a plus d'instruction, fin du jeu |
antbig | 0:ad97421fb1fb | 1176 | } else { |
antbig | 0:ad97421fb1fb | 1177 | instruction = strat_instructions[actual_instruction]; |
antbig | 0:ad97421fb1fb | 1178 | //On effectue le traitement de l'instruction |
antbig | 0:ad97421fb1fb | 1179 | gameEtat = ETAT_GAME_PROCESS_INSTRUCTION; |
antbig | 0:ad97421fb1fb | 1180 | } |
antbig | 0:ad97421fb1fb | 1181 | screenChecktry = 0; |
antbig | 28:acd18776ed2d | 1182 | ingnorInversionOnce = 0; |
antbig | 0:ad97421fb1fb | 1183 | break; |
antbig | 0:ad97421fb1fb | 1184 | case ETAT_GAME_PROCESS_INSTRUCTION: |
antbig | 0:ad97421fb1fb | 1185 | /* |
antbig | 0:ad97421fb1fb | 1186 | Traitement de l'instruction, envoie de la trame CAN |
antbig | 0:ad97421fb1fb | 1187 | */ |
antbig | 0:ad97421fb1fb | 1188 | //debug_Instruction(instruction); |
Sitkah | 36:6dd30780bd8e | 1189 | affichage_debug(gameEtat); |
ClementBreteau | 25:f140c93a8666 | 1190 | actionPrecedente = instruction.order; |
antbig | 0:ad97421fb1fb | 1191 | switch(instruction.order) |
antbig | 0:ad97421fb1fb | 1192 | { |
antbig | 12:14729d584500 | 1193 | case MV_COURBURE://C'est un rayon de courbure |
ClementBreteau | 26:2f4fcc2354f3 | 1194 | actionPrecedente = MV_COURBURE; |
antbig | 6:eddfa414fd11 | 1195 | waitingAckID = ASSERVISSEMENT_COURBURE; |
antbig | 6:eddfa414fd11 | 1196 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
Sitkah | 30:a1e37af4bbde | 1197 | if(instruction.nextActionType == ENCHAINEMENT){ |
antbig | 6:eddfa414fd11 | 1198 | MV_enchainement++; |
antbig | 6:eddfa414fd11 | 1199 | localData5 = 1; |
antbig | 6:eddfa414fd11 | 1200 | } else { |
antbig | 6:eddfa414fd11 | 1201 | if(MV_enchainement > 0) { |
antbig | 6:eddfa414fd11 | 1202 | localData5 = 2; |
antbig | 6:eddfa414fd11 | 1203 | MV_enchainement = 0; |
antbig | 6:eddfa414fd11 | 1204 | } else { |
antbig | 6:eddfa414fd11 | 1205 | localData5 = 0; |
antbig | 6:eddfa414fd11 | 1206 | } |
antbig | 0:ad97421fb1fb | 1207 | } |
antbig | 11:ed13a480ddca | 1208 | localData1 = ((instruction.direction == LEFT)?1:-1); |
ClementBreteau | 23:ab87d308eaf9 | 1209 | localData2 = instruction.arg3; |
antbig | 28:acd18776ed2d | 1210 | if(InversStrat == 1 && ingnorInversionOnce == 0) |
antbig | 12:14729d584500 | 1211 | { |
antbig | 12:14729d584500 | 1212 | localData1 = -localData1;//Inversion de la direction |
ClementBreteau | 23:ab87d308eaf9 | 1213 | #ifdef ROBOT_BIG |
ClementBreteau | 25:f140c93a8666 | 1214 | localData2 = -localData2; |
ClementBreteau | 26:2f4fcc2354f3 | 1215 | localData1 = -localData1;//Inversion de la direction |
ClementBreteau | 23:ab87d308eaf9 | 1216 | #endif |
antbig | 12:14729d584500 | 1217 | } |
ClementBreteau | 25:f140c93a8666 | 1218 | BendRadius(instruction.arg1, localData2, localData1, localData5); |
ClementBreteau | 18:cc5fec34ed9c | 1219 | |
antbig | 28:acd18776ed2d | 1220 | |
antbig | 28:acd18776ed2d | 1221 | target_theta_robot = localData2 - theta_robot; |
antbig | 28:acd18776ed2d | 1222 | /* |
ClementBreteau | 26:2f4fcc2354f3 | 1223 | if(instruction.direction == LEFT){ |
antbig | 28:acd18776ed2d | 1224 | |
ClementBreteau | 26:2f4fcc2354f3 | 1225 | }else{ |
antbig | 28:acd18776ed2d | 1226 | target_theta_robot = theta_robot + localData2; |
antbig | 28:acd18776ed2d | 1227 | }*/ |
ClementBreteau | 26:2f4fcc2354f3 | 1228 | |
antbig | 0:ad97421fb1fb | 1229 | break; |
antbig | 12:14729d584500 | 1230 | case MV_LINE://Ligne droite |
antbig | 0:ad97421fb1fb | 1231 | waitingAckID = ASSERVISSEMENT_RECALAGE; |
antbig | 0:ad97421fb1fb | 1232 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
antbig | 0:ad97421fb1fb | 1233 | if(instruction.nextActionType == ENCHAINEMENT) { |
antbig | 1:116040d14164 | 1234 | MV_enchainement++; |
antbig | 1:116040d14164 | 1235 | localData5 = 1; |
antbig | 1:116040d14164 | 1236 | } else { |
antbig | 12:14729d584500 | 1237 | if(MV_enchainement > 0) {//Utilisé en cas d'enchainement, |
antbig | 1:116040d14164 | 1238 | localData5 = 2; |
antbig | 1:116040d14164 | 1239 | MV_enchainement = 0; |
antbig | 1:116040d14164 | 1240 | } else { |
antbig | 1:116040d14164 | 1241 | localData5 = 0; |
antbig | 1:116040d14164 | 1242 | } |
antbig | 0:ad97421fb1fb | 1243 | } |
ClementBreteau | 16:7321fb3bb396 | 1244 | #ifdef ROBOT_BIG |
antbig | 28:acd18776ed2d | 1245 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
ClementBreteau | 15:c2fc239e85df | 1246 | /*if (instruction.direction == FORWARD) instruction.direction = BACKWARD; |
ClementBreteau | 15:c2fc239e85df | 1247 | else instruction.direction = FORWARD;*/ |
ClementBreteau | 15:c2fc239e85df | 1248 | instruction.direction = ((instruction.direction == FORWARD)?BACKWARD:FORWARD); |
ClementBreteau | 15:c2fc239e85df | 1249 | } |
ClementBreteau | 16:7321fb3bb396 | 1250 | #endif |
antbig | 1:116040d14164 | 1251 | localData2 = (((instruction.direction == FORWARD)?1:-1)*instruction.arg1); |
antbig | 1:116040d14164 | 1252 | GoStraight(localData2, 0, 0, localData5); |
ClementBreteau | 14:c8fc06c4887f | 1253 | |
ClementBreteau | 26:2f4fcc2354f3 | 1254 | target_x_robot = x_robot + localData2*cos((double)theta_robot*M_PI/1800); |
ClementBreteau | 26:2f4fcc2354f3 | 1255 | target_y_robot = y_robot + localData2*sin((double)theta_robot*M_PI/1800); |
ClementBreteau | 25:f140c93a8666 | 1256 | target_theta_robot = theta_robot; |
ClementBreteau | 25:f140c93a8666 | 1257 | |
antbig | 0:ad97421fb1fb | 1258 | break; |
antbig | 12:14729d584500 | 1259 | case MV_TURN: //Rotation sur place |
antbig | 0:ad97421fb1fb | 1260 | if(instruction.direction == RELATIVE) { |
antbig | 0:ad97421fb1fb | 1261 | localData2 = instruction.arg3; |
antbig | 12:14729d584500 | 1262 | } else {//C'est un rotation absolu, il faut la convertir en relative |
antbig | 12:14729d584500 | 1263 | localData2 = instruction.arg3; |
antbig | 12:14729d584500 | 1264 | |
antbig | 12:14729d584500 | 1265 | localData2 = (localData2 - theta_robot)%3600; |
antbig | 12:14729d584500 | 1266 | if(localData2 > 1800) { |
antbig | 12:14729d584500 | 1267 | localData2 = localData2-3600; |
antbig | 12:14729d584500 | 1268 | } |
antbig | 12:14729d584500 | 1269 | |
antbig | 0:ad97421fb1fb | 1270 | } |
ClementBreteau | 23:ab87d308eaf9 | 1271 | #ifdef ROBOT_SMALL |
antbig | 28:acd18776ed2d | 1272 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
clementlignie | 22:a466d08ac42b | 1273 | localData2 = -localData2; |
clementlignie | 22:a466d08ac42b | 1274 | } |
ClementBreteau | 23:ab87d308eaf9 | 1275 | #endif |
antbig | 28:acd18776ed2d | 1276 | #ifdef ROBOT_BIG |
antbig | 28:acd18776ed2d | 1277 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
antbig | 28:acd18776ed2d | 1278 | if(instruction.direction == RELATIVE) { |
antbig | 28:acd18776ed2d | 1279 | localData2 = instruction.arg3; |
antbig | 28:acd18776ed2d | 1280 | } else {//C'est un rotation absolu, il faut la convertir en relative |
antbig | 28:acd18776ed2d | 1281 | |
antbig | 28:acd18776ed2d | 1282 | localData2 = 1800-instruction.arg3;//Inversion theta |
antbig | 28:acd18776ed2d | 1283 | if(localData2 > 1800) localData2 -= 3600; |
antbig | 28:acd18776ed2d | 1284 | else if(localData2 <= -1800) localData2 += 3600; |
antbig | 28:acd18776ed2d | 1285 | |
antbig | 28:acd18776ed2d | 1286 | localData2 = (localData2 - theta_robot)%3600; |
antbig | 28:acd18776ed2d | 1287 | if(localData2 > 1800) { |
antbig | 28:acd18776ed2d | 1288 | localData2 = localData2-3600; |
antbig | 28:acd18776ed2d | 1289 | } |
antbig | 28:acd18776ed2d | 1290 | |
antbig | 28:acd18776ed2d | 1291 | } |
antbig | 28:acd18776ed2d | 1292 | } |
antbig | 28:acd18776ed2d | 1293 | #endif |
antbig | 0:ad97421fb1fb | 1294 | waitingAckID = ASSERVISSEMENT_ROTATION; |
antbig | 0:ad97421fb1fb | 1295 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
Sitkah | 34:6aa4b46b102e | 1296 | Rotate(localData2); |
Sitkah | 34:6aa4b46b102e | 1297 | |
antbig | 28:acd18776ed2d | 1298 | |
antbig | 0:ad97421fb1fb | 1299 | break; |
antbig | 0:ad97421fb1fb | 1300 | case MV_XYT: |
antbig | 0:ad97421fb1fb | 1301 | if(instruction.direction == BACKWARD) { |
antbig | 0:ad97421fb1fb | 1302 | localData1 = -1; |
antbig | 0:ad97421fb1fb | 1303 | } else { |
antbig | 0:ad97421fb1fb | 1304 | localData1 = 1; |
antbig | 0:ad97421fb1fb | 1305 | } |
antbig | 2:8d8e2cf798a3 | 1306 | |
antbig | 28:acd18776ed2d | 1307 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
antbig | 12:14729d584500 | 1308 | localData2 = -instruction.arg3; |
antbig | 2:8d8e2cf798a3 | 1309 | localData3 = 3000 - instruction.arg2;//Inversion du Y |
antbig | 2:8d8e2cf798a3 | 1310 | } else { |
antbig | 2:8d8e2cf798a3 | 1311 | localData3 = instruction.arg2; |
antbig | 12:14729d584500 | 1312 | localData2 = instruction.arg3; |
antbig | 2:8d8e2cf798a3 | 1313 | } |
ClementBreteau | 23:ab87d308eaf9 | 1314 | |
ClementBreteau | 23:ab87d308eaf9 | 1315 | #ifdef ROBOT_BIG |
antbig | 28:acd18776ed2d | 1316 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
ClementBreteau | 23:ab87d308eaf9 | 1317 | localData1 = -localData1; |
antbig | 27:76ead555a63d | 1318 | localData2 = 1800-instruction.arg3;//Inversion theta |
antbig | 28:acd18776ed2d | 1319 | if(localData2 > 1800) localData2 -= 3600; |
antbig | 28:acd18776ed2d | 1320 | else if(localData2 <= -1800) localData2 += 3600; |
ClementBreteau | 23:ab87d308eaf9 | 1321 | } |
ClementBreteau | 23:ab87d308eaf9 | 1322 | #endif |
ClementBreteau | 23:ab87d308eaf9 | 1323 | |
antbig | 12:14729d584500 | 1324 | GoToPosition(instruction.arg1,localData3,localData2,localData1); |
antbig | 0:ad97421fb1fb | 1325 | waitingAckID = ASSERVISSEMENT_XYT; |
antbig | 0:ad97421fb1fb | 1326 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
ClementBreteau | 25:f140c93a8666 | 1327 | |
ClementBreteau | 25:f140c93a8666 | 1328 | target_x_robot = instruction.arg1; |
ClementBreteau | 25:f140c93a8666 | 1329 | target_y_robot = localData3; |
ClementBreteau | 25:f140c93a8666 | 1330 | target_theta_robot = localData2; |
ClementBreteau | 25:f140c93a8666 | 1331 | |
antbig | 0:ad97421fb1fb | 1332 | break; |
antbig | 0:ad97421fb1fb | 1333 | case MV_RECALAGE: |
Sitkah | 34:6aa4b46b102e | 1334 | if(instruction.nextActionType == MECANIQUE) |
Sitkah | 34:6aa4b46b102e | 1335 | { |
Sitkah | 34:6aa4b46b102e | 1336 | instruction.nextActionType = WAIT; |
Sitkah | 34:6aa4b46b102e | 1337 | |
Sitkah | 34:6aa4b46b102e | 1338 | waitingAckID = ASSERVISSEMENT_RECALAGE; |
Sitkah | 34:6aa4b46b102e | 1339 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
Sitkah | 34:6aa4b46b102e | 1340 | |
Sitkah | 34:6aa4b46b102e | 1341 | localData2 = (((instruction.direction == FORWARD)?1:-1)*3000);//On indique une distance de 3000 pour etre sur que le robot va ce recaler |
Sitkah | 34:6aa4b46b102e | 1342 | |
Sitkah | 34:6aa4b46b102e | 1343 | if(instruction.precision == RECALAGE_Y) { |
Sitkah | 34:6aa4b46b102e | 1344 | localData5 = 2; |
Sitkah | 34:6aa4b46b102e | 1345 | if(InversStrat == 1 && ingnorInversionOnce == 0) { |
Sitkah | 34:6aa4b46b102e | 1346 | localData3 = 3000 - instruction.arg1;//Inversion du Y |
Sitkah | 34:6aa4b46b102e | 1347 | } else { |
Sitkah | 34:6aa4b46b102e | 1348 | localData3 = instruction.arg1; |
Sitkah | 34:6aa4b46b102e | 1349 | } |
antbig | 11:ed13a480ddca | 1350 | } else { |
Sitkah | 34:6aa4b46b102e | 1351 | localData5 = 1; |
antbig | 11:ed13a480ddca | 1352 | localData3 = instruction.arg1; |
antbig | 11:ed13a480ddca | 1353 | } |
Sitkah | 34:6aa4b46b102e | 1354 | GoStraight(localData2, localData5, localData3, 0); |
antbig | 11:ed13a480ddca | 1355 | } |
Sitkah | 34:6aa4b46b102e | 1356 | else //CAPTEUR |
Sitkah | 36:6dd30780bd8e | 1357 | { |
Sitkah | 34:6aa4b46b102e | 1358 | SendRawId(DATA_RECALAGE); |
Sitkah | 34:6aa4b46b102e | 1359 | waitingAckID = RECEPTION_RECALAGE; |
Sitkah | 34:6aa4b46b102e | 1360 | waitingAckFrom = ACKNOWLEDGE_TELEMETRE; |
Sitkah | 34:6aa4b46b102e | 1361 | |
Sitkah | 34:6aa4b46b102e | 1362 | // On attend que les variables soient actualisé |
Sitkah | 34:6aa4b46b102e | 1363 | while(!(waitingAckID == 0 && waitingAckFrom == 0)) |
Sitkah | 34:6aa4b46b102e | 1364 | canProcessRx(); |
Sitkah | 35:742dc6b200b0 | 1365 | while(!(waitingAckID_FIN==0 && waitingAckFrom_FIN==0)) |
Sitkah | 35:742dc6b200b0 | 1366 | canProcessRx(); |
Sitkah | 36:6dd30780bd8e | 1367 | |
Sitkah | 34:6aa4b46b102e | 1368 | if(instruction.precision == RECALAGE_Y) // ((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600)) (theta_robot < 900 && theta_robot > -900) |
Sitkah | 34:6aa4b46b102e | 1369 | { |
Sitkah | 36:6dd30780bd8e | 1370 | SetOdometrie(ODOMETRIE_SMALL_POSITION, x_robot, recalageDistanceY(), theta_robot); |
Sitkah | 34:6aa4b46b102e | 1371 | } |
Sitkah | 34:6aa4b46b102e | 1372 | else if(instruction.precision == RECALAGE_X) |
Sitkah | 34:6aa4b46b102e | 1373 | { |
Sitkah | 36:6dd30780bd8e | 1374 | SetOdometrie(ODOMETRIE_SMALL_POSITION, recalageDistanceX(), y_robot, theta_robot); |
Sitkah | 34:6aa4b46b102e | 1375 | } |
Sitkah | 35:742dc6b200b0 | 1376 | else if(instruction.precision == RECALAGE_T) |
Sitkah | 34:6aa4b46b102e | 1377 | { |
Sitkah | 36:6dd30780bd8e | 1378 | SetOdometrie(ODOMETRIE_SMALL_POSITION, x_robot, y_robot, recalageAngulaireCapteur() ); |
Sitkah | 35:742dc6b200b0 | 1379 | } |
Sitkah | 34:6aa4b46b102e | 1380 | } |
antbig | 0:ad97421fb1fb | 1381 | break; |
Sitkah | 34:6aa4b46b102e | 1382 | |
antbig | 0:ad97421fb1fb | 1383 | case ACTION: |
ClementBreteau | 18:cc5fec34ed9c | 1384 | int tempo = 0; |
Sitkah | 30:a1e37af4bbde | 1385 | waitingAckID= ACK_ACTION; //On veut un ack de type action |
Sitkah | 30:a1e37af4bbde | 1386 | waitingAckFrom = ACKNOWLEDGE_HERKULEX; //de la part des herkulex |
ClementBreteau | 18:cc5fec34ed9c | 1387 | tempo = doAction(instruction.arg1,instruction.arg2,instruction.arg3); |
ClementBreteau | 18:cc5fec34ed9c | 1388 | if(tempo == 1){ |
antbig | 0:ad97421fb1fb | 1389 | //L'action est spécifique |
Sitkah | 34:6aa4b46b102e | 1390 | if((waitingAckFrom == 0 && waitingAckID == 0) && instruction.nextActionType == ENCHAINEMENT) { |
antbig | 11:ed13a480ddca | 1391 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 11:ed13a480ddca | 1392 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
Sitkah | 30:a1e37af4bbde | 1393 | } |
Sitkah | 30:a1e37af4bbde | 1394 | else { |
ClementBreteau | 15:c2fc239e85df | 1395 | gameEtat = ETAT_GAME_WAIT_ACK; |
antbig | 11:ed13a480ddca | 1396 | } |
ClementBreteau | 18:cc5fec34ed9c | 1397 | #ifdef ROBOT_SMALL |
Sitkah | 34:6aa4b46b102e | 1398 | /*actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
Sitkah | 34:6aa4b46b102e | 1399 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;*/ |
ClementBreteau | 18:cc5fec34ed9c | 1400 | #endif |
antbig | 11:ed13a480ddca | 1401 | return; |
ClementBreteau | 18:cc5fec34ed9c | 1402 | #ifdef ROBOT_SMALL |
ClementBreteau | 18:cc5fec34ed9c | 1403 | } else if (tempo == 2) { |
ClementBreteau | 18:cc5fec34ed9c | 1404 | // on est dans le cas de l'avance selon le telemetre |
ClementBreteau | 18:cc5fec34ed9c | 1405 | waitingAckID = ASSERVISSEMENT_RECALAGE; |
ClementBreteau | 18:cc5fec34ed9c | 1406 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
ClementBreteau | 18:cc5fec34ed9c | 1407 | |
ClementBreteau | 18:cc5fec34ed9c | 1408 | localData2 = (((instruction.direction == FORWARD)?1:-1)*instruction.arg1); |
ClementBreteau | 18:cc5fec34ed9c | 1409 | GoStraight(telemetreDistance, 0, 0, 0); |
ClementBreteau | 18:cc5fec34ed9c | 1410 | // on reset la distance du telemetre à 0 |
ClementBreteau | 18:cc5fec34ed9c | 1411 | telemetreDistance = 5000; |
ClementBreteau | 18:cc5fec34ed9c | 1412 | #endif |
ClementBreteau | 18:cc5fec34ed9c | 1413 | }else{ |
antbig | 0:ad97421fb1fb | 1414 | //C'est un AX12 qu'il faut bouger |
ClementBreteau | 15:c2fc239e85df | 1415 | //AX12_setGoal(instruction.arg1,instruction.arg3/10,instruction.arg2); |
ClementBreteau | 15:c2fc239e85df | 1416 | //AX12_enchainement++; |
ClementBreteau | 14:c8fc06c4887f | 1417 | |
antbig | 0:ad97421fb1fb | 1418 | } |
antbig | 0:ad97421fb1fb | 1419 | break; |
antbig | 0:ad97421fb1fb | 1420 | default: |
antbig | 0:ad97421fb1fb | 1421 | //Instruction inconnue, on l'ignore |
antbig | 0:ad97421fb1fb | 1422 | break; |
antbig | 0:ad97421fb1fb | 1423 | } |
antbig | 0:ad97421fb1fb | 1424 | |
antbig | 0:ad97421fb1fb | 1425 | |
antbig | 0:ad97421fb1fb | 1426 | |
antbig | 0:ad97421fb1fb | 1427 | if(instruction.nextActionType == JUMP || instruction.nextActionType == WAIT) { |
antbig | 0:ad97421fb1fb | 1428 | gameEtat = ETAT_GAME_WAIT_ACK;//Il faut attendre que la carte est bien reçu l'acknowledge |
antbig | 0:ad97421fb1fb | 1429 | screenChecktry++;//On incrèment le conteur de tentative de 1 |
antbig | 0:ad97421fb1fb | 1430 | cartesCheker.reset();//On reset le timeOut |
antbig | 0:ad97421fb1fb | 1431 | cartesCheker.start(); |
antbig | 1:116040d14164 | 1432 | if(AX12_enchainement > 0) { |
ClementBreteau | 15:c2fc239e85df | 1433 | //AX12_processChange();//Il faut lancer le déplacement des AX12 |
ClementBreteau | 15:c2fc239e85df | 1434 | //AX12_enchainement = 0; |
antbig | 1:116040d14164 | 1435 | } |
Sitkah | 36:6dd30780bd8e | 1436 | } |
Sitkah | 36:6dd30780bd8e | 1437 | else {//C'est un enchainement |
ClementBreteau | 15:c2fc239e85df | 1438 | if(instruction.order == MV_LINE){ |
Sitkah | 30:a1e37af4bbde | 1439 | gameEtat = ETAT_GAME_WAIT_ACK; |
Sitkah | 30:a1e37af4bbde | 1440 | } |
Sitkah | 30:a1e37af4bbde | 1441 | else{ |
ClementBreteau | 15:c2fc239e85df | 1442 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
ClementBreteau | 15:c2fc239e85df | 1443 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;//C'est un enchainement, on charge directement l'instruction suivante |
ClementBreteau | 15:c2fc239e85df | 1444 | } |
antbig | 0:ad97421fb1fb | 1445 | } |
antbig | 0:ad97421fb1fb | 1446 | |
antbig | 0:ad97421fb1fb | 1447 | break; |
antbig | 0:ad97421fb1fb | 1448 | case ETAT_GAME_WAIT_ACK: |
Sitkah | 36:6dd30780bd8e | 1449 | canProcessRx(); |
Sitkah | 34:6aa4b46b102e | 1450 | |
Sitkah | 30:a1e37af4bbde | 1451 | if(waitingAckID == 0 && waitingAckFrom == 0) {//Les ack ont été reset, c'est bon on continue |
antbig | 0:ad97421fb1fb | 1452 | //if(true) { |
antbig | 0:ad97421fb1fb | 1453 | cartesCheker.stop(); |
antbig | 0:ad97421fb1fb | 1454 | if(instruction.nextActionType == JUMP) { |
antbig | 11:ed13a480ddca | 1455 | if(instruction.jumpAction == JUMP_POSITION) { |
antbig | 11:ed13a480ddca | 1456 | gameEtat = ETAT_GAME_JUMP_POSITION; |
Sitkah | 30:a1e37af4bbde | 1457 | } |
Sitkah | 30:a1e37af4bbde | 1458 | else {//Pour eviter les erreurs, on dit que c'est par défaut un jump time |
antbig | 0:ad97421fb1fb | 1459 | gameEtat = ETAT_GAME_JUMP_TIME; |
antbig | 0:ad97421fb1fb | 1460 | cartesCheker.reset();//On reset le timeOut |
antbig | 11:ed13a480ddca | 1461 | cartesCheker.start(); |
antbig | 0:ad97421fb1fb | 1462 | } |
Sitkah | 30:a1e37af4bbde | 1463 | } |
Sitkah | 30:a1e37af4bbde | 1464 | else if(instruction.nextActionType == WAIT) { ///Actualisation des waiting ack afin d'attendre la fin des actions |
Sitkah | 34:6aa4b46b102e | 1465 | gameEtat = ETAT_GAME_WAIT_END_INSTRUCTION; |
antbig | 0:ad97421fb1fb | 1466 | switch(instruction.order) |
antbig | 0:ad97421fb1fb | 1467 | { |
antbig | 0:ad97421fb1fb | 1468 | case MV_COURBURE: |
Sitkah | 34:6aa4b46b102e | 1469 | waitingAckID_FIN = ASSERVISSEMENT_COURBURE; |
Sitkah | 34:6aa4b46b102e | 1470 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
antbig | 0:ad97421fb1fb | 1471 | break; |
antbig | 0:ad97421fb1fb | 1472 | case MV_LINE: |
Sitkah | 34:6aa4b46b102e | 1473 | waitingAckID_FIN = ASSERVISSEMENT_RECALAGE; |
Sitkah | 34:6aa4b46b102e | 1474 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
antbig | 0:ad97421fb1fb | 1475 | break; |
antbig | 0:ad97421fb1fb | 1476 | case MV_TURN: |
Sitkah | 34:6aa4b46b102e | 1477 | waitingAckID_FIN = ASSERVISSEMENT_ROTATION; |
Sitkah | 34:6aa4b46b102e | 1478 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
antbig | 0:ad97421fb1fb | 1479 | break; |
antbig | 0:ad97421fb1fb | 1480 | case MV_XYT: |
Sitkah | 34:6aa4b46b102e | 1481 | waitingAckID_FIN = ASSERVISSEMENT_XYT; |
Sitkah | 34:6aa4b46b102e | 1482 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
antbig | 0:ad97421fb1fb | 1483 | break; |
antbig | 0:ad97421fb1fb | 1484 | case MV_RECALAGE: |
Sitkah | 34:6aa4b46b102e | 1485 | waitingAckID_FIN = ASSERVISSEMENT_RECALAGE; |
Sitkah | 34:6aa4b46b102e | 1486 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
antbig | 0:ad97421fb1fb | 1487 | break; |
antbig | 0:ad97421fb1fb | 1488 | case ACTION: |
ClementBreteau | 15:c2fc239e85df | 1489 | |
ClementBreteau | 15:c2fc239e85df | 1490 | if (modeTelemetre == 0){ |
ClementBreteau | 18:cc5fec34ed9c | 1491 | if (telemetreDistance == 0){ |
Sitkah | 34:6aa4b46b102e | 1492 | waitingAckID_FIN = ACK_FIN_ACTION;// ack de type action |
Sitkah | 34:6aa4b46b102e | 1493 | waitingAckFrom_FIN = ACKNOWLEDGE_HERKULEX; //de la part des herkulex/actionneurs |
ClementBreteau | 18:cc5fec34ed9c | 1494 | }else if(telemetreDistance == 5000){ |
ClementBreteau | 18:cc5fec34ed9c | 1495 | // on est dans le cas ou l'on fait une ligne suivant la distance du telemetre |
Sitkah | 34:6aa4b46b102e | 1496 | waitingAckID_FIN = ASSERVISSEMENT_RECALAGE; |
Sitkah | 34:6aa4b46b102e | 1497 | waitingAckFrom_FIN = INSTRUCTION_END_MOTEUR; |
ClementBreteau | 18:cc5fec34ed9c | 1498 | telemetreDistance = 0; |
ClementBreteau | 18:cc5fec34ed9c | 1499 | } |
ClementBreteau | 15:c2fc239e85df | 1500 | }else{ // si on attend la reponse du telemetre |
ClementBreteau | 15:c2fc239e85df | 1501 | //modeTelemetre = 1; |
Sitkah | 34:6aa4b46b102e | 1502 | waitingAckID_FIN = OBJET_SUR_TABLE; |
Sitkah | 34:6aa4b46b102e | 1503 | waitingAckFrom_FIN = 0; |
ClementBreteau | 15:c2fc239e85df | 1504 | } |
antbig | 0:ad97421fb1fb | 1505 | break; |
antbig | 0:ad97421fb1fb | 1506 | default: |
antbig | 0:ad97421fb1fb | 1507 | break; |
antbig | 0:ad97421fb1fb | 1508 | } |
Sitkah | 30:a1e37af4bbde | 1509 | } |
Sitkah | 30:a1e37af4bbde | 1510 | else { |
antbig | 0:ad97421fb1fb | 1511 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
antbig | 0:ad97421fb1fb | 1512 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 0:ad97421fb1fb | 1513 | } |
Sitkah | 30:a1e37af4bbde | 1514 | } |
Sitkah | 36:6dd30780bd8e | 1515 | else if(cartesCheker.read_ms () > 1000){ |
antbig | 0:ad97421fb1fb | 1516 | cartesCheker.stop(); |
antbig | 0:ad97421fb1fb | 1517 | if(screenChecktry >=2) {//La carte n'a pas reçus l'information, on passe à l'instruction d'erreur |
antbig | 0:ad97421fb1fb | 1518 | actual_instruction = instruction.nextLineError; |
antbig | 0:ad97421fb1fb | 1519 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
Sitkah | 30:a1e37af4bbde | 1520 | } |
Sitkah | 30:a1e37af4bbde | 1521 | else { |
Sitkah | 34:6aa4b46b102e | 1522 | gameEtat = ETAT_GAME_PROCESS_INSTRUCTION;//On retourne dans l'etat d'envois de l'instruction |
antbig | 0:ad97421fb1fb | 1523 | } |
antbig | 0:ad97421fb1fb | 1524 | } |
antbig | 0:ad97421fb1fb | 1525 | break; |
antbig | 0:ad97421fb1fb | 1526 | |
antbig | 0:ad97421fb1fb | 1527 | case ETAT_GAME_JUMP_TIME: |
antbig | 0:ad97421fb1fb | 1528 | if(cartesCheker.read_ms () >= instruction.JumpTimeOrX) { |
antbig | 0:ad97421fb1fb | 1529 | cartesCheker.stop();//On arrete le timer |
antbig | 0:ad97421fb1fb | 1530 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 0:ad97421fb1fb | 1531 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;//On charge l'instruction suivante |
antbig | 0:ad97421fb1fb | 1532 | } |
antbig | 0:ad97421fb1fb | 1533 | break; |
ClementBreteau | 15:c2fc239e85df | 1534 | |
ClementBreteau | 15:c2fc239e85df | 1535 | case ETAT_GAME_JUMP_CONFIG: |
ClementBreteau | 15:c2fc239e85df | 1536 | signed int depasX = 1, depasY = 1; // servent à indiquer le sens de dépassement des coordonnées |
ClementBreteau | 15:c2fc239e85df | 1537 | // 1 si l'instruction est plus grande que la position du robot |
ClementBreteau | 15:c2fc239e85df | 1538 | // -1 si l'instruction est plus petite que la position du robot |
ClementBreteau | 15:c2fc239e85df | 1539 | // 0 si l'instruction et position du robot sont proche de moins de 1cm |
ClementBreteau | 15:c2fc239e85df | 1540 | if (abs(x_robot-instruction.JumpTimeOrX)<10){ |
ClementBreteau | 15:c2fc239e85df | 1541 | depasX = 0; |
ClementBreteau | 15:c2fc239e85df | 1542 | }else if(x_robot > instruction.JumpTimeOrX){ |
ClementBreteau | 15:c2fc239e85df | 1543 | depasX = -1; |
ClementBreteau | 15:c2fc239e85df | 1544 | } |
ClementBreteau | 15:c2fc239e85df | 1545 | |
ClementBreteau | 15:c2fc239e85df | 1546 | if(abs(y_robot-instruction.JumpY)<10){ |
ClementBreteau | 15:c2fc239e85df | 1547 | depasY = 0; |
ClementBreteau | 15:c2fc239e85df | 1548 | }else if(y_robot > instruction.JumpY){ |
ClementBreteau | 15:c2fc239e85df | 1549 | depasY = -1; |
ClementBreteau | 15:c2fc239e85df | 1550 | } |
ClementBreteau | 15:c2fc239e85df | 1551 | |
ClementBreteau | 15:c2fc239e85df | 1552 | gameEtat = ETAT_GAME_JUMP_POSITION; |
ClementBreteau | 15:c2fc239e85df | 1553 | break; |
antbig | 0:ad97421fb1fb | 1554 | case ETAT_GAME_JUMP_POSITION: |
ClementBreteau | 15:c2fc239e85df | 1555 | bool Xok = false, Yok = false; |
ClementBreteau | 15:c2fc239e85df | 1556 | |
ClementBreteau | 15:c2fc239e85df | 1557 | if (depasX == 0){ |
ClementBreteau | 15:c2fc239e85df | 1558 | Xok = true; |
ClementBreteau | 15:c2fc239e85df | 1559 | }else if ((instruction.JumpTimeOrX - x_robot)*depasX < -5){ |
ClementBreteau | 15:c2fc239e85df | 1560 | Xok = true; |
ClementBreteau | 15:c2fc239e85df | 1561 | } |
ClementBreteau | 15:c2fc239e85df | 1562 | |
ClementBreteau | 15:c2fc239e85df | 1563 | if (depasY == 0){ |
ClementBreteau | 15:c2fc239e85df | 1564 | Yok = true; |
ClementBreteau | 15:c2fc239e85df | 1565 | }else if ((instruction.JumpY - y_robot)*depasY < -5){ |
ClementBreteau | 15:c2fc239e85df | 1566 | Yok = true; |
ClementBreteau | 15:c2fc239e85df | 1567 | } |
ClementBreteau | 15:c2fc239e85df | 1568 | |
ClementBreteau | 15:c2fc239e85df | 1569 | // on teste si les deux coordonnées ont été dépassées, si oui on lance l'instruction suivante |
ClementBreteau | 15:c2fc239e85df | 1570 | if (Xok && Yok){ |
ClementBreteau | 15:c2fc239e85df | 1571 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
ClementBreteau | 15:c2fc239e85df | 1572 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;//On charge l'instruction suivante |
ClementBreteau | 15:c2fc239e85df | 1573 | } |
ClementBreteau | 15:c2fc239e85df | 1574 | |
antbig | 0:ad97421fb1fb | 1575 | break; |
antbig | 0:ad97421fb1fb | 1576 | case ETAT_GAME_WAIT_END_INSTRUCTION: |
Sitkah | 36:6dd30780bd8e | 1577 | canProcessRx(); |
Sitkah | 35:742dc6b200b0 | 1578 | if(waitingAckID_FIN == 0 && waitingAckFrom_FIN ==0) {//On attend que la carte nous indique que l'instruction est terminée |
antbig | 0:ad97421fb1fb | 1579 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 0:ad97421fb1fb | 1580 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;//On charge l'instruction suivante |
antbig | 0:ad97421fb1fb | 1581 | } |
Sitkah | 34:6aa4b46b102e | 1582 | |
antbig | 0:ad97421fb1fb | 1583 | break; |
antbig | 0:ad97421fb1fb | 1584 | |
antbig | 0:ad97421fb1fb | 1585 | |
antbig | 5:dcd817534b57 | 1586 | case ETAT_WARNING_TIMEOUT://Attente de la trame fin de danger ou du timeout de 2s |
antbig | 12:14729d584500 | 1587 | if(timeoutWarning.read_ms() >= BALISE_TIMEOUT)//ça fait plus de 2s, il faut changer de stratégie |
antbig | 5:dcd817534b57 | 1588 | { |
antbig | 5:dcd817534b57 | 1589 | gameEtat = ETAT_WARNING_SWITCH_STRATEGIE; |
antbig | 5:dcd817534b57 | 1590 | } |
antbig | 5:dcd817534b57 | 1591 | break; |
antbig | 5:dcd817534b57 | 1592 | case ETAT_WARING_END_BALISE_WAIT://Attente d'une seconde apres la fin d'un End Balise pour etre sur que c'est bon |
antbig | 12:14729d584500 | 1593 | if(timeoutWarningWaitEnd.read_ms() >= 1000) {//c'est bon, on repart |
antbig | 12:14729d584500 | 1594 | //actual_instruction = instruction.nextLineError; |
antbig | 12:14729d584500 | 1595 | gameEtat = ETAT_WARNING_END_LAST_INSTRUCTION; |
antbig | 12:14729d584500 | 1596 | } |
antbig | 5:dcd817534b57 | 1597 | break; |
antbig | 5:dcd817534b57 | 1598 | case ETAT_WARNING_END_LAST_INSTRUCTION://trouver le meilleur moyen de reprendre l'instruction en cours |
ClementBreteau | 25:f140c93a8666 | 1599 | /* |
antbig | 12:14729d584500 | 1600 | #ifdef ROBOT_BIG |
ClementBreteau | 15:c2fc239e85df | 1601 | actual_instruction = instruction.nextLineError;// 2 //Modification directe... c'est pas bien mais ça marchait pour le match 5 |
antbig | 12:14729d584500 | 1602 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
ClementBreteau | 20:de595e4ff01d | 1603 | #else |
antbig | 12:14729d584500 | 1604 | actual_instruction = instruction.nextLineError; |
antbig | 12:14729d584500 | 1605 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
ClementBreteau | 20:de595e4ff01d | 1606 | #endif |
ClementBreteau | 25:f140c93a8666 | 1607 | gameEtat = ETAT_END;*/ |
ClementBreteau | 21:590cdacb6a35 | 1608 | |
ClementBreteau | 25:f140c93a8666 | 1609 | switch(actionPrecedente){ |
ClementBreteau | 25:f140c93a8666 | 1610 | case MV_LINE: |
antbig | 27:76ead555a63d | 1611 | |
ClementBreteau | 25:f140c93a8666 | 1612 | if(instruction.direction == BACKWARD) { |
ClementBreteau | 25:f140c93a8666 | 1613 | localData1 = -1; |
ClementBreteau | 25:f140c93a8666 | 1614 | } else { |
ClementBreteau | 25:f140c93a8666 | 1615 | localData1 = 1; |
ClementBreteau | 25:f140c93a8666 | 1616 | } |
antbig | 27:76ead555a63d | 1617 | |
ClementBreteau | 25:f140c93a8666 | 1618 | GoToPosition(target_x_robot,target_y_robot,target_theta_robot,localData1); |
antbig | 27:76ead555a63d | 1619 | debugXYTTarget(target_x_robot,target_y_robot,target_theta_robot); |
antbig | 27:76ead555a63d | 1620 | waitingAckID = ASSERVISSEMENT_XYT; |
antbig | 27:76ead555a63d | 1621 | waitingAckFrom = ACKNOWLEDGE_MOTEUR; |
antbig | 27:76ead555a63d | 1622 | gameEtat = ETAT_GAME_WAIT_ACK; |
antbig | 27:76ead555a63d | 1623 | instruction.order = MV_XYT; |
antbig | 28:acd18776ed2d | 1624 | instruction.arg1 = target_x_robot; |
antbig | 28:acd18776ed2d | 1625 | instruction.arg2 = target_y_robot; |
antbig | 28:acd18776ed2d | 1626 | instruction.arg3 = target_theta_robot; |
antbig | 28:acd18776ed2d | 1627 | instruction.direction = (localData1)?FORWARD:BACKWARD; |
antbig | 28:acd18776ed2d | 1628 | ingnorInversionOnce = 1;//Pour éviter que l'ago recalcul l'inversion |
antbig | 27:76ead555a63d | 1629 | return; |
ClementBreteau | 25:f140c93a8666 | 1630 | |
ClementBreteau | 25:f140c93a8666 | 1631 | case MV_XYT: |
antbig | 27:76ead555a63d | 1632 | gameEtat = ETAT_GAME_PROCESS_INSTRUCTION; |
Sitkah | 33:388aa0bf6af4 | 1633 | ///////cv |
ClementBreteau | 25:f140c93a8666 | 1634 | break; |
ClementBreteau | 25:f140c93a8666 | 1635 | |
ClementBreteau | 26:2f4fcc2354f3 | 1636 | case MV_COURBURE: |
antbig | 28:acd18776ed2d | 1637 | //target_theta_robot = theta_robot - target_theta_robot; |
antbig | 28:acd18776ed2d | 1638 | //instruction.arg3 = instruction.arg3 - target_theta_robot; |
ClementBreteau | 26:2f4fcc2354f3 | 1639 | if(instruction.direction == LEFT){ |
ClementBreteau | 26:2f4fcc2354f3 | 1640 | target_theta_robot = target_theta_robot - theta_robot; |
ClementBreteau | 26:2f4fcc2354f3 | 1641 | }else{ |
antbig | 28:acd18776ed2d | 1642 | target_theta_robot = theta_robot + target_theta_robot; |
antbig | 28:acd18776ed2d | 1643 | } |
antbig | 28:acd18776ed2d | 1644 | |
antbig | 28:acd18776ed2d | 1645 | |
antbig | 28:acd18776ed2d | 1646 | target_theta_robot = (target_theta_robot)%3600; |
antbig | 28:acd18776ed2d | 1647 | if(target_theta_robot > 1800) { |
antbig | 28:acd18776ed2d | 1648 | target_theta_robot = target_theta_robot-3600; |
antbig | 28:acd18776ed2d | 1649 | } |
antbig | 28:acd18776ed2d | 1650 | if(InversStrat == 1) { |
antbig | 28:acd18776ed2d | 1651 | target_theta_robot = -target_theta_robot; |
antbig | 28:acd18776ed2d | 1652 | } |
antbig | 28:acd18776ed2d | 1653 | instruction.arg3 = target_theta_robot; |
antbig | 28:acd18776ed2d | 1654 | |
antbig | 28:acd18776ed2d | 1655 | |
antbig | 28:acd18776ed2d | 1656 | gameEtat = ETAT_GAME_PROCESS_INSTRUCTION; |
antbig | 28:acd18776ed2d | 1657 | |
ClementBreteau | 25:f140c93a8666 | 1658 | break; |
antbig | 27:76ead555a63d | 1659 | default: |
antbig | 27:76ead555a63d | 1660 | actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 27:76ead555a63d | 1661 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
antbig | 27:76ead555a63d | 1662 | break; |
ClementBreteau | 25:f140c93a8666 | 1663 | } |
ClementBreteau | 25:f140c93a8666 | 1664 | |
antbig | 27:76ead555a63d | 1665 | //actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante |
antbig | 27:76ead555a63d | 1666 | //gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
antbig | 5:dcd817534b57 | 1667 | break; |
antbig | 5:dcd817534b57 | 1668 | case ETAT_WARNING_SWITCH_STRATEGIE://Si à la fin du timeout il y a toujours un robot, passer à l'instruction d'erreur |
antbig | 5:dcd817534b57 | 1669 | actual_instruction = instruction.nextLineError; |
antbig | 5:dcd817534b57 | 1670 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
antbig | 12:14729d584500 | 1671 | ingnorBaliseOnce = 1; |
antbig | 5:dcd817534b57 | 1672 | break; |
ClementBreteau | 20:de595e4ff01d | 1673 | |
ClementBreteau | 20:de595e4ff01d | 1674 | |
ClementBreteau | 20:de595e4ff01d | 1675 | |
ClementBreteau | 14:c8fc06c4887f | 1676 | case ETAT_END: |
ClementBreteau | 14:c8fc06c4887f | 1677 | if (ModeDemo){ |
ClementBreteau | 14:c8fc06c4887f | 1678 | gameEtat = ETAT_CHECK_CARTE_SCREEN; |
ClementBreteau | 14:c8fc06c4887f | 1679 | ModeDemo = 1; |
ClementBreteau | 14:c8fc06c4887f | 1680 | } else { |
ClementBreteau | 14:c8fc06c4887f | 1681 | gameEtat = ETAT_END_LOOP; |
ClementBreteau | 14:c8fc06c4887f | 1682 | } |
antbig | 0:ad97421fb1fb | 1683 | break; |
antbig | 0:ad97421fb1fb | 1684 | case ETAT_END_LOOP: |
antbig | 0:ad97421fb1fb | 1685 | //Rien, on tourne en rond |
ClementBreteau | 18:cc5fec34ed9c | 1686 | |
antbig | 0:ad97421fb1fb | 1687 | break; |
antbig | 0:ad97421fb1fb | 1688 | default: |
ClementBreteau | 20:de595e4ff01d | 1689 | |
antbig | 0:ad97421fb1fb | 1690 | break; |
ClementBreteau | 20:de595e4ff01d | 1691 | } |
Sitkah | 29:41e02746041d | 1692 | } |
Sitkah | 29:41e02746041d | 1693 | |
Sitkah | 29:41e02746041d | 1694 | |
Sitkah | 29:41e02746041d | 1695 | |
Sitkah | 29:41e02746041d | 1696 | |
Sitkah | 29:41e02746041d | 1697 | |
antbig | 4:88431b537477 | 1698 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 1699 | /* FUNCTION NAME: canProcessRx */ |
Sitkah | 29:41e02746041d | 1700 | /* DESCRIPTION : Fait évoluer l'automate de l'IHM en fonction des receptions sur le CAN*/ |
antbig | 4:88431b537477 | 1701 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 1702 | void canProcessRx(void) |
Sitkah | 29:41e02746041d | 1703 | { |
antbig | 0:ad97421fb1fb | 1704 | static signed char FIFO_occupation=0,FIFO_max_occupation=0; |
Sitkah | 29:41e02746041d | 1705 | char useless1 = 0; |
Sitkah | 31:833fc481b002 | 1706 | char message[10]="toto"; |
Sitkah | 31:833fc481b002 | 1707 | char message1[10]="toto"; |
Sitkah | 31:833fc481b002 | 1708 | char message2[10]="toto"; |
Sitkah | 31:833fc481b002 | 1709 | char message3[10]="toto"; |
antbig | 0:ad97421fb1fb | 1710 | FIFO_occupation=FIFO_ecriture-FIFO_lecture; |
antbig | 0:ad97421fb1fb | 1711 | if(FIFO_occupation<0) |
antbig | 0:ad97421fb1fb | 1712 | FIFO_occupation=FIFO_occupation+SIZE_FIFO; |
antbig | 0:ad97421fb1fb | 1713 | if(FIFO_max_occupation<FIFO_occupation) |
antbig | 0:ad97421fb1fb | 1714 | FIFO_max_occupation=FIFO_occupation; |
antbig | 0:ad97421fb1fb | 1715 | if(FIFO_occupation!=0) { |
Sitkah | 29:41e02746041d | 1716 | int identifiant=msgRxBuffer[FIFO_lecture].id; |
Sitkah | 29:41e02746041d | 1717 | switch(identifiant) { |
Sitkah | 29:41e02746041d | 1718 | |
Sitkah | 29:41e02746041d | 1719 | case ALIVE_MOTEUR: |
Sitkah | 29:41e02746041d | 1720 | if (etat == ATT) { |
Sitkah | 29:41e02746041d | 1721 | |
Sitkah | 29:41e02746041d | 1722 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
Sitkah | 34:6aa4b46b102e | 1723 | lcd.FillRect(0,400,400,150); |
Sitkah | 29:41e02746041d | 1724 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 1725 | lcd.SetBackColor(LCD_COLOR_LIGHTGREEN); |
Sitkah | 34:6aa4b46b102e | 1726 | lcd.DisplayStringAt(80, 450, (uint8_t *)"Carte Moteur", LEFT_MODE); |
Sitkah | 29:41e02746041d | 1727 | } |
Sitkah | 29:41e02746041d | 1728 | break; |
Sitkah | 29:41e02746041d | 1729 | |
Sitkah | 29:41e02746041d | 1730 | case ALIVE_BALISE: |
Sitkah | 29:41e02746041d | 1731 | if (etat == ATT) { |
Sitkah | 29:41e02746041d | 1732 | |
Sitkah | 29:41e02746041d | 1733 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
Sitkah | 34:6aa4b46b102e | 1734 | lcd.FillRect(0,600,400,150); //carte AX12 |
Sitkah | 29:41e02746041d | 1735 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Sitkah | 29:41e02746041d | 1736 | lcd.SetBackColor(LCD_COLOR_LIGHTGREEN); |
Sitkah | 34:6aa4b46b102e | 1737 | lcd.DisplayStringAt(110, 650, (uint8_t *)"Balise", LEFT_MODE); |
Sitkah | 29:41e02746041d | 1738 | } |
Sitkah | 29:41e02746041d | 1739 | break; |
Sitkah | 29:41e02746041d | 1740 | |
Sitkah | 29:41e02746041d | 1741 | case RESET_IHM: |
Sitkah | 29:41e02746041d | 1742 | etat = CHOIX; |
Sitkah | 29:41e02746041d | 1743 | break; |
Sitkah | 29:41e02746041d | 1744 | |
antbig | 4:88431b537477 | 1745 | case DEBUG_FAKE_JAKE://Permet de lancer le match à distance |
ClementBreteau | 23:ab87d308eaf9 | 1746 | case GLOBAL_JACK: |
antbig | 1:116040d14164 | 1747 | if(gameEtat == ETAT_GAME_WAIT_FOR_JACK) { |
antbig | 1:116040d14164 | 1748 | gameEtat = ETAT_GAME_START; |
ClementBreteau | 23:ab87d308eaf9 | 1749 | SendRawId(ACKNOWLEDGE_JACK); |
antbig | 1:116040d14164 | 1750 | } |
antbig | 1:116040d14164 | 1751 | break; |
antbig | 1:116040d14164 | 1752 | |
Sitkah | 30:a1e37af4bbde | 1753 | case ALIVE_ACTIONNEURS_AVANT: //pas de break donc passe directement dans ECRAN_ALL_CHECK mais conserve l'ident initial |
ClementBreteau | 23:ab87d308eaf9 | 1754 | case ALIVE_ACTIONNEURS_ARRIERE: |
Sitkah | 30:a1e37af4bbde | 1755 | case ALIVE_HERKULEX: |
antbig | 0:ad97421fb1fb | 1756 | case ECRAN_ALL_CHECK: |
antbig | 0:ad97421fb1fb | 1757 | if(waitingAckFrom == msgRxBuffer[FIFO_lecture].id) { |
antbig | 0:ad97421fb1fb | 1758 | waitingAckFrom = 0;//C'est la bonne carte qui indique qu'elle est en ligne |
antbig | 0:ad97421fb1fb | 1759 | } |
ClementBreteau | 15:c2fc239e85df | 1760 | break; |
antbig | 0:ad97421fb1fb | 1761 | |
Sitkah | 30:a1e37af4bbde | 1762 | |
Sitkah | 30:a1e37af4bbde | 1763 | |
Sitkah | 30:a1e37af4bbde | 1764 | |
Sitkah | 30:a1e37af4bbde | 1765 | /////////////////////////////////////Acknowledges de Reception de la demande d'action//////////////////////////////////////// |
Sitkah | 30:a1e37af4bbde | 1766 | case ACKNOWLEDGE_HERKULEX: |
Sitkah | 30:a1e37af4bbde | 1767 | case ACKNOWLEDGE_BALISE: //pas de break donc passe directement dans INSTRUCTION_END_AX12 mais conserve l'ident initial |
Sitkah | 34:6aa4b46b102e | 1768 | |
Sitkah | 30:a1e37af4bbde | 1769 | case ACKNOWLEDGE_TELEMETRE: |
Sitkah | 30:a1e37af4bbde | 1770 | /////////////////////////////////////////////Acknowledges de la fin d'action///////////////////////////////////////////////// |
Sitkah | 34:6aa4b46b102e | 1771 | case ACKNOWLEDGE_MOTEUR: |
antbig | 0:ad97421fb1fb | 1772 | case INSTRUCTION_END_BALISE: |
antbig | 0:ad97421fb1fb | 1773 | case INSTRUCTION_END_MOTEUR: |
Sitkah | 31:833fc481b002 | 1774 | case ACK_FIN_ACTION: |
antbig | 11:ed13a480ddca | 1775 | if(waitingAckFrom == msgRxBuffer[FIFO_lecture].id && ((unsigned short)msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8) == waitingAckID)) { |
Sitkah | 36:6dd30780bd8e | 1776 | lcd.DisplayStringAt(0, LINE(16),(unsigned char *)"ACK OK",LEFT_MODE); |
antbig | 0:ad97421fb1fb | 1777 | waitingAckFrom = 0; |
Sitkah | 30:a1e37af4bbde | 1778 | waitingAckID = 0; |
antbig | 0:ad97421fb1fb | 1779 | } |
Sitkah | 34:6aa4b46b102e | 1780 | if(waitingAckFrom_FIN == msgRxBuffer[FIFO_lecture].id && ((unsigned short)msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8) == waitingAckID_FIN)) { |
Sitkah | 34:6aa4b46b102e | 1781 | //SendRawId(waitingAckID); |
Sitkah | 34:6aa4b46b102e | 1782 | waitingAckFrom_FIN = 0; |
Sitkah | 34:6aa4b46b102e | 1783 | waitingAckID_FIN = 0; |
Sitkah | 34:6aa4b46b102e | 1784 | } |
Sitkah | 30:a1e37af4bbde | 1785 | |
antbig | 0:ad97421fb1fb | 1786 | break; |
antbig | 1:116040d14164 | 1787 | #ifdef ROBOT_BIG |
antbig | 0:ad97421fb1fb | 1788 | case ODOMETRIE_BIG_POSITION: |
antbig | 0:ad97421fb1fb | 1789 | #else |
antbig | 0:ad97421fb1fb | 1790 | case ODOMETRIE_SMALL_POSITION: |
antbig | 0:ad97421fb1fb | 1791 | #endif |
antbig | 0:ad97421fb1fb | 1792 | x_robot=msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8); |
antbig | 0:ad97421fb1fb | 1793 | y_robot=msgRxBuffer[FIFO_lecture].data[2]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[3])<<8); |
antbig | 0:ad97421fb1fb | 1794 | theta_robot=msgRxBuffer[FIFO_lecture].data[4]|((signed short)(msgRxBuffer[FIFO_lecture].data[5])<<8); |
antbig | 0:ad97421fb1fb | 1795 | break; |
Sitkah | 29:41e02746041d | 1796 | |
Sitkah | 30:a1e37af4bbde | 1797 | //case SERVO_AX12_SETGOAL: |
antbig | 9:d0042422d95a | 1798 | //SendAck(0x114, SERVO_AX12_SETGOAL); |
ClementBreteau | 14:c8fc06c4887f | 1799 | //if(AX12_isLocal(msgRxBuffer[FIFO_lecture].data[0])) |
ClementBreteau | 14:c8fc06c4887f | 1800 | //AX12_setGoal(msgRxBuffer[FIFO_lecture].data[0], msgRxBuffer[FIFO_lecture].data[1]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[2])<<8), msgRxBuffer[FIFO_lecture].data[3]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[4])<<8)); |
antbig | 5:dcd817534b57 | 1801 | |
Sitkah | 30:a1e37af4bbde | 1802 | //break; |
ClementBreteau | 14:c8fc06c4887f | 1803 | |
Sitkah | 30:a1e37af4bbde | 1804 | /*case SERVO_AX12_PROCESS: |
ClementBreteau | 14:c8fc06c4887f | 1805 | SendAck(0x114, SERVO_AX12_PROCESS); |
ClementBreteau | 14:c8fc06c4887f | 1806 | //AX12_processChange(1); |
antbig | 0:ad97421fb1fb | 1807 | break; |
ClementBreteau | 14:c8fc06c4887f | 1808 | |
antbig | 1:116040d14164 | 1809 | case SERVO_AX12_DONE: |
ClementBreteau | 15:c2fc239e85df | 1810 | SendRawId(POMPE_PWM); |
Sitkah | 30:a1e37af4bbde | 1811 | //SendAck(0x114, SERVO_AX12_DONE); |
antbig | 1:116040d14164 | 1812 | AX12_notifyCANEnd(((unsigned short)(msgRxBuffer[FIFO_lecture].data[0]))); |
ClementBreteau | 14:c8fc06c4887f | 1813 | |
ClementBreteau | 15:c2fc239e85df | 1814 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
ClementBreteau | 14:c8fc06c4887f | 1815 | waitingAckFrom = 0; |
ClementBreteau | 14:c8fc06c4887f | 1816 | waitingAckID = 0;*/ |
ClementBreteau | 14:c8fc06c4887f | 1817 | |
Sitkah | 30:a1e37af4bbde | 1818 | //break; |
Sitkah | 30:a1e37af4bbde | 1819 | case ACK_ACTION: |
Sitkah | 30:a1e37af4bbde | 1820 | if(waitingAckID == msgRxBuffer[FIFO_lecture].id) { |
Sitkah | 30:a1e37af4bbde | 1821 | waitingAckFrom = 0; |
Sitkah | 30:a1e37af4bbde | 1822 | waitingAckID = 0; |
Sitkah | 30:a1e37af4bbde | 1823 | } |
Sitkah | 30:a1e37af4bbde | 1824 | break; |
Sitkah | 30:a1e37af4bbde | 1825 | |
ClementBreteau | 16:7321fb3bb396 | 1826 | case BALISE_DANGER : |
ClementBreteau | 16:7321fb3bb396 | 1827 | SendAck(ACKNOWLEDGE_BALISE, BALISE_END_DANGER); |
ClementBreteau | 16:7321fb3bb396 | 1828 | break; |
ClementBreteau | 16:7321fb3bb396 | 1829 | |
antbig | 5:dcd817534b57 | 1830 | case BALISE_STOP: |
antbig | 5:dcd817534b57 | 1831 | SendAck(ACKNOWLEDGE_BALISE, BALISE_STOP); |
antbig | 28:acd18776ed2d | 1832 | if (instruction.order != MV_TURN && instruction.order != ACTION ){ //J'ai rajouté cette ligne mais il faut tester avec et sans pour voir le comportement du robot, |
ClementBreteau | 16:7321fb3bb396 | 1833 | if(needToStop() != 0 && ingnorBaliseOnce ==0) { |
ClementBreteau | 16:7321fb3bb396 | 1834 | if(gameEtat > ETAT_GAME_START && gameEtat != ETAT_WARNING_TIMEOUT) |
ClementBreteau | 16:7321fb3bb396 | 1835 | { |
ClementBreteau | 16:7321fb3bb396 | 1836 | SendRawId(ASSERVISSEMENT_STOP); |
ClementBreteau | 26:2f4fcc2354f3 | 1837 | //while(1); // ligne à décommenter si on est en homologation |
ClementBreteau | 16:7321fb3bb396 | 1838 | if(gameEtat != ETAT_WARING_END_BALISE_WAIT) { |
ClementBreteau | 16:7321fb3bb396 | 1839 | timeoutWarning.reset(); |
ClementBreteau | 16:7321fb3bb396 | 1840 | timeoutWarning.start();//Reset du timer utiliser par le timeout |
ClementBreteau | 16:7321fb3bb396 | 1841 | } |
antbig | 27:76ead555a63d | 1842 | gameEtat = ETAT_WARNING_TIMEOUT; |
antbig | 12:14729d584500 | 1843 | } |
antbig | 12:14729d584500 | 1844 | } |
antbig | 28:acd18776ed2d | 1845 | } |
antbig | 12:14729d584500 | 1846 | ingnorBaliseOnce = 0; |
antbig | 5:dcd817534b57 | 1847 | break; |
ClementBreteau | 16:7321fb3bb396 | 1848 | |
antbig | 5:dcd817534b57 | 1849 | case BALISE_END_DANGER: |
ClementBreteau | 16:7321fb3bb396 | 1850 | SendAck(ACKNOWLEDGE_BALISE, BALISE_END_DANGER); |
antbig | 5:dcd817534b57 | 1851 | if(gameEtat == ETAT_WARNING_TIMEOUT) { |
antbig | 5:dcd817534b57 | 1852 | timeoutWarningWaitEnd.reset(); |
antbig | 5:dcd817534b57 | 1853 | timeoutWarningWaitEnd.start(); |
antbig | 5:dcd817534b57 | 1854 | gameEtat = ETAT_WARING_END_BALISE_WAIT; |
antbig | 5:dcd817534b57 | 1855 | } |
antbig | 5:dcd817534b57 | 1856 | break; |
antbig | 12:14729d584500 | 1857 | |
ClementBreteau | 14:c8fc06c4887f | 1858 | case OBJET_SUR_TABLE: |
ClementBreteau | 15:c2fc239e85df | 1859 | if (msgRxBuffer[FIFO_lecture].data[1] == 0xff){ |
ClementBreteau | 15:c2fc239e85df | 1860 | |
ClementBreteau | 15:c2fc239e85df | 1861 | gameEtat = ETAT_WARNING_END_LAST_INSTRUCTION; |
ClementBreteau | 15:c2fc239e85df | 1862 | } |
ClementBreteau | 15:c2fc239e85df | 1863 | else{ |
ClementBreteau | 15:c2fc239e85df | 1864 | |
ClementBreteau | 15:c2fc239e85df | 1865 | waitingAckFrom = 0; |
ClementBreteau | 15:c2fc239e85df | 1866 | waitingAckID = 0; |
ClementBreteau | 15:c2fc239e85df | 1867 | |
ClementBreteau | 15:c2fc239e85df | 1868 | strat_instructions[actual_instruction+1].arg1 = returnX(strat_instructions[actual_instruction].arg2); |
ClementBreteau | 15:c2fc239e85df | 1869 | strat_instructions[actual_instruction+1].arg2 = returnY(strat_instructions[actual_instruction].arg2); |
ClementBreteau | 15:c2fc239e85df | 1870 | } |
ClementBreteau | 15:c2fc239e85df | 1871 | modeTelemetre = 0; |
ClementBreteau | 14:c8fc06c4887f | 1872 | break; |
Sitkah | 29:41e02746041d | 1873 | |
Sitkah | 30:a1e37af4bbde | 1874 | case RECEPTION_DATA: |
Sitkah | 30:a1e37af4bbde | 1875 | telemetreDistance=char_to_short_transformation(msgRxBuffer[FIFO_lecture].data[0], msgRxBuffer[FIFO_lecture].data[1]); |
Sitkah | 30:a1e37af4bbde | 1876 | telemetreDistance= (float)telemetreDistance*100*35.5+50; |
Sitkah | 30:a1e37af4bbde | 1877 | waitingAckFrom = 0; |
Sitkah | 30:a1e37af4bbde | 1878 | waitingAckID = 0; |
Sitkah | 30:a1e37af4bbde | 1879 | break; |
Sitkah | 30:a1e37af4bbde | 1880 | |
Sitkah | 31:833fc481b002 | 1881 | case RECEPTION_RECALAGE: |
Sitkah | 34:6aa4b46b102e | 1882 | telemetreDistance_arriere_droite = char_to_short_transformation(msgRxBuffer[FIFO_lecture].data[0], msgRxBuffer[FIFO_lecture].data[1]); // |
Sitkah | 34:6aa4b46b102e | 1883 | telemetreDistance_avant_droite = char_to_short_transformation(msgRxBuffer[FIFO_lecture].data[2], msgRxBuffer[FIFO_lecture].data[3]); |
Sitkah | 34:6aa4b46b102e | 1884 | telemetreDistance_arriere_gauche = char_to_short_transformation(msgRxBuffer[FIFO_lecture].data[4], msgRxBuffer[FIFO_lecture].data[5]); |
Sitkah | 34:6aa4b46b102e | 1885 | telemetreDistance_avant_gauche = char_to_short_transformation(msgRxBuffer[FIFO_lecture].data[6], msgRxBuffer[FIFO_lecture].data[7]); |
Sitkah | 34:6aa4b46b102e | 1886 | |
Sitkah | 34:6aa4b46b102e | 1887 | |
Sitkah | 34:6aa4b46b102e | 1888 | |
Sitkah | 34:6aa4b46b102e | 1889 | if(ModeDemo==1) |
Sitkah | 34:6aa4b46b102e | 1890 | { |
Sitkah | 34:6aa4b46b102e | 1891 | sprintf(message,"%04d mm",telemetreDistance_arriere_droite); |
Sitkah | 31:833fc481b002 | 1892 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 1893 | lcd.DisplayStringAt(0, LINE(10),(unsigned char *)"LASER ARD : ",LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1894 | lcd.DisplayStringAt(200, LINE(10),(unsigned char *)message, LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1895 | |
Sitkah | 34:6aa4b46b102e | 1896 | sprintf(message1,"%04d mm",telemetreDistance_avant_droite); |
Sitkah | 31:833fc481b002 | 1897 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 1898 | lcd.DisplayStringAt(0, LINE(12),(unsigned char *)"LASER AVD : ",LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1899 | lcd.DisplayStringAt(200, LINE(12),(unsigned char *)message1, LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1900 | |
Sitkah | 34:6aa4b46b102e | 1901 | sprintf(message2,"%04d mm",telemetreDistance_arriere_gauche); |
Sitkah | 31:833fc481b002 | 1902 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 1903 | lcd.DisplayStringAt(0, LINE(14),(unsigned char *)"LASER ARG : ",LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1904 | lcd.DisplayStringAt(200, LINE(14),(unsigned char *)message2, LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1905 | |
Sitkah | 34:6aa4b46b102e | 1906 | sprintf(message3,"%04d mm",telemetreDistance_avant_gauche); |
Sitkah | 31:833fc481b002 | 1907 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Sitkah | 31:833fc481b002 | 1908 | lcd.DisplayStringAt(0, LINE(16),(unsigned char *)"LASER AVG : ",LEFT_MODE); |
Sitkah | 34:6aa4b46b102e | 1909 | lcd.DisplayStringAt(200, LINE(16),(unsigned char *)message3, LEFT_MODE); |
Sitkah | 31:833fc481b002 | 1910 | } |
Sitkah | 30:a1e37af4bbde | 1911 | break; |
Sitkah | 29:41e02746041d | 1912 | |
Sitkah | 30:a1e37af4bbde | 1913 | case RECEPTION_COULEUR: |
Sitkah | 30:a1e37af4bbde | 1914 | couleur1=msgRxBuffer[FIFO_lecture].data[0]; |
Sitkah | 30:a1e37af4bbde | 1915 | couleur2=msgRxBuffer[FIFO_lecture].data[1]; |
Sitkah | 30:a1e37af4bbde | 1916 | couleur3=msgRxBuffer[FIFO_lecture].data[2]; |
Sitkah | 30:a1e37af4bbde | 1917 | break; |
Sitkah | 30:a1e37af4bbde | 1918 | |
Sitkah | 35:742dc6b200b0 | 1919 | case NO_BLOC: //il n'y a pas de bloc, on saute les étapes liées à l'attrape bloc |
Sitkah | 35:742dc6b200b0 | 1920 | actual_instruction = instruction.nextLineError; |
Sitkah | 35:742dc6b200b0 | 1921 | gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION; |
Sitkah | 35:742dc6b200b0 | 1922 | /*waitingAckID_FIN=0; |
Sitkah | 35:742dc6b200b0 | 1923 | waitingAckFrom_FIN=0;*/ |
Sitkah | 35:742dc6b200b0 | 1924 | SendRawId(0x40); |
Sitkah | 35:742dc6b200b0 | 1925 | break; |
Sitkah | 29:41e02746041d | 1926 | } |
antbig | 0:ad97421fb1fb | 1927 | FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO; |
antbig | 0:ad97421fb1fb | 1928 | } |
antbig | 0:ad97421fb1fb | 1929 | } |
Sitkah | 29:41e02746041d | 1930 | |
Sitkah | 29:41e02746041d | 1931 | |
Sitkah | 29:41e02746041d | 1932 | |
Sitkah | 29:41e02746041d | 1933 | |
Sitkah | 29:41e02746041d | 1934 | |
Sitkah | 29:41e02746041d | 1935 | /****************************************************************************************/ |
Sitkah | 29:41e02746041d | 1936 | /* FUNCTION NAME: Bouton_Strat */ |
Sitkah | 29:41e02746041d | 1937 | /* DESCRIPTION : Sélection de la strat sur le lcd puis envoie sur CAN (à modifier!) */ |
Sitkah | 29:41e02746041d | 1938 | /****************************************************************************************/ |
Sitkah | 29:41e02746041d | 1939 | signed char Bouton_Strat (void) |
Sitkah | 29:41e02746041d | 1940 | { |
Sitkah | 29:41e02746041d | 1941 | Button STRAT_1 (0, 30, 190, 110, strat_sd[0]); |
Sitkah | 29:41e02746041d | 1942 | Button STRAT_2 (210, 30, 190, 110, strat_sd[1]); |
Sitkah | 29:41e02746041d | 1943 | Button STRAT_3 (0, 150, 190, 110, strat_sd[2]); |
Sitkah | 29:41e02746041d | 1944 | Button STRAT_4 (210, 150, 190, 110, strat_sd[3]); |
Sitkah | 29:41e02746041d | 1945 | Button STRAT_5 (0, 270, 190, 110,strat_sd[4]); |
Sitkah | 29:41e02746041d | 1946 | Button STRAT_6 (210, 270, 190, 110, strat_sd[5]); |
Sitkah | 29:41e02746041d | 1947 | Button STRAT_7 (0, 390, 190, 110, strat_sd[6]); |
Sitkah | 29:41e02746041d | 1948 | Button STRAT_8 (210, 390, 190, 110, strat_sd[7]); |
Sitkah | 29:41e02746041d | 1949 | Button STRAT_9 (0, 510, 190, 110, strat_sd[8]); |
Sitkah | 29:41e02746041d | 1950 | Button STRAT_10 (210, 510, 190, 110, strat_sd[9]); |
Sitkah | 29:41e02746041d | 1951 | Button RETOUR (0, 680, 400, 110, "--Precedent--"); |
Sitkah | 29:41e02746041d | 1952 | //Definition des boutons |
Sitkah | 29:41e02746041d | 1953 | |
Sitkah | 29:41e02746041d | 1954 | Ack_strat = 0; |
Sitkah | 29:41e02746041d | 1955 | Strat = 0; |
Sitkah | 29:41e02746041d | 1956 | STRAT_1.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1957 | STRAT_2.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1958 | STRAT_3.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1959 | STRAT_4.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1960 | STRAT_5.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1961 | STRAT_6.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1962 | STRAT_7.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1963 | STRAT_8.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1964 | STRAT_9.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1965 | STRAT_10.Draw(0xFFF0F0F0, 0); |
Sitkah | 29:41e02746041d | 1966 | RETOUR.Draw(0xFFFF0000, 0); |
Sitkah | 29:41e02746041d | 1967 | |
Sitkah | 29:41e02746041d | 1968 | while(Ack_strat == 0) |
Sitkah | 29:41e02746041d | 1969 | { |
Sitkah | 29:41e02746041d | 1970 | canProcessRx(); |
Sitkah | 29:41e02746041d | 1971 | CANMessage msgTx=CANMessage(); |
Sitkah | 30:a1e37af4bbde | 1972 | //msgTx.id=ECRAN_CHOICE_STRAT; |
Sitkah | 29:41e02746041d | 1973 | if (RETOUR.Touched()) |
Sitkah | 29:41e02746041d | 1974 | return -1; |
Sitkah | 29:41e02746041d | 1975 | while(RETOUR.Touched()); |
Sitkah | 29:41e02746041d | 1976 | //////////////////////////////STRATEGIE N°1 |
Sitkah | 29:41e02746041d | 1977 | if (STRAT_1.Touched()){ |
Sitkah | 29:41e02746041d | 1978 | Strat = 0; |
Sitkah | 30:a1e37af4bbde | 1979 | //msgTx.data[0] = 0x1; |
Sitkah | 30:a1e37af4bbde | 1980 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 1981 | while(STRAT_1.Touched()); |
Sitkah | 29:41e02746041d | 1982 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 1983 | } |
Sitkah | 29:41e02746041d | 1984 | /////////////////////////////STRATEGIE N°2 |
Sitkah | 29:41e02746041d | 1985 | if (STRAT_2.Touched()){ |
Sitkah | 29:41e02746041d | 1986 | Strat = 1; |
Sitkah | 30:a1e37af4bbde | 1987 | //msgTx.data[0] = 0x2; |
Sitkah | 30:a1e37af4bbde | 1988 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 1989 | while(STRAT_2.Touched()); |
Sitkah | 29:41e02746041d | 1990 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 1991 | } |
Sitkah | 29:41e02746041d | 1992 | //////////////////////////////STRATEGIE N°3 |
Sitkah | 29:41e02746041d | 1993 | if (STRAT_3.Touched()){ |
Sitkah | 29:41e02746041d | 1994 | Strat = 2; |
Sitkah | 30:a1e37af4bbde | 1995 | //msgTx.data[0] = 0x3; |
Sitkah | 30:a1e37af4bbde | 1996 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 1997 | while(STRAT_3.Touched()); |
Sitkah | 29:41e02746041d | 1998 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 1999 | } |
Sitkah | 29:41e02746041d | 2000 | /////////////////////////////STRATEGIE N°4 |
Sitkah | 29:41e02746041d | 2001 | if (STRAT_4.Touched()){ |
Sitkah | 29:41e02746041d | 2002 | Strat = 3; |
Sitkah | 30:a1e37af4bbde | 2003 | //msgTx.data[0] = 0x4; |
Sitkah | 30:a1e37af4bbde | 2004 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2005 | while(STRAT_4.Touched()); |
Sitkah | 29:41e02746041d | 2006 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2007 | } |
Sitkah | 29:41e02746041d | 2008 | ///////////////////////////////STRATEGIE N°5 |
Sitkah | 29:41e02746041d | 2009 | if (STRAT_5.Touched()){ |
Sitkah | 29:41e02746041d | 2010 | Strat = 4; |
Sitkah | 30:a1e37af4bbde | 2011 | //msgTx.data[0] = 0x5; |
Sitkah | 30:a1e37af4bbde | 2012 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2013 | while(STRAT_5.Touched()); |
Sitkah | 29:41e02746041d | 2014 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2015 | } |
Sitkah | 29:41e02746041d | 2016 | ////////////////////////////////STRATEGIE N°6 |
Sitkah | 29:41e02746041d | 2017 | if (STRAT_6.Touched()){ |
Sitkah | 29:41e02746041d | 2018 | Strat = 5; |
Sitkah | 30:a1e37af4bbde | 2019 | //msgTx.data[0] = 0x6; |
Sitkah | 30:a1e37af4bbde | 2020 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2021 | while(STRAT_6.Touched()); |
Sitkah | 29:41e02746041d | 2022 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2023 | } |
Sitkah | 29:41e02746041d | 2024 | /////////////////////////////////STRATEGIE N°7 |
Sitkah | 29:41e02746041d | 2025 | if (STRAT_7.Touched()){ |
Sitkah | 29:41e02746041d | 2026 | Strat = 6; |
Sitkah | 30:a1e37af4bbde | 2027 | //msgTx.data[0] = 0x7; |
Sitkah | 30:a1e37af4bbde | 2028 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2029 | while(STRAT_7.Touched()); |
Sitkah | 29:41e02746041d | 2030 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2031 | } |
Sitkah | 29:41e02746041d | 2032 | /////////////////////////////////STRATEGIE N°8 |
Sitkah | 29:41e02746041d | 2033 | if (STRAT_8.Touched()){ |
Sitkah | 29:41e02746041d | 2034 | Strat = 7; |
Sitkah | 30:a1e37af4bbde | 2035 | //msgTx.data[0] = 0x8; |
Sitkah | 30:a1e37af4bbde | 2036 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2037 | while(STRAT_8.Touched()); |
Sitkah | 29:41e02746041d | 2038 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2039 | } |
Sitkah | 29:41e02746041d | 2040 | /////////////////////////////////STRATEGIE N°9 |
Sitkah | 29:41e02746041d | 2041 | if (STRAT_9.Touched()){ |
Sitkah | 29:41e02746041d | 2042 | Strat = 8; |
Sitkah | 30:a1e37af4bbde | 2043 | //msgTx.data[0] = 0x9; |
Sitkah | 30:a1e37af4bbde | 2044 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2045 | while(STRAT_9.Touched()); |
Sitkah | 29:41e02746041d | 2046 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2047 | } |
Sitkah | 29:41e02746041d | 2048 | ///////////////////////////////////STRATEGIE N°10 |
Sitkah | 29:41e02746041d | 2049 | if (STRAT_10.Touched()){ |
Sitkah | 29:41e02746041d | 2050 | Strat = 9; |
Sitkah | 30:a1e37af4bbde | 2051 | //msgTx.data[0] = 0xA; |
Sitkah | 30:a1e37af4bbde | 2052 | //can2.write(msgTx); |
Sitkah | 29:41e02746041d | 2053 | while(STRAT_10.Touched()); |
Sitkah | 29:41e02746041d | 2054 | Ack_strat =1; |
Sitkah | 29:41e02746041d | 2055 | } |
Sitkah | 29:41e02746041d | 2056 | |
Sitkah | 29:41e02746041d | 2057 | } |
Sitkah | 29:41e02746041d | 2058 | return Strat; |
Sitkah | 29:41e02746041d | 2059 | |
Sitkah | 29:41e02746041d | 2060 | } |
Sitkah | 29:41e02746041d | 2061 | |
Sitkah | 29:41e02746041d | 2062 | void affichage_compteur (int nombre) |
Sitkah | 29:41e02746041d | 2063 | { |
Sitkah | 29:41e02746041d | 2064 | int dizaine=0,unite=0; |
Sitkah | 29:41e02746041d | 2065 | dizaine = nombre/10; |
Sitkah | 29:41e02746041d | 2066 | unite = nombre-(10*dizaine); |
Sitkah | 29:41e02746041d | 2067 | print_segment(unite,0); |
Sitkah | 29:41e02746041d | 2068 | print_segment(dizaine,200); |
Sitkah | 29:41e02746041d | 2069 | |
Sitkah | 29:41e02746041d | 2070 | } |
Sitkah | 29:41e02746041d | 2071 | |
Sitkah | 29:41e02746041d | 2072 | |
Sitkah | 29:41e02746041d | 2073 | //****print_segment*** |
Sitkah | 29:41e02746041d | 2074 | //Dessine en 7 segment le nombre en parametre |
Sitkah | 29:41e02746041d | 2075 | // A |
Sitkah | 29:41e02746041d | 2076 | // ===== |
Sitkah | 29:41e02746041d | 2077 | // | | |
Sitkah | 29:41e02746041d | 2078 | // B | G | E |
Sitkah | 29:41e02746041d | 2079 | // |=====| |
Sitkah | 29:41e02746041d | 2080 | // C | | F |
Sitkah | 29:41e02746041d | 2081 | // | | |
Sitkah | 29:41e02746041d | 2082 | // ===== |
Sitkah | 29:41e02746041d | 2083 | // D |
Sitkah | 29:41e02746041d | 2084 | /* |
Sitkah | 29:41e02746041d | 2085 | position pour le chiffre des unites |
Sitkah | 29:41e02746041d | 2086 | lcd.FillRect(460,75,120,25);// A |
Sitkah | 29:41e02746041d | 2087 | lcd.FillRect(435,100,25,120);// B |
Sitkah | 29:41e02746041d | 2088 | lcd.FillRect(435,245,25,120);// C |
Sitkah | 29:41e02746041d | 2089 | lcd.FillRect(460,365,120,25);// D |
Sitkah | 29:41e02746041d | 2090 | lcd.FillRect(580,100,25,120);// E |
Sitkah | 29:41e02746041d | 2091 | lcd.FillRect(580,245,25,120);// F |
Sitkah | 29:41e02746041d | 2092 | lcd.FillRect(460,220,120,25);// G |
Sitkah | 29:41e02746041d | 2093 | |
Sitkah | 29:41e02746041d | 2094 | position pour le chiffre des dizaines |
Sitkah | 29:41e02746041d | 2095 | lcd.FillRect(260,75,120,25);// A |
Sitkah | 29:41e02746041d | 2096 | lcd.FillRect(235,100,25,120);// B |
Sitkah | 29:41e02746041d | 2097 | lcd.FillRect(235,245,25,120);// C |
Sitkah | 29:41e02746041d | 2098 | lcd.FillRect(260,365,120,25);// D |
Sitkah | 29:41e02746041d | 2099 | lcd.FillRect(380,100,25,120);// E |
Sitkah | 29:41e02746041d | 2100 | lcd.FillRect(380,245,25,120);// F |
Sitkah | 29:41e02746041d | 2101 | lcd.FillRect(260,220,120,25);// G |
Sitkah | 29:41e02746041d | 2102 | */ |
Sitkah | 29:41e02746041d | 2103 | |
Sitkah | 29:41e02746041d | 2104 | void print_segment(int nombre, int decalage) |
Sitkah | 29:41e02746041d | 2105 | { |
Sitkah | 29:41e02746041d | 2106 | switch(nombre) |
Sitkah | 29:41e02746041d | 2107 | { |
Sitkah | 29:41e02746041d | 2108 | case 0: |
Sitkah | 29:41e02746041d | 2109 | lcd.FillRect(240-decalage,75,120,25); |
Sitkah | 29:41e02746041d | 2110 | lcd.FillRect(215-decalage,100,25,120); |
Sitkah | 29:41e02746041d | 2111 | lcd.FillRect(215-decalage,245,25,120); |
Sitkah | 29:41e02746041d | 2112 | lcd.FillRect(360-decalage,245,25,120); |
Sitkah | 29:41e02746041d | 2113 | lcd.FillRect(360-decalage,100,25,120); |
Sitkah | 29:41e02746041d | 2114 | lcd.FillRect(240-decalage,365,120,25); |
Sitkah | 29:41e02746041d | 2115 | break; |
Sitkah | 29:41e02746041d | 2116 | |
Sitkah | 29:41e02746041d | 2117 | case 1: |
Sitkah | 29:41e02746041d | 2118 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2119 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2120 | break; |
Sitkah | 29:41e02746041d | 2121 | |
Sitkah | 29:41e02746041d | 2122 | case 2: |
Sitkah | 29:41e02746041d | 2123 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2124 | lcd.FillRect(215-decalage,245,25,120);// C |
Sitkah | 29:41e02746041d | 2125 | lcd.FillRect(240-decalage,365,120,25);// D |
Sitkah | 29:41e02746041d | 2126 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2127 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2128 | break; |
Sitkah | 29:41e02746041d | 2129 | |
Sitkah | 29:41e02746041d | 2130 | case 3: |
Sitkah | 29:41e02746041d | 2131 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2132 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2133 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2134 | lcd.FillRect(240-decalage,365,120,25);// D |
Sitkah | 29:41e02746041d | 2135 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2136 | break; |
Sitkah | 29:41e02746041d | 2137 | |
Sitkah | 29:41e02746041d | 2138 | case 4: |
Sitkah | 29:41e02746041d | 2139 | lcd.FillRect(215-decalage,100,25,120);// B |
Sitkah | 29:41e02746041d | 2140 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2141 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2142 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2143 | break; |
Sitkah | 29:41e02746041d | 2144 | |
Sitkah | 29:41e02746041d | 2145 | case 5: |
Sitkah | 29:41e02746041d | 2146 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2147 | lcd.FillRect(215-decalage,100,25,120);// B |
Sitkah | 29:41e02746041d | 2148 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2149 | lcd.FillRect(240-decalage,365,120,25);// D |
Sitkah | 29:41e02746041d | 2150 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2151 | break; |
Sitkah | 29:41e02746041d | 2152 | |
Sitkah | 29:41e02746041d | 2153 | case 6: |
Sitkah | 29:41e02746041d | 2154 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2155 | lcd.FillRect(215-decalage,100,25,120);// B |
Sitkah | 29:41e02746041d | 2156 | lcd.FillRect(215-decalage,245,25,120);// C |
Sitkah | 29:41e02746041d | 2157 | lcd.FillRect(240-decalage,365,120,25);// D |
Sitkah | 29:41e02746041d | 2158 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2159 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2160 | break; |
Sitkah | 29:41e02746041d | 2161 | |
Sitkah | 29:41e02746041d | 2162 | case 7: |
Sitkah | 29:41e02746041d | 2163 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2164 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2165 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2166 | break; |
Sitkah | 29:41e02746041d | 2167 | |
Sitkah | 29:41e02746041d | 2168 | case 8: |
Sitkah | 29:41e02746041d | 2169 | lcd.FillRect(240-decalage,75,120,25); // A |
Sitkah | 29:41e02746041d | 2170 | lcd.FillRect(215-decalage,100,25,120); |
Sitkah | 29:41e02746041d | 2171 | lcd.FillRect(215-decalage,245,25,120); |
Sitkah | 29:41e02746041d | 2172 | lcd.FillRect(360-decalage,245,25,120);//... |
Sitkah | 29:41e02746041d | 2173 | lcd.FillRect(360-decalage,100,25,120); |
Sitkah | 29:41e02746041d | 2174 | lcd.FillRect(240-decalage,365,120,25); |
Sitkah | 29:41e02746041d | 2175 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2176 | break; |
Sitkah | 29:41e02746041d | 2177 | |
Sitkah | 29:41e02746041d | 2178 | case 9: |
Sitkah | 29:41e02746041d | 2179 | lcd.FillRect(240-decalage,75,120,25);// A |
Sitkah | 29:41e02746041d | 2180 | lcd.FillRect(215-decalage,100,25,120);// B |
Sitkah | 29:41e02746041d | 2181 | lcd.FillRect(240-decalage,365,120,25);// D |
Sitkah | 29:41e02746041d | 2182 | lcd.FillRect(360-decalage,100,25,120);// E |
Sitkah | 29:41e02746041d | 2183 | lcd.FillRect(360-decalage,245,25,120);// F |
Sitkah | 29:41e02746041d | 2184 | lcd.FillRect(240-decalage,220,120,25);// G |
Sitkah | 29:41e02746041d | 2185 | break; |
Sitkah | 29:41e02746041d | 2186 | } |
Sitkah | 29:41e02746041d | 2187 | } |
Sitkah | 29:41e02746041d | 2188 | |
Sitkah | 29:41e02746041d | 2189 | void effacer_segment(long couleur) |
Sitkah | 29:41e02746041d | 2190 | { |
Sitkah | 29:41e02746041d | 2191 | lcd.SetTextColor(couleur); |
Sitkah | 29:41e02746041d | 2192 | lcd.FillRect(240-200,75,120,25); // A |
Sitkah | 29:41e02746041d | 2193 | lcd.FillRect(215-200,100,25,120); |
Sitkah | 29:41e02746041d | 2194 | lcd.FillRect(215-200,245,25,120); |
Sitkah | 29:41e02746041d | 2195 | lcd.FillRect(360-200,245,25,120);//... |
Sitkah | 29:41e02746041d | 2196 | lcd.FillRect(360-200,100,25,120); |
Sitkah | 29:41e02746041d | 2197 | lcd.FillRect(240-200,365,120,25); |
Sitkah | 29:41e02746041d | 2198 | lcd.FillRect(240-200,220,120,25);// G |
Sitkah | 29:41e02746041d | 2199 | |
Sitkah | 29:41e02746041d | 2200 | lcd.FillRect(240,75,120,25); // A |
Sitkah | 29:41e02746041d | 2201 | lcd.FillRect(215,100,25,120); |
Sitkah | 29:41e02746041d | 2202 | lcd.FillRect(215,245,25,120); |
Sitkah | 29:41e02746041d | 2203 | lcd.FillRect(360,245,25,120);//... |
Sitkah | 29:41e02746041d | 2204 | lcd.FillRect(360,100,25,120); |
Sitkah | 29:41e02746041d | 2205 | lcd.FillRect(240,365,120,25); |
Sitkah | 29:41e02746041d | 2206 | lcd.FillRect(240,220,120,25);// G |
Sitkah | 29:41e02746041d | 2207 | } |
Sitkah | 36:6dd30780bd8e | 2208 | |
Sitkah | 36:6dd30780bd8e | 2209 | short recalageAngulaireCapteur(void) |
Sitkah | 36:6dd30780bd8e | 2210 | { |
Sitkah | 36:6dd30780bd8e | 2211 | unsigned char nombresDeMesuresAuxTelemetresQuiSontCoherentes = 0; |
Sitkah | 36:6dd30780bd8e | 2212 | unsigned int moyennageTelemetre = 0; |
Sitkah | 36:6dd30780bd8e | 2213 | unsigned short angleAvant = 0; |
Sitkah | 36:6dd30780bd8e | 2214 | unsigned short angleArriere = 0; |
Sitkah | 36:6dd30780bd8e | 2215 | unsigned short orientationArrondie = 0; |
Sitkah | 36:6dd30780bd8e | 2216 | |
Sitkah | 36:6dd30780bd8e | 2217 | unsigned short position_avant_gauche=0; |
Sitkah | 36:6dd30780bd8e | 2218 | unsigned short position_avant_droite=0; |
Sitkah | 36:6dd30780bd8e | 2219 | unsigned short position_arriere_gauche=0; |
Sitkah | 36:6dd30780bd8e | 2220 | unsigned short position_arriere_droite=0; |
Sitkah | 36:6dd30780bd8e | 2221 | |
Sitkah | 36:6dd30780bd8e | 2222 | if(theta_robot >= 450 && theta_robot <= 1350) |
Sitkah | 36:6dd30780bd8e | 2223 | orientationArrondie = 90; |
Sitkah | 36:6dd30780bd8e | 2224 | else if(theta_robot <= -450 && theta_robot >= -1350) |
Sitkah | 36:6dd30780bd8e | 2225 | orientationArrondie = 270; |
Sitkah | 36:6dd30780bd8e | 2226 | else if(theta_robot <= 450 && theta_robot >= -450) |
Sitkah | 36:6dd30780bd8e | 2227 | orientationArrondie = 0; |
Sitkah | 36:6dd30780bd8e | 2228 | else if(theta_robot >= 1350 && theta_robot <= -1350) |
Sitkah | 36:6dd30780bd8e | 2229 | orientationArrondie = 180; |
Sitkah | 36:6dd30780bd8e | 2230 | |
Sitkah | 36:6dd30780bd8e | 2231 | // Calcul de position pour faire la vérification de cohérence |
Sitkah | 36:6dd30780bd8e | 2232 | if(orientationArrondie == 90 || orientationArrondie == 270) |
Sitkah | 36:6dd30780bd8e | 2233 | { |
Sitkah | 36:6dd30780bd8e | 2234 | position_avant_gauche = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?3000:0) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?-1:1)*telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2235 | position_avant_droite = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?3000:0) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?-1:1)*telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2236 | position_arriere_gauche = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?0:3000) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?1:-1)*telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2237 | position_arriere_droite = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?0:3000) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?1:-1)*telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2238 | |
Sitkah | 36:6dd30780bd8e | 2239 | } |
Sitkah | 36:6dd30780bd8e | 2240 | else if(orientationArrondie == 0 || orientationArrondie == 180) |
Sitkah | 36:6dd30780bd8e | 2241 | { |
Sitkah | 36:6dd30780bd8e | 2242 | position_avant_gauche = ((theta_robot < 900 && theta_robot > -900)?2000:0) + ((theta_robot < 900 && theta_robot > -900)?-1:1)*telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2243 | position_avant_droite = ((theta_robot < 900 && theta_robot > -900)?2000:0) + ((theta_robot < 900 && theta_robot > -900)?-1:1)*telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2244 | position_arriere_gauche = ((theta_robot < 900 && theta_robot > -900)?0:2000) + ((theta_robot < 900 && theta_robot > -900)?1:-1)*telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2245 | position_arriere_droite = ((theta_robot < 900 && theta_robot > -900)?0:2000) + ((theta_robot < 900 && theta_robot > -900)?1:-1)*telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2246 | } |
Sitkah | 36:6dd30780bd8e | 2247 | |
Sitkah | 36:6dd30780bd8e | 2248 | |
Sitkah | 36:6dd30780bd8e | 2249 | if(orientationArrondie == 90 || orientationArrondie == 270) // Si il est en axe Y |
Sitkah | 36:6dd30780bd8e | 2250 | { |
Sitkah | 36:6dd30780bd8e | 2251 | if(position_arriere_droite >= y_robot-instruction.arg1 && position_arriere_droite <= y_robot+instruction.arg1) // Et que les mesures sont cohérentes |
Sitkah | 36:6dd30780bd8e | 2252 | { |
Sitkah | 36:6dd30780bd8e | 2253 | if(position_arriere_gauche >= y_robot-instruction.arg1 && position_arriere_gauche <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2254 | { |
Sitkah | 36:6dd30780bd8e | 2255 | if(telemetreDistance_arriere_droite > telemetreDistance_arriere_gauche) |
Sitkah | 36:6dd30780bd8e | 2256 | angleArriere =900+(1800 * atan2((double)(telemetreDistance_arriere_droite-telemetreDistance_arriere_gauche) , (double)ESPACE_INTER_TELEMETRE ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2257 | else |
Sitkah | 36:6dd30780bd8e | 2258 | angleArriere =(1800 * atan2( (double) ESPACE_INTER_TELEMETRE,(double) (telemetreDistance_arriere_gauche-telemetreDistance_arriere_droite) ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2259 | |
Sitkah | 36:6dd30780bd8e | 2260 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2261 | moyennageTelemetre += angleArriere; |
Sitkah | 36:6dd30780bd8e | 2262 | } |
Sitkah | 36:6dd30780bd8e | 2263 | } |
Sitkah | 36:6dd30780bd8e | 2264 | } |
Sitkah | 36:6dd30780bd8e | 2265 | else if(orientationArrondie == 0 || orientationArrondie == 180) // Si il est en axe X |
Sitkah | 36:6dd30780bd8e | 2266 | { |
Sitkah | 36:6dd30780bd8e | 2267 | if(position_arriere_droite >= x_robot-instruction.arg1 && position_arriere_droite <= x_robot+instruction.arg1) // Et que les mesures sont cohérentes |
Sitkah | 36:6dd30780bd8e | 2268 | { |
Sitkah | 36:6dd30780bd8e | 2269 | if(position_arriere_gauche >= x_robot-instruction.arg1 && position_arriere_gauche <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2270 | { |
Sitkah | 36:6dd30780bd8e | 2271 | if(telemetreDistance_arriere_droite > telemetreDistance_arriere_gauche) |
Sitkah | 36:6dd30780bd8e | 2272 | angleArriere =900+(1800 * atan2( (double) (telemetreDistance_arriere_droite-telemetreDistance_arriere_gauche) , (double) ESPACE_INTER_TELEMETRE ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2273 | else |
Sitkah | 36:6dd30780bd8e | 2274 | angleArriere =(1800 * atan2( (double) ESPACE_INTER_TELEMETRE,(double) (telemetreDistance_arriere_gauche-telemetreDistance_arriere_droite) ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2275 | |
Sitkah | 36:6dd30780bd8e | 2276 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2277 | moyennageTelemetre += angleArriere; |
Sitkah | 36:6dd30780bd8e | 2278 | } |
Sitkah | 36:6dd30780bd8e | 2279 | } |
Sitkah | 36:6dd30780bd8e | 2280 | } |
Sitkah | 36:6dd30780bd8e | 2281 | |
Sitkah | 36:6dd30780bd8e | 2282 | if(orientationArrondie == 90 || orientationArrondie == 270) // Si il est en axe Y |
Sitkah | 36:6dd30780bd8e | 2283 | { |
Sitkah | 36:6dd30780bd8e | 2284 | if(position_avant_droite >= y_robot-instruction.arg1 && position_avant_droite <= y_robot+instruction.arg1) // Et que les mesures sont cohérentes |
Sitkah | 36:6dd30780bd8e | 2285 | { |
Sitkah | 36:6dd30780bd8e | 2286 | if(position_avant_gauche >= y_robot-instruction.arg1 && position_avant_gauche <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2287 | { |
Sitkah | 36:6dd30780bd8e | 2288 | if(telemetreDistance_avant_droite > telemetreDistance_avant_gauche) |
Sitkah | 36:6dd30780bd8e | 2289 | angleAvant = (1800 * atan2( (double) ESPACE_INTER_TELEMETRE,(double) (telemetreDistance_avant_droite-telemetreDistance_avant_gauche) ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2290 | else |
Sitkah | 36:6dd30780bd8e | 2291 | angleAvant = 900 + (1800 * atan2( (double)( telemetreDistance_avant_gauche-telemetreDistance_avant_droite) ,(double) ESPACE_INTER_TELEMETRE ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2292 | |
Sitkah | 36:6dd30780bd8e | 2293 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2294 | moyennageTelemetre += angleAvant; |
Sitkah | 36:6dd30780bd8e | 2295 | } |
Sitkah | 36:6dd30780bd8e | 2296 | } |
Sitkah | 36:6dd30780bd8e | 2297 | } |
Sitkah | 36:6dd30780bd8e | 2298 | else if(orientationArrondie == 0 || orientationArrondie == 180) // Si il est en axe X |
Sitkah | 36:6dd30780bd8e | 2299 | { |
Sitkah | 36:6dd30780bd8e | 2300 | if(position_avant_droite >= x_robot-instruction.arg1 && position_avant_droite <= x_robot+instruction.arg1) // Et que les mesures sont cohérentes |
Sitkah | 36:6dd30780bd8e | 2301 | { |
Sitkah | 36:6dd30780bd8e | 2302 | if(position_avant_gauche >= x_robot-instruction.arg1 && position_avant_gauche <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2303 | { |
Sitkah | 36:6dd30780bd8e | 2304 | if(telemetreDistance_avant_droite > telemetreDistance_avant_gauche) |
Sitkah | 36:6dd30780bd8e | 2305 | angleAvant = (1800 * atan2((double) ESPACE_INTER_TELEMETRE, (double) (telemetreDistance_avant_droite-telemetreDistance_avant_gauche) ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2306 | else |
Sitkah | 36:6dd30780bd8e | 2307 | angleAvant = 900 + (1800 * atan2( (double) (telemetreDistance_avant_gauche-telemetreDistance_avant_droite) ,(double) ESPACE_INTER_TELEMETRE ))/M_PI; |
Sitkah | 36:6dd30780bd8e | 2308 | |
Sitkah | 36:6dd30780bd8e | 2309 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2310 | moyennageTelemetre += angleAvant; |
Sitkah | 36:6dd30780bd8e | 2311 | } |
Sitkah | 36:6dd30780bd8e | 2312 | } |
Sitkah | 36:6dd30780bd8e | 2313 | } |
Sitkah | 36:6dd30780bd8e | 2314 | |
Sitkah | 36:6dd30780bd8e | 2315 | angleRecalage = moyennageTelemetre/nombresDeMesuresAuxTelemetresQuiSontCoherentes; |
Sitkah | 36:6dd30780bd8e | 2316 | |
Sitkah | 36:6dd30780bd8e | 2317 | |
Sitkah | 36:6dd30780bd8e | 2318 | |
Sitkah | 36:6dd30780bd8e | 2319 | if(nombresDeMesuresAuxTelemetresQuiSontCoherentes) |
Sitkah | 36:6dd30780bd8e | 2320 | { |
Sitkah | 36:6dd30780bd8e | 2321 | if(orientationArrondie == 0) |
Sitkah | 36:6dd30780bd8e | 2322 | { |
Sitkah | 36:6dd30780bd8e | 2323 | angleRecalage -= 900; |
Sitkah | 36:6dd30780bd8e | 2324 | |
Sitkah | 36:6dd30780bd8e | 2325 | /*if(telemetreDistance_avant_droite > telemetreDistance_avant_gauche) |
Sitkah | 36:6dd30780bd8e | 2326 | distanceRecalage = *); |
Sitkah | 36:6dd30780bd8e | 2327 | else |
Sitkah | 36:6dd30780bd8e | 2328 | distanceRecalage = 900 + (1800 * atan( (double)( (telemetreDistance_avant_droite-telemetreDistance_avant_gauche) / ESPACE_INTER_TELEMETRE )))/M_PI;*/ |
Sitkah | 36:6dd30780bd8e | 2329 | } |
Sitkah | 36:6dd30780bd8e | 2330 | else if(orientationArrondie == 90) |
Sitkah | 36:6dd30780bd8e | 2331 | { |
Sitkah | 36:6dd30780bd8e | 2332 | angleRecalage += 0; |
Sitkah | 36:6dd30780bd8e | 2333 | } |
Sitkah | 36:6dd30780bd8e | 2334 | else if(orientationArrondie == 180) |
Sitkah | 36:6dd30780bd8e | 2335 | { |
Sitkah | 36:6dd30780bd8e | 2336 | angleRecalage += 900; |
Sitkah | 36:6dd30780bd8e | 2337 | } |
Sitkah | 36:6dd30780bd8e | 2338 | else if(orientationArrondie == 270) |
Sitkah | 36:6dd30780bd8e | 2339 | { |
Sitkah | 36:6dd30780bd8e | 2340 | angleRecalage += 1800; |
Sitkah | 36:6dd30780bd8e | 2341 | } |
Sitkah | 36:6dd30780bd8e | 2342 | } |
Sitkah | 36:6dd30780bd8e | 2343 | |
Sitkah | 36:6dd30780bd8e | 2344 | return (nombresDeMesuresAuxTelemetresQuiSontCoherentes && (angleAvant-angleArriere<80 && angleAvant-angleArriere>-80)) ? angleRecalage : theta_robot; |
Sitkah | 36:6dd30780bd8e | 2345 | } |
Sitkah | 36:6dd30780bd8e | 2346 | |
Sitkah | 36:6dd30780bd8e | 2347 | short recalageDistanceX(void) |
Sitkah | 36:6dd30780bd8e | 2348 | { |
Sitkah | 36:6dd30780bd8e | 2349 | unsigned char nombresDeMesuresAuxTelemetresQuiSontCoherentes = 0; |
Sitkah | 36:6dd30780bd8e | 2350 | unsigned int moyennageTelemetre = 0; |
Sitkah | 36:6dd30780bd8e | 2351 | |
Sitkah | 36:6dd30780bd8e | 2352 | telemetreDistance_avant_gauche = ((theta_robot < 900 && theta_robot > -900)?2000:0) + ((theta_robot < 900 && theta_robot > -900)?-1:1)*telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2353 | telemetreDistance_avant_droite = ((theta_robot < 900 && theta_robot > -900)?2000:0) + ((theta_robot < 900 && theta_robot > -900)?-1:1)*telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2354 | telemetreDistance_arriere_gauche = ((theta_robot < 900 && theta_robot > -900)?0:2000) + ((theta_robot < 900 && theta_robot > -900)?1:-1)*telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2355 | telemetreDistance_arriere_droite = ((theta_robot < 900 && theta_robot > -900)?0:2000) + ((theta_robot < 900 && theta_robot > -900)?1:-1)*telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2356 | |
Sitkah | 36:6dd30780bd8e | 2357 | if(telemetreDistance_avant_gauche >= x_robot-instruction.arg1 && telemetreDistance_avant_gauche <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2358 | { |
Sitkah | 36:6dd30780bd8e | 2359 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2360 | moyennageTelemetre += telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2361 | } |
Sitkah | 36:6dd30780bd8e | 2362 | if(telemetreDistance_avant_droite >= x_robot-instruction.arg1 && telemetreDistance_avant_droite <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2363 | { |
Sitkah | 36:6dd30780bd8e | 2364 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2365 | moyennageTelemetre += telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2366 | } |
Sitkah | 36:6dd30780bd8e | 2367 | if(telemetreDistance_arriere_gauche >= x_robot-instruction.arg1 && telemetreDistance_arriere_gauche <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2368 | { |
Sitkah | 36:6dd30780bd8e | 2369 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2370 | moyennageTelemetre += telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2371 | } |
Sitkah | 36:6dd30780bd8e | 2372 | if(telemetreDistance_arriere_droite >= x_robot-instruction.arg1 && telemetreDistance_arriere_droite <= x_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2373 | { |
Sitkah | 36:6dd30780bd8e | 2374 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2375 | moyennageTelemetre += telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2376 | } |
Sitkah | 36:6dd30780bd8e | 2377 | |
Sitkah | 36:6dd30780bd8e | 2378 | moyennageTelemetre /= nombresDeMesuresAuxTelemetresQuiSontCoherentes; |
Sitkah | 36:6dd30780bd8e | 2379 | |
Sitkah | 36:6dd30780bd8e | 2380 | return (nombresDeMesuresAuxTelemetresQuiSontCoherentes)? moyennageTelemetre : x_robot; //SetOdometrie(ODOMETRIE_SMALL_POSITION, moyennageTelemetre, y_robot, theta_robot); |
Sitkah | 36:6dd30780bd8e | 2381 | } |
Sitkah | 36:6dd30780bd8e | 2382 | |
Sitkah | 36:6dd30780bd8e | 2383 | short recalageDistanceY(void) |
Sitkah | 36:6dd30780bd8e | 2384 | { |
Sitkah | 36:6dd30780bd8e | 2385 | unsigned char nombresDeMesuresAuxTelemetresQuiSontCoherentes = 0; |
Sitkah | 36:6dd30780bd8e | 2386 | unsigned int moyennageTelemetre = 0; |
Sitkah | 36:6dd30780bd8e | 2387 | |
Sitkah | 36:6dd30780bd8e | 2388 | telemetreDistance_avant_gauche = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?3000:0) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?-1:1)*telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2389 | telemetreDistance_avant_droite = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?3000:0) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?-1:1)*telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2390 | telemetreDistance_arriere_gauche = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?0:3000) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?1:-1)*telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2391 | telemetreDistance_arriere_droite = (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?0:3000) + (((theta_robot < 1800 && theta_robot > 0) || (theta_robot < -1800 && theta_robot > -3600))?1:-1)*telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2392 | |
Sitkah | 36:6dd30780bd8e | 2393 | if(telemetreDistance_avant_gauche >= y_robot-instruction.arg1 && telemetreDistance_avant_gauche <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2394 | { |
Sitkah | 36:6dd30780bd8e | 2395 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2396 | moyennageTelemetre += telemetreDistance_avant_gauche; |
Sitkah | 36:6dd30780bd8e | 2397 | } |
Sitkah | 36:6dd30780bd8e | 2398 | if(telemetreDistance_avant_droite >= y_robot-instruction.arg1 && telemetreDistance_avant_droite <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2399 | { |
Sitkah | 36:6dd30780bd8e | 2400 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2401 | moyennageTelemetre += telemetreDistance_avant_droite; |
Sitkah | 36:6dd30780bd8e | 2402 | } |
Sitkah | 36:6dd30780bd8e | 2403 | if(telemetreDistance_arriere_gauche >= y_robot-instruction.arg1 && telemetreDistance_arriere_gauche <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2404 | { |
Sitkah | 36:6dd30780bd8e | 2405 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2406 | moyennageTelemetre += telemetreDistance_arriere_gauche; |
Sitkah | 36:6dd30780bd8e | 2407 | } |
Sitkah | 36:6dd30780bd8e | 2408 | if(telemetreDistance_arriere_droite >= y_robot-instruction.arg1 && telemetreDistance_arriere_droite <= y_robot+instruction.arg1) |
Sitkah | 36:6dd30780bd8e | 2409 | { |
Sitkah | 36:6dd30780bd8e | 2410 | nombresDeMesuresAuxTelemetresQuiSontCoherentes++; |
Sitkah | 36:6dd30780bd8e | 2411 | moyennageTelemetre += telemetreDistance_arriere_droite; |
Sitkah | 36:6dd30780bd8e | 2412 | } |
Sitkah | 36:6dd30780bd8e | 2413 | |
Sitkah | 36:6dd30780bd8e | 2414 | moyennageTelemetre /= nombresDeMesuresAuxTelemetresQuiSontCoherentes; |
Sitkah | 36:6dd30780bd8e | 2415 | |
Sitkah | 36:6dd30780bd8e | 2416 | return (nombresDeMesuresAuxTelemetresQuiSontCoherentes)? moyennageTelemetre : y_robot ; // SetOdometrie(ODOMETRIE_SMALL_POSITION, x_robot, moyennageTelemetre, theta_robot); |
Sitkah | 36:6dd30780bd8e | 2417 | } |
Sitkah | 36:6dd30780bd8e | 2418 |