code avec modifs, programme mit dans les robots pour les derniers matchs

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Committer:
gabrieltetar
Date:
Wed Jun 24 09:39:42 2020 +0000
Revision:
21:d137ec53c3a9
Child:
22:c7763a7ec6c7
SPLIT - A TEST

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gabrieltetar 21:d137ec53c3a9 1 #include "global.h"
gabrieltetar 21:d137ec53c3a9 2
gabrieltetar 21:d137ec53c3a9 3 #define VERT 0xFF00FF00
gabrieltetar 21:d137ec53c3a9 4 #define ROUGE 0xFFFF0000
gabrieltetar 21:d137ec53c3a9 5 #define BLEU 0xFF0000FF
gabrieltetar 21:d137ec53c3a9 6 #define JAUNE 0xFFFDD835//FEFE00
gabrieltetar 21:d137ec53c3a9 7 #define BLANC 0xFF000000
gabrieltetar 21:d137ec53c3a9 8 #define ORANGE 0xFFFFA500
gabrieltetar 21:d137ec53c3a9 9 #define NOIR 0xFF000000
gabrieltetar 21:d137ec53c3a9 10 #define DIY_GREY 0xFFDFDFDF
gabrieltetar 21:d137ec53c3a9 11 #define VIOLET 0xFF4527A0
gabrieltetar 21:d137ec53c3a9 12 TS_DISCO_F469NI ts;
gabrieltetar 21:d137ec53c3a9 13 LCD_DISCO_F469NI lcd;
gabrieltetar 21:d137ec53c3a9 14
gabrieltetar 21:d137ec53c3a9 15
gabrieltetar 21:d137ec53c3a9 16 TS_StateTypeDef TS_State;
gabrieltetar 21:d137ec53c3a9 17
gabrieltetar 21:d137ec53c3a9 18
gabrieltetar 21:d137ec53c3a9 19 /////////////////DEFINITION DES BOUTONS////////////////////
gabrieltetar 21:d137ec53c3a9 20 Button COTE_JAUNE(0, 25, 400, 300, "JAUNE");
gabrieltetar 21:d137ec53c3a9 21 Button COTE_VIOLET(0, 350, 400, 300, "VIOLET");
gabrieltetar 21:d137ec53c3a9 22 Button RETOUR (0, 680, 400, 110, "--Precedent--");
gabrieltetar 21:d137ec53c3a9 23 Button LANCER (0, 200, 400, 200, "--LANCER--");
gabrieltetar 21:d137ec53c3a9 24 Button CHECK (0, 420, 400, 200, "Valider");
gabrieltetar 21:d137ec53c3a9 25 Button MATCH (0, 50, 400, 320, "Match");
gabrieltetar 21:d137ec53c3a9 26 Button DEMONSTRATION (0, 400, 400, 320, "Demo");
gabrieltetar 21:d137ec53c3a9 27 //menu demo
gabrieltetar 21:d137ec53c3a9 28 Button TEST_VENT(0, 25, 400, 100, "Test ventouses");
gabrieltetar 21:d137ec53c3a9 29 Button TEST_MOT(0, 135, 400, 100, "Test moteur");
gabrieltetar 21:d137ec53c3a9 30 Button TEST_COUL(0,245,400,100,"Test capteurs couleur");
gabrieltetar 21:d137ec53c3a9 31 Button TEST_BRAS(0,355,400,100,"Test Bras");
gabrieltetar 21:d137ec53c3a9 32 Button TEST_AUDIO(0,465,400,100,"Test Audio");
gabrieltetar 21:d137ec53c3a9 33 Button TEST_ELECTRV(0,575,400,100,"Test Divers");
gabrieltetar 21:d137ec53c3a9 34 //menu demo/demo/
gabrieltetar 21:d137ec53c3a9 35 Button TEST_A(0,25,195,100,"A");
gabrieltetar 21:d137ec53c3a9 36 Button TEST_B(205,25,195,100,"B");
gabrieltetar 21:d137ec53c3a9 37 Button TEST_C(0,135,195,100,"C");
gabrieltetar 21:d137ec53c3a9 38 Button TEST_D(205,135,195,100,"D");
gabrieltetar 21:d137ec53c3a9 39 Button TEST_NUM(0,245,400,100,"Bras num");
gabrieltetar 21:d137ec53c3a9 40 Button TEST_PLUS(205,355,195,100,"+");
gabrieltetar 21:d137ec53c3a9 41 Button TEST_MOINS(0,355,195,100,"-");
gabrieltetar 21:d137ec53c3a9 42
gabrieltetar 21:d137ec53c3a9 43
gabrieltetar 21:d137ec53c3a9 44 Button FORCE_LAUNCH(0, 50, 400, 320, "Force Launch");
gabrieltetar 21:d137ec53c3a9 45 Button SUIVANT(0,380,200,100,"Suivant");
gabrieltetar 21:d137ec53c3a9 46 ////////////////////////////////////////////////////////////
gabrieltetar 21:d137ec53c3a9 47
gabrieltetar 21:d137ec53c3a9 48 signed char Bouton_Strat (void);
gabrieltetar 21:d137ec53c3a9 49
gabrieltetar 21:d137ec53c3a9 50 void SelectionStrat (unsigned char numeroStrat);
gabrieltetar 21:d137ec53c3a9 51
gabrieltetar 21:d137ec53c3a9 52 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 53 /* FUNCTION NAME: automate_etat_ihm */
gabrieltetar 21:d137ec53c3a9 54 /* DESCRIPTION : Automate de gestion de l'affichage */
gabrieltetar 21:d137ec53c3a9 55 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 56 void automate_etat_ihm(void)
gabrieltetar 21:d137ec53c3a9 57 {
gabrieltetar 21:d137ec53c3a9 58 char toto[2];
gabrieltetar 21:d137ec53c3a9 59 int j;
gabrieltetar 21:d137ec53c3a9 60 unsigned char maximilien=1;
gabrieltetar 21:d137ec53c3a9 61 if (j==0) {
gabrieltetar 21:d137ec53c3a9 62 ts.Init(lcd.GetXSize(), lcd.GetYSize());
gabrieltetar 21:d137ec53c3a9 63 j++;
gabrieltetar 21:d137ec53c3a9 64 }
gabrieltetar 21:d137ec53c3a9 65 ts.GetState(&TS_State);
gabrieltetar 21:d137ec53c3a9 66 switch (strat_etat_s) {
gabrieltetar 21:d137ec53c3a9 67 case INIT : //intialise l'écran et passe à l'attente d'initialisation des cartes
gabrieltetar 21:d137ec53c3a9 68 ts.GetState(&TS_State);
gabrieltetar 21:d137ec53c3a9 69 canProcessRx();
gabrieltetar 21:d137ec53c3a9 70 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 71 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 72 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 73 wait(0.15);
gabrieltetar 21:d137ec53c3a9 74 lcd.DisplayStringAt(0, 10, (uint8_t *)"Verification des cartes", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 75 //cartes non verifiées////////////////
gabrieltetar 21:d137ec53c3a9 76 lcd.SetTextColor(DIY_GREY);
gabrieltetar 21:d137ec53c3a9 77 lcd.FillRect(0,400,400,150); //carte moteur
gabrieltetar 21:d137ec53c3a9 78 lcd.FillRect(0,600,400,150); //Balise
gabrieltetar 21:d137ec53c3a9 79 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 80 lcd.SetBackColor(DIY_GREY);
gabrieltetar 21:d137ec53c3a9 81 lcd.DisplayStringAt(80, 450, (uint8_t *)"Carte Moteur", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 82 lcd.DisplayStringAt(110,650, (uint8_t *)"Balise", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 83 ////////////////////////////////////////
gabrieltetar 21:d137ec53c3a9 84 FORCE_LAUNCH.Draw(0xFFFF0000, 0);
gabrieltetar 21:d137ec53c3a9 85
gabrieltetar 21:d137ec53c3a9 86 strat_etat_s=ATT;
gabrieltetar 21:d137ec53c3a9 87 break;
gabrieltetar 21:d137ec53c3a9 88
gabrieltetar 21:d137ec53c3a9 89 case ATT : //Si les cartes sont présentes passe directement à choix sinon attente de force Launch (cette partie est encore buggée mais les cartes affichent bien leur présence donc faut juste force launch tout le temps...)
gabrieltetar 21:d137ec53c3a9 90 if (flag_check_carte==1) {
gabrieltetar 21:d137ec53c3a9 91 strat_etat_s = CHOIX;
gabrieltetar 21:d137ec53c3a9 92 gameEtat = ETAT_CONFIG;
gabrieltetar 21:d137ec53c3a9 93 } else if (FORCE_LAUNCH.Touched()) {
gabrieltetar 21:d137ec53c3a9 94 strat_etat_s = CHOIX;
gabrieltetar 21:d137ec53c3a9 95 gameEtat = ETAT_CONFIG;
gabrieltetar 21:d137ec53c3a9 96 while(FORCE_LAUNCH.Touched());
gabrieltetar 21:d137ec53c3a9 97 }
gabrieltetar 21:d137ec53c3a9 98
gabrieltetar 21:d137ec53c3a9 99 break;
gabrieltetar 21:d137ec53c3a9 100
gabrieltetar 21:d137ec53c3a9 101
gabrieltetar 21:d137ec53c3a9 102 case CHOIX : //Match ou DEMO
gabrieltetar 21:d137ec53c3a9 103 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 104 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 105 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 106 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 107 DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
gabrieltetar 21:d137ec53c3a9 108 MATCH.Draw(0xFFF01010, 0);
gabrieltetar 21:d137ec53c3a9 109 while(strat_etat_s == CHOIX) {
gabrieltetar 21:d137ec53c3a9 110 canProcessRx();
gabrieltetar 21:d137ec53c3a9 111 if(DEMONSTRATION.Touched()) {
gabrieltetar 21:d137ec53c3a9 112 strat_etat_s = DEMO;
gabrieltetar 21:d137ec53c3a9 113 while(DEMONSTRATION.Touched());
gabrieltetar 21:d137ec53c3a9 114 }
gabrieltetar 21:d137ec53c3a9 115
gabrieltetar 21:d137ec53c3a9 116 if(MATCH.Touched()) {
gabrieltetar 21:d137ec53c3a9 117 strat_etat_s = SELECT_SIDE;
gabrieltetar 21:d137ec53c3a9 118 while(MATCH.Touched());
gabrieltetar 21:d137ec53c3a9 119 }
gabrieltetar 21:d137ec53c3a9 120
gabrieltetar 21:d137ec53c3a9 121 }
gabrieltetar 21:d137ec53c3a9 122 break;
gabrieltetar 21:d137ec53c3a9 123
gabrieltetar 21:d137ec53c3a9 124 case DEMO :
gabrieltetar 21:d137ec53c3a9 125 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 126 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 127 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 128 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"DEMO", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 129 RETOUR.Draw(0xFFFF0000, 0);
gabrieltetar 21:d137ec53c3a9 130 TEST_VENT.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 131 TEST_MOT.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 132 TEST_COUL.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 133 TEST_BRAS.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 134 TEST_AUDIO.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 135 TEST_ELECTRV.Draw(VERT, 0);
gabrieltetar 21:d137ec53c3a9 136 maximilien=0;
gabrieltetar 21:d137ec53c3a9 137 while (strat_etat_s == DEMO) {
gabrieltetar 21:d137ec53c3a9 138 canProcessRx();
gabrieltetar 21:d137ec53c3a9 139 if(TEST_VENT.Touched()) {
gabrieltetar 21:d137ec53c3a9 140 while(TEST_VENT.Touched());
gabrieltetar 21:d137ec53c3a9 141 strat_etat_s = TEST_VENTOUSE;
gabrieltetar 21:d137ec53c3a9 142 } else if(TEST_MOT.Touched()) {
gabrieltetar 21:d137ec53c3a9 143 while(TEST_MOT.Touched());
gabrieltetar 21:d137ec53c3a9 144 strat_etat_s = TEST_MOTEUR;
gabrieltetar 21:d137ec53c3a9 145 } else if(TEST_ELECTRV.Touched()) {
gabrieltetar 21:d137ec53c3a9 146 while(TEST_ELECTRV.Touched());
gabrieltetar 21:d137ec53c3a9 147 strat_etat_s = TEST_ELECTROV;
gabrieltetar 21:d137ec53c3a9 148 } else if (TEST_COUL.Touched()) {
gabrieltetar 21:d137ec53c3a9 149 while(TEST_COUL.Touched());
gabrieltetar 21:d137ec53c3a9 150 strat_etat_s =TEST_COULEUR ;
gabrieltetar 21:d137ec53c3a9 151 } else if (TEST_BRAS.Touched()) {
gabrieltetar 21:d137ec53c3a9 152 while(TEST_BRAS.Touched());
gabrieltetar 21:d137ec53c3a9 153 strat_etat_s =TEST_SERVO_BRAS ;
gabrieltetar 21:d137ec53c3a9 154 } else if(TEST_AUDIO.Touched()) {
gabrieltetar 21:d137ec53c3a9 155 while(TEST_AUDIO.Touched());
gabrieltetar 21:d137ec53c3a9 156 strat_etat_s=TEST_AUD;
gabrieltetar 21:d137ec53c3a9 157 } else if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 158 while(RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 159 strat_etat_s = CHOIX;
gabrieltetar 21:d137ec53c3a9 160 }
gabrieltetar 21:d137ec53c3a9 161 }
gabrieltetar 21:d137ec53c3a9 162 break;
gabrieltetar 21:d137ec53c3a9 163
gabrieltetar 21:d137ec53c3a9 164
gabrieltetar 21:d137ec53c3a9 165 case TEST_VENTOUSE:
gabrieltetar 21:d137ec53c3a9 166 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 167 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 168 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 169 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 170 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Ventouse", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 171 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 172 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 173 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 174 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 175 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 176 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 177 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 178 while(strat_etat_s==TEST_VENTOUSE) {
gabrieltetar 21:d137ec53c3a9 179 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 180 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 181 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 182 } else if(TEST_A.Touched()) {
gabrieltetar 21:d137ec53c3a9 183 while (TEST_A.Touched());
gabrieltetar 21:d137ec53c3a9 184 //SendRawId(TEST_VENT_A);
gabrieltetar 21:d137ec53c3a9 185 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 186 } else if(TEST_NUM.Touched()) {
gabrieltetar 21:d137ec53c3a9 187 while (TEST_NUM.Touched());
gabrieltetar 21:d137ec53c3a9 188 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 189 switch(maximilien){
gabrieltetar 21:d137ec53c3a9 190 case 1:
gabrieltetar 21:d137ec53c3a9 191 SendRawId(TEST_VENT_1_ON);
gabrieltetar 21:d137ec53c3a9 192 break;
gabrieltetar 21:d137ec53c3a9 193 case 2:
gabrieltetar 21:d137ec53c3a9 194 SendRawId(TEST_VENT_1_OFF);
gabrieltetar 21:d137ec53c3a9 195 break;
gabrieltetar 21:d137ec53c3a9 196 case 3:
gabrieltetar 21:d137ec53c3a9 197 //SendRawId(TEST_VENT_3);
gabrieltetar 21:d137ec53c3a9 198 break;
gabrieltetar 21:d137ec53c3a9 199 case 4:
gabrieltetar 21:d137ec53c3a9 200 //SendRawId(TEST_VENT_4);
gabrieltetar 21:d137ec53c3a9 201 break;
gabrieltetar 21:d137ec53c3a9 202 case 5:
gabrieltetar 21:d137ec53c3a9 203 //SendRawId(TEST_VENT_5);
gabrieltetar 21:d137ec53c3a9 204 break;
gabrieltetar 21:d137ec53c3a9 205 case 6:
gabrieltetar 21:d137ec53c3a9 206 //SendRawId(TEST_VENT_6);
gabrieltetar 21:d137ec53c3a9 207 break;
gabrieltetar 21:d137ec53c3a9 208 }
gabrieltetar 21:d137ec53c3a9 209 } else if(TEST_PLUS.Touched()) {
gabrieltetar 21:d137ec53c3a9 210 while (TEST_PLUS.Touched());
gabrieltetar 21:d137ec53c3a9 211 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 212 if(maximilien!=6)maximilien++;
gabrieltetar 21:d137ec53c3a9 213 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 214 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 215 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 216 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 217 } else if(TEST_MOINS.Touched()) {
gabrieltetar 21:d137ec53c3a9 218 while (TEST_MOINS.Touched());
gabrieltetar 21:d137ec53c3a9 219 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 220 if(maximilien!=1)maximilien--;
gabrieltetar 21:d137ec53c3a9 221 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 222 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 223 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 224 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 225 }
gabrieltetar 21:d137ec53c3a9 226 }
gabrieltetar 21:d137ec53c3a9 227 break;
gabrieltetar 21:d137ec53c3a9 228
gabrieltetar 21:d137ec53c3a9 229 case TEST_ELECTROV:
gabrieltetar 21:d137ec53c3a9 230 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 231 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 232 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 233 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 234 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"A : Manches B : Pavillon", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 235 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 236 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 237 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 238 while(strat_etat_s==TEST_ELECTROV) {
gabrieltetar 21:d137ec53c3a9 239 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 240 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 241 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 242 } else if(TEST_A.Touched()) {
gabrieltetar 21:d137ec53c3a9 243 while (TEST_A.Touched());
gabrieltetar 21:d137ec53c3a9 244 //SendRawId(TEST_ELECTROV_A);
gabrieltetar 21:d137ec53c3a9 245 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 246 } else if(TEST_B.Touched()) {
gabrieltetar 21:d137ec53c3a9 247 while (TEST_B.Touched());
gabrieltetar 21:d137ec53c3a9 248 //SendRawId(TEST_ELECTROV_A);
gabrieltetar 21:d137ec53c3a9 249 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 250 }
gabrieltetar 21:d137ec53c3a9 251 }
gabrieltetar 21:d137ec53c3a9 252 break;
gabrieltetar 21:d137ec53c3a9 253
gabrieltetar 21:d137ec53c3a9 254 case TEST_AUD:
gabrieltetar 21:d137ec53c3a9 255
gabrieltetar 21:d137ec53c3a9 256 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 257 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 258 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 259 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 260 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Audio", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 261 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 262 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 263 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 264 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 265 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 266 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 267 while(strat_etat_s==TEST_AUD) {
gabrieltetar 21:d137ec53c3a9 268 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 269 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 270 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 271 } else if(TEST_NUM.Touched()) {
gabrieltetar 21:d137ec53c3a9 272 while (TEST_NUM.Touched());
gabrieltetar 21:d137ec53c3a9 273 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 274 Debug_Audio(3,maximilien);
gabrieltetar 21:d137ec53c3a9 275 } else if(TEST_PLUS.Touched()) {
gabrieltetar 21:d137ec53c3a9 276 while (TEST_PLUS.Touched());
gabrieltetar 21:d137ec53c3a9 277 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 278 if(maximilien!=20)maximilien++;
gabrieltetar 21:d137ec53c3a9 279 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 280 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 281 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 282 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 283 } else if(TEST_MOINS.Touched()) {
gabrieltetar 21:d137ec53c3a9 284 while (TEST_MOINS.Touched());
gabrieltetar 21:d137ec53c3a9 285 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 286 if(maximilien!=1)maximilien--;
gabrieltetar 21:d137ec53c3a9 287 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 288 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 289 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 290 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 291 }
gabrieltetar 21:d137ec53c3a9 292 }
gabrieltetar 21:d137ec53c3a9 293 break;
gabrieltetar 21:d137ec53c3a9 294
gabrieltetar 21:d137ec53c3a9 295 case TEST_SERVO_BRAS:
gabrieltetar 21:d137ec53c3a9 296
gabrieltetar 21:d137ec53c3a9 297 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 298 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 299 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 300 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 301 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Bras", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 302 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 303 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 304 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 305 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 306 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 307 TEST_C.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 308 TEST_D.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 309 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 310 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 311 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 312 while(strat_etat_s==TEST_SERVO_BRAS) {
gabrieltetar 21:d137ec53c3a9 313 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 314 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 315 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 316 } else if(TEST_A.Touched()) {
gabrieltetar 21:d137ec53c3a9 317 while (TEST_A.Touched());
gabrieltetar 21:d137ec53c3a9 318 SendRawId(TEST_BRAS_A);
gabrieltetar 21:d137ec53c3a9 319 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 320 } else if(TEST_B.Touched()) {
gabrieltetar 21:d137ec53c3a9 321 while (TEST_B.Touched());
gabrieltetar 21:d137ec53c3a9 322 SendRawId(TEST_BRAS_B);
gabrieltetar 21:d137ec53c3a9 323 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 324 } else if(TEST_C.Touched()) {
gabrieltetar 21:d137ec53c3a9 325 while (TEST_C.Touched());
gabrieltetar 21:d137ec53c3a9 326 SendRawId(TEST_BRAS_C);
gabrieltetar 21:d137ec53c3a9 327 TEST_C.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 328 } else if(TEST_D.Touched()) {
gabrieltetar 21:d137ec53c3a9 329 while (TEST_D.Touched());
gabrieltetar 21:d137ec53c3a9 330 SendRawId(TEST_BRAS_D);
gabrieltetar 21:d137ec53c3a9 331 TEST_D.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 332 } else if(TEST_NUM.Touched()) {
gabrieltetar 21:d137ec53c3a9 333 while (TEST_NUM.Touched());
gabrieltetar 21:d137ec53c3a9 334 TEST_NUM.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 335 switch(maximilien){
gabrieltetar 21:d137ec53c3a9 336 case 1:
gabrieltetar 21:d137ec53c3a9 337 SendRawId(TEST_BRAS_1);
gabrieltetar 21:d137ec53c3a9 338 break;
gabrieltetar 21:d137ec53c3a9 339 case 2:
gabrieltetar 21:d137ec53c3a9 340 SendRawId(TEST_BRAS_2);
gabrieltetar 21:d137ec53c3a9 341 break;
gabrieltetar 21:d137ec53c3a9 342 case 3:
gabrieltetar 21:d137ec53c3a9 343 SendRawId(TEST_BRAS_3);
gabrieltetar 21:d137ec53c3a9 344 break;
gabrieltetar 21:d137ec53c3a9 345 case 4:
gabrieltetar 21:d137ec53c3a9 346 SendRawId(TEST_BRAS_4);
gabrieltetar 21:d137ec53c3a9 347 break;
gabrieltetar 21:d137ec53c3a9 348 case 5:
gabrieltetar 21:d137ec53c3a9 349 SendRawId(TEST_BRAS_5);
gabrieltetar 21:d137ec53c3a9 350 break;
gabrieltetar 21:d137ec53c3a9 351 case 6:
gabrieltetar 21:d137ec53c3a9 352 SendRawId(TEST_BRAS_6);
gabrieltetar 21:d137ec53c3a9 353 break;
gabrieltetar 21:d137ec53c3a9 354 }
gabrieltetar 21:d137ec53c3a9 355 } else if(TEST_PLUS.Touched()) {
gabrieltetar 21:d137ec53c3a9 356 while (TEST_PLUS.Touched());
gabrieltetar 21:d137ec53c3a9 357 TEST_PLUS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 358 if(maximilien!=6)maximilien++;
gabrieltetar 21:d137ec53c3a9 359 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 360 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 361 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 362 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 363 } else if(TEST_MOINS.Touched()) {
gabrieltetar 21:d137ec53c3a9 364 while (TEST_MOINS.Touched());
gabrieltetar 21:d137ec53c3a9 365 TEST_MOINS.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 366 if(maximilien!=1)maximilien--;
gabrieltetar 21:d137ec53c3a9 367 sprintf(toto,"%hd",maximilien);
gabrieltetar 21:d137ec53c3a9 368 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 369 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 370 lcd.DisplayStringAt(50, LINE(20), (unsigned char *)toto, LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 371 }
gabrieltetar 21:d137ec53c3a9 372 }
gabrieltetar 21:d137ec53c3a9 373 break;
gabrieltetar 21:d137ec53c3a9 374
gabrieltetar 21:d137ec53c3a9 375 case TEST_COULEUR:
gabrieltetar 21:d137ec53c3a9 376 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 377 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Couleur", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 378 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 379 while(strat_etat_s==TEST_COULEUR) {
gabrieltetar 21:d137ec53c3a9 380 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 381 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 382 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 383 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 384 }
gabrieltetar 21:d137ec53c3a9 385 }
gabrieltetar 21:d137ec53c3a9 386 break;
gabrieltetar 21:d137ec53c3a9 387
gabrieltetar 21:d137ec53c3a9 388 case TEST_MOTEUR:
gabrieltetar 21:d137ec53c3a9 389 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 390 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 391 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 392 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 393 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Test Moteur", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 394 RETOUR.Draw(0xFFFF0000,0);
gabrieltetar 21:d137ec53c3a9 395 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 396 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 397 while(strat_etat_s==TEST_MOTEUR) {
gabrieltetar 21:d137ec53c3a9 398 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 399 while (RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 400 strat_etat_s=DEMO;
gabrieltetar 21:d137ec53c3a9 401 } else if(TEST_A.Touched()) {
gabrieltetar 21:d137ec53c3a9 402 while (TEST_A.Touched());
gabrieltetar 21:d137ec53c3a9 403 BendRadius(150,1800,1,0);
gabrieltetar 21:d137ec53c3a9 404 TEST_A.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 405 } else if(TEST_B.Touched()) {
gabrieltetar 21:d137ec53c3a9 406 while (TEST_B.Touched());
gabrieltetar 21:d137ec53c3a9 407 BendRadius(150,1800,0,0);
gabrieltetar 21:d137ec53c3a9 408 TEST_B.Draw(BLEU, BLANC);
gabrieltetar 21:d137ec53c3a9 409 }
gabrieltetar 21:d137ec53c3a9 410 }
gabrieltetar 21:d137ec53c3a9 411 break; ///////////////////////////////////////////FIN DES DEMOS/////////////////////////////////////////////////
gabrieltetar 21:d137ec53c3a9 412
gabrieltetar 21:d137ec53c3a9 413
gabrieltetar 21:d137ec53c3a9 414 case SELECT_SIDE : // CHOIX DU COTE DU TERRAIN + INVERSION DE LA STRAT SI COTE ORANGE+ ENVOI DU COTE A LA CARTE CAPTEUR/ACTIONNEURS
gabrieltetar 21:d137ec53c3a9 415 lcd.Clear(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 416 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 417 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 418
gabrieltetar 21:d137ec53c3a9 419 lcd.DisplayStringAt(70, LINE(0), (uint8_t *)"Choisir le cote", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 420 COTE_JAUNE.Draw(JAUNE, 0);
gabrieltetar 21:d137ec53c3a9 421 COTE_VIOLET.Draw(VIOLET, 0);
gabrieltetar 21:d137ec53c3a9 422 RETOUR.Draw(LCD_COLOR_RED, 0);
gabrieltetar 21:d137ec53c3a9 423
gabrieltetar 21:d137ec53c3a9 424
gabrieltetar 21:d137ec53c3a9 425 while (strat_etat_s == SELECT_SIDE) {
gabrieltetar 21:d137ec53c3a9 426 canProcessRx();
gabrieltetar 21:d137ec53c3a9 427 if(COTE_JAUNE.Touched()) {
gabrieltetar 21:d137ec53c3a9 428 Cote = 0x0;
gabrieltetar 21:d137ec53c3a9 429 InversStrat = Cote;
gabrieltetar 21:d137ec53c3a9 430 strat_etat_s = TACTIQUE;
gabrieltetar 21:d137ec53c3a9 431 CANMessage trame_Tx = CANMessage();
gabrieltetar 21:d137ec53c3a9 432 trame_Tx.len = 1;
gabrieltetar 21:d137ec53c3a9 433 trame_Tx.format = CANStandard;
gabrieltetar 21:d137ec53c3a9 434 trame_Tx.type = CANData;
gabrieltetar 21:d137ec53c3a9 435 trame_Tx.id=CHOICE_COLOR;
gabrieltetar 21:d137ec53c3a9 436 trame_Tx.data[0]=Cote;
gabrieltetar 21:d137ec53c3a9 437 can2.write(trame_Tx);
gabrieltetar 21:d137ec53c3a9 438 while(COTE_JAUNE.Touched());
gabrieltetar 21:d137ec53c3a9 439
gabrieltetar 21:d137ec53c3a9 440 }
gabrieltetar 21:d137ec53c3a9 441
gabrieltetar 21:d137ec53c3a9 442 if(COTE_VIOLET.Touched()) {
gabrieltetar 21:d137ec53c3a9 443 Cote = 0x1;
gabrieltetar 21:d137ec53c3a9 444 InversStrat= Cote;
gabrieltetar 21:d137ec53c3a9 445 strat_etat_s = TACTIQUE;
gabrieltetar 21:d137ec53c3a9 446 CANMessage trame_Tx = CANMessage();
gabrieltetar 21:d137ec53c3a9 447 trame_Tx.len = 1;
gabrieltetar 21:d137ec53c3a9 448 trame_Tx.format = CANStandard;
gabrieltetar 21:d137ec53c3a9 449 trame_Tx.type = CANData;
gabrieltetar 21:d137ec53c3a9 450 trame_Tx.id=CHOICE_COLOR;
gabrieltetar 21:d137ec53c3a9 451 trame_Tx.data[0]=Cote;
gabrieltetar 21:d137ec53c3a9 452 can2.write(trame_Tx);
gabrieltetar 21:d137ec53c3a9 453 while(COTE_VIOLET.Touched());
gabrieltetar 21:d137ec53c3a9 454 }
gabrieltetar 21:d137ec53c3a9 455
gabrieltetar 21:d137ec53c3a9 456 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 457 strat_etat_s = CHOIX;
gabrieltetar 21:d137ec53c3a9 458 while(RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 459 }
gabrieltetar 21:d137ec53c3a9 460 }
gabrieltetar 21:d137ec53c3a9 461
gabrieltetar 21:d137ec53c3a9 462 break;
gabrieltetar 21:d137ec53c3a9 463
gabrieltetar 21:d137ec53c3a9 464 case TACTIQUE : //AFFICHE LA LISTE DES STRATS AFIN DE SELECTIONNER CELLE VOULUE
gabrieltetar 21:d137ec53c3a9 465 if (Cote == 0) {
gabrieltetar 21:d137ec53c3a9 466 lcd.Clear(JAUNE);
gabrieltetar 21:d137ec53c3a9 467 lcd.SetBackColor(JAUNE);
gabrieltetar 21:d137ec53c3a9 468 } else if (Cote == 1) {
gabrieltetar 21:d137ec53c3a9 469 lcd.Clear(VIOLET);
gabrieltetar 21:d137ec53c3a9 470 lcd.SetBackColor(VIOLET);
gabrieltetar 21:d137ec53c3a9 471 } else {
gabrieltetar 21:d137ec53c3a9 472 lcd.Clear(BLEU);
gabrieltetar 21:d137ec53c3a9 473 lcd.SetBackColor(BLEU);
gabrieltetar 21:d137ec53c3a9 474 }
gabrieltetar 21:d137ec53c3a9 475
gabrieltetar 21:d137ec53c3a9 476 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 477
gabrieltetar 21:d137ec53c3a9 478 lcd.DisplayStringAt(20, LINE(0), (uint8_t *)"Choisir une strategie", LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 479
gabrieltetar 21:d137ec53c3a9 480 nbStrat = Bouton_Strat(); // retourne valeur de Strategie si bouton strat renvoi -1 on reviens en arriere
gabrieltetar 21:d137ec53c3a9 481 if (nbStrat == -1) {
gabrieltetar 21:d137ec53c3a9 482 strat_etat_s = SELECT_SIDE;
gabrieltetar 21:d137ec53c3a9 483 } else {
gabrieltetar 21:d137ec53c3a9 484 strat_etat_s = DETAILS;
gabrieltetar 21:d137ec53c3a9 485 }
gabrieltetar 21:d137ec53c3a9 486 wait(0.1);
gabrieltetar 21:d137ec53c3a9 487 break;
gabrieltetar 21:d137ec53c3a9 488
gabrieltetar 21:d137ec53c3a9 489 case DETAILS : //SECONDE VALIDATION DE LA STRAT
gabrieltetar 21:d137ec53c3a9 490 lcd.Clear(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 491 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 492 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 493 CHECK.Draw(VERT);
gabrieltetar 21:d137ec53c3a9 494 RETOUR.Draw(LCD_COLOR_RED);
gabrieltetar 21:d137ec53c3a9 495
gabrieltetar 21:d137ec53c3a9 496 SelectionStrat(nbStrat); //affiche la stratégie selectionnée
gabrieltetar 21:d137ec53c3a9 497
gabrieltetar 21:d137ec53c3a9 498 while (strat_etat_s == DETAILS) {
gabrieltetar 21:d137ec53c3a9 499 canProcessRx();
gabrieltetar 21:d137ec53c3a9 500 if (CHECK.Touched()) {
gabrieltetar 21:d137ec53c3a9 501 if(gameEtat == ETAT_CONFIG) {
gabrieltetar 21:d137ec53c3a9 502 gameEtat = ETAT_GAME_INIT;
gabrieltetar 21:d137ec53c3a9 503 strat_etat_s=LECTURE;
gabrieltetar 21:d137ec53c3a9 504
gabrieltetar 21:d137ec53c3a9 505 }
gabrieltetar 21:d137ec53c3a9 506 while(CHECK.Touched());
gabrieltetar 21:d137ec53c3a9 507 }
gabrieltetar 21:d137ec53c3a9 508
gabrieltetar 21:d137ec53c3a9 509 if(RETOUR.Touched()) {
gabrieltetar 21:d137ec53c3a9 510 strat_etat_s = TACTIQUE;
gabrieltetar 21:d137ec53c3a9 511 while(RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 512 }
gabrieltetar 21:d137ec53c3a9 513 }
gabrieltetar 21:d137ec53c3a9 514 break;
gabrieltetar 21:d137ec53c3a9 515
gabrieltetar 21:d137ec53c3a9 516
gabrieltetar 21:d137ec53c3a9 517 case LECTURE :
gabrieltetar 21:d137ec53c3a9 518 break;
gabrieltetar 21:d137ec53c3a9 519 case AFF_WAIT_JACK : //FONCTIONS D'AFFICHAGE DE L'ATTENTE DU JACK
gabrieltetar 21:d137ec53c3a9 520 lcd.Clear(BLANC);
gabrieltetar 21:d137ec53c3a9 521 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 522 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 523
gabrieltetar 21:d137ec53c3a9 524 if (Cote == 0) {
gabrieltetar 21:d137ec53c3a9 525 lcd.Clear(VERT);
gabrieltetar 21:d137ec53c3a9 526 lcd.SetBackColor(VERT);
gabrieltetar 21:d137ec53c3a9 527 } else if (Cote == 1) {
gabrieltetar 21:d137ec53c3a9 528 lcd.Clear(ORANGE);
gabrieltetar 21:d137ec53c3a9 529 lcd.SetBackColor(ORANGE);
gabrieltetar 21:d137ec53c3a9 530 } else {
gabrieltetar 21:d137ec53c3a9 531 lcd.Clear(VERT);
gabrieltetar 21:d137ec53c3a9 532 lcd.SetBackColor(VERT);
gabrieltetar 21:d137ec53c3a9 533 }
gabrieltetar 21:d137ec53c3a9 534 canProcessRx();
gabrieltetar 21:d137ec53c3a9 535 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"En attente du Jack", CENTER_MODE);
gabrieltetar 21:d137ec53c3a9 536 strat_etat_s=WAIT_JACK;
gabrieltetar 21:d137ec53c3a9 537 break;
gabrieltetar 21:d137ec53c3a9 538
gabrieltetar 21:d137ec53c3a9 539 case WAIT_JACK: //VERITABLE ATTENTE DU JACK
gabrieltetar 21:d137ec53c3a9 540 break;
gabrieltetar 21:d137ec53c3a9 541
gabrieltetar 21:d137ec53c3a9 542 case FIN : //AFFICHAGE DE FIN AVEC LE SCORE FINAL
gabrieltetar 21:d137ec53c3a9 543 lcd.Clear (LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 544 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 545
gabrieltetar 21:d137ec53c3a9 546
gabrieltetar 21:d137ec53c3a9 547 while(1); // force le redemarage du robot
gabrieltetar 21:d137ec53c3a9 548 //break;
gabrieltetar 21:d137ec53c3a9 549
gabrieltetar 21:d137ec53c3a9 550 }
gabrieltetar 21:d137ec53c3a9 551 }
gabrieltetar 21:d137ec53c3a9 552 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 553 /* FUNCTION NAME: Bouton_Strat */
gabrieltetar 21:d137ec53c3a9 554 /* DESCRIPTION : Sélection de la strat sur le lcd puis envoie sur CAN (à modifier!) */
gabrieltetar 21:d137ec53c3a9 555 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 556 signed char Bouton_Strat (void)
gabrieltetar 21:d137ec53c3a9 557 {
gabrieltetar 21:d137ec53c3a9 558 char Ack_strat = 0;
gabrieltetar 21:d137ec53c3a9 559 signed char Strat = 0;
gabrieltetar 21:d137ec53c3a9 560 Button STRAT_1 (0, 30, 190, 110, strat_sd[0]);
gabrieltetar 21:d137ec53c3a9 561 Button STRAT_2 (210, 30, 190, 110, strat_sd[1]);
gabrieltetar 21:d137ec53c3a9 562 Button STRAT_3 (0, 150, 190, 110, strat_sd[2]);
gabrieltetar 21:d137ec53c3a9 563 Button STRAT_4 (210, 150, 190, 110, strat_sd[3]);
gabrieltetar 21:d137ec53c3a9 564 Button STRAT_5 (0, 270, 190, 110,strat_sd[4]);
gabrieltetar 21:d137ec53c3a9 565 Button STRAT_6 (210, 270, 190, 110, strat_sd[5]);
gabrieltetar 21:d137ec53c3a9 566 Button STRAT_7 (0, 390, 190, 110, strat_sd[6]);
gabrieltetar 21:d137ec53c3a9 567 Button STRAT_8 (210, 390, 190, 110, strat_sd[7]);
gabrieltetar 21:d137ec53c3a9 568 Button STRAT_9 (0, 510, 190, 110, strat_sd[8]);
gabrieltetar 21:d137ec53c3a9 569 Button STRAT_10 (210, 510, 190, 110, strat_sd[9]);
gabrieltetar 21:d137ec53c3a9 570 Button RETOUR (0, 680, 400, 110, "--Precedent--");
gabrieltetar 21:d137ec53c3a9 571 //Definition des boutons
gabrieltetar 21:d137ec53c3a9 572
gabrieltetar 21:d137ec53c3a9 573 Ack_strat = 0;
gabrieltetar 21:d137ec53c3a9 574 Strat = 0;
gabrieltetar 21:d137ec53c3a9 575 STRAT_1.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 576 STRAT_2.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 577 STRAT_3.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 578 STRAT_4.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 579 STRAT_5.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 580 STRAT_6.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 581 STRAT_7.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 582 STRAT_8.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 583 STRAT_9.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 584 STRAT_10.Draw(0xFFF0F0F0, 0);
gabrieltetar 21:d137ec53c3a9 585 RETOUR.Draw(0xFFFF0000, 0);
gabrieltetar 21:d137ec53c3a9 586
gabrieltetar 21:d137ec53c3a9 587 while(Ack_strat == 0) {
gabrieltetar 21:d137ec53c3a9 588 canProcessRx();
gabrieltetar 21:d137ec53c3a9 589 CANMessage msgTx=CANMessage();
gabrieltetar 21:d137ec53c3a9 590 //msgTx.id=ECRAN_CHOICE_STRAT;
gabrieltetar 21:d137ec53c3a9 591 if (RETOUR.Touched())
gabrieltetar 21:d137ec53c3a9 592 return -1;
gabrieltetar 21:d137ec53c3a9 593 while(RETOUR.Touched());
gabrieltetar 21:d137ec53c3a9 594 //////////////////////////////STRATEGIE N°1
gabrieltetar 21:d137ec53c3a9 595 if (STRAT_1.Touched()) {
gabrieltetar 21:d137ec53c3a9 596 Strat = 0;
gabrieltetar 21:d137ec53c3a9 597 //msgTx.data[0] = 0x1;
gabrieltetar 21:d137ec53c3a9 598 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 599 while(STRAT_1.Touched());
gabrieltetar 21:d137ec53c3a9 600 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 601 }
gabrieltetar 21:d137ec53c3a9 602 /////////////////////////////STRATEGIE N°2
gabrieltetar 21:d137ec53c3a9 603 if (STRAT_2.Touched()) {
gabrieltetar 21:d137ec53c3a9 604 Strat = 1;
gabrieltetar 21:d137ec53c3a9 605 //msgTx.data[0] = 0x2;
gabrieltetar 21:d137ec53c3a9 606 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 607 while(STRAT_2.Touched());
gabrieltetar 21:d137ec53c3a9 608 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 609 }
gabrieltetar 21:d137ec53c3a9 610 //////////////////////////////STRATEGIE N°3
gabrieltetar 21:d137ec53c3a9 611 if (STRAT_3.Touched()) {
gabrieltetar 21:d137ec53c3a9 612 Strat = 2;
gabrieltetar 21:d137ec53c3a9 613 //msgTx.data[0] = 0x3;
gabrieltetar 21:d137ec53c3a9 614 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 615 while(STRAT_3.Touched());
gabrieltetar 21:d137ec53c3a9 616 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 617 }
gabrieltetar 21:d137ec53c3a9 618 /////////////////////////////STRATEGIE N°4
gabrieltetar 21:d137ec53c3a9 619 if (STRAT_4.Touched()) {
gabrieltetar 21:d137ec53c3a9 620 Strat = 3;
gabrieltetar 21:d137ec53c3a9 621 //msgTx.data[0] = 0x4;
gabrieltetar 21:d137ec53c3a9 622 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 623 while(STRAT_4.Touched());
gabrieltetar 21:d137ec53c3a9 624 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 625 }
gabrieltetar 21:d137ec53c3a9 626 ///////////////////////////////STRATEGIE N°5
gabrieltetar 21:d137ec53c3a9 627 if (STRAT_5.Touched()) {
gabrieltetar 21:d137ec53c3a9 628 Strat = 4;
gabrieltetar 21:d137ec53c3a9 629 //msgTx.data[0] = 0x5;
gabrieltetar 21:d137ec53c3a9 630 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 631 while(STRAT_5.Touched());
gabrieltetar 21:d137ec53c3a9 632 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 633 }
gabrieltetar 21:d137ec53c3a9 634 ////////////////////////////////STRATEGIE N°6
gabrieltetar 21:d137ec53c3a9 635 if (STRAT_6.Touched()) {
gabrieltetar 21:d137ec53c3a9 636 Strat = 5;
gabrieltetar 21:d137ec53c3a9 637 //msgTx.data[0] = 0x6;
gabrieltetar 21:d137ec53c3a9 638 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 639 while(STRAT_6.Touched());
gabrieltetar 21:d137ec53c3a9 640 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 641 }
gabrieltetar 21:d137ec53c3a9 642 /////////////////////////////////STRATEGIE N°7
gabrieltetar 21:d137ec53c3a9 643 if (STRAT_7.Touched()) {
gabrieltetar 21:d137ec53c3a9 644 Strat = 6;
gabrieltetar 21:d137ec53c3a9 645 //msgTx.data[0] = 0x7;
gabrieltetar 21:d137ec53c3a9 646 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 647 while(STRAT_7.Touched());
gabrieltetar 21:d137ec53c3a9 648 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 649 }
gabrieltetar 21:d137ec53c3a9 650 /////////////////////////////////STRATEGIE N°8
gabrieltetar 21:d137ec53c3a9 651 if (STRAT_8.Touched()) {
gabrieltetar 21:d137ec53c3a9 652 Strat = 7;
gabrieltetar 21:d137ec53c3a9 653 //msgTx.data[0] = 0x8;
gabrieltetar 21:d137ec53c3a9 654 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 655 while(STRAT_8.Touched());
gabrieltetar 21:d137ec53c3a9 656 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 657 }
gabrieltetar 21:d137ec53c3a9 658 /////////////////////////////////STRATEGIE N°9
gabrieltetar 21:d137ec53c3a9 659 if (STRAT_9.Touched()) {
gabrieltetar 21:d137ec53c3a9 660 Strat = 8;
gabrieltetar 21:d137ec53c3a9 661 //msgTx.data[0] = 0x9;
gabrieltetar 21:d137ec53c3a9 662 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 663 while(STRAT_9.Touched());
gabrieltetar 21:d137ec53c3a9 664 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 665 }
gabrieltetar 21:d137ec53c3a9 666 ///////////////////////////////////STRATEGIE N°10
gabrieltetar 21:d137ec53c3a9 667 if (STRAT_10.Touched()) {
gabrieltetar 21:d137ec53c3a9 668 Strat = 9;
gabrieltetar 21:d137ec53c3a9 669 //msgTx.data[0] = 0xA;
gabrieltetar 21:d137ec53c3a9 670 //can2.write(msgTx);
gabrieltetar 21:d137ec53c3a9 671 while(STRAT_10.Touched());
gabrieltetar 21:d137ec53c3a9 672 Ack_strat =1;
gabrieltetar 21:d137ec53c3a9 673 }
gabrieltetar 21:d137ec53c3a9 674
gabrieltetar 21:d137ec53c3a9 675 }
gabrieltetar 21:d137ec53c3a9 676 return Strat;
gabrieltetar 21:d137ec53c3a9 677
gabrieltetar 21:d137ec53c3a9 678 }
gabrieltetar 21:d137ec53c3a9 679 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 680 /* FUNCTION NAME: SelectionStrat */
gabrieltetar 21:d137ec53c3a9 681 /* DESCRIPTION : Affiche la Stratégie sélectionnée sur l'ihm */
gabrieltetar 21:d137ec53c3a9 682 /****************************************************************************************/
gabrieltetar 21:d137ec53c3a9 683
gabrieltetar 21:d137ec53c3a9 684
gabrieltetar 21:d137ec53c3a9 685 void SelectionStrat (unsigned char Strategie)
gabrieltetar 21:d137ec53c3a9 686 {
gabrieltetar 21:d137ec53c3a9 687 lcd.SetBackColor(LCD_COLOR_WHITE);
gabrieltetar 21:d137ec53c3a9 688 lcd.SetTextColor(LCD_COLOR_BLACK);
gabrieltetar 21:d137ec53c3a9 689
gabrieltetar 21:d137ec53c3a9 690 switch (Strategie+1) {
gabrieltetar 21:d137ec53c3a9 691 case 0x1 :
gabrieltetar 21:d137ec53c3a9 692 //description de Strategie n°1
gabrieltetar 21:d137ec53c3a9 693 lcd.DisplayStringAt(150, 0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 694 break;
gabrieltetar 21:d137ec53c3a9 695
gabrieltetar 21:d137ec53c3a9 696 case 0x2 :
gabrieltetar 21:d137ec53c3a9 697 //description de Strategie n°2
gabrieltetar 21:d137ec53c3a9 698 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 699 break;
gabrieltetar 21:d137ec53c3a9 700
gabrieltetar 21:d137ec53c3a9 701 case 0x3 :
gabrieltetar 21:d137ec53c3a9 702 //description de Strategie n°3
gabrieltetar 21:d137ec53c3a9 703 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 704 break;
gabrieltetar 21:d137ec53c3a9 705
gabrieltetar 21:d137ec53c3a9 706 case 0x4 :
gabrieltetar 21:d137ec53c3a9 707 //description de Strategie n°4
gabrieltetar 21:d137ec53c3a9 708 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 709 break;
gabrieltetar 21:d137ec53c3a9 710
gabrieltetar 21:d137ec53c3a9 711 case 0x5 :
gabrieltetar 21:d137ec53c3a9 712 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 713 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 714 break;
gabrieltetar 21:d137ec53c3a9 715
gabrieltetar 21:d137ec53c3a9 716 case 0x6 :
gabrieltetar 21:d137ec53c3a9 717 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 718 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 719 break;
gabrieltetar 21:d137ec53c3a9 720
gabrieltetar 21:d137ec53c3a9 721 case 0x7 :
gabrieltetar 21:d137ec53c3a9 722 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 723 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 724 break;
gabrieltetar 21:d137ec53c3a9 725
gabrieltetar 21:d137ec53c3a9 726 case 0x8 :
gabrieltetar 21:d137ec53c3a9 727 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 728 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 729 break;
gabrieltetar 21:d137ec53c3a9 730
gabrieltetar 21:d137ec53c3a9 731 case 0x9 :
gabrieltetar 21:d137ec53c3a9 732 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 733 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 734 break;
gabrieltetar 21:d137ec53c3a9 735
gabrieltetar 21:d137ec53c3a9 736 case 0xA :
gabrieltetar 21:d137ec53c3a9 737 //description de Strategie n°5
gabrieltetar 21:d137ec53c3a9 738 lcd.DisplayStringAt(150,0, (uint8_t *)strat_sd[Strategie], LEFT_MODE);
gabrieltetar 21:d137ec53c3a9 739 break;
gabrieltetar 21:d137ec53c3a9 740 }
gabrieltetar 21:d137ec53c3a9 741 }