Automate écran capacitif

Dependencies:   BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed

Fork of DISCO-F469NI_LCD_demo by ST

Committer:
SquirrelGod
Date:
Fri Mar 31 15:36:26 2017 +0000
Revision:
2:2182df2d7810
Programme ?cran capacitif

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SquirrelGod 2:2182df2d7810 1 #include "mbed.h"
SquirrelGod 2:2182df2d7810 2 #include "TS_DISCO_F469NI.h"
SquirrelGod 2:2182df2d7810 3 #include "LCD_DISCO_F469NI.h"
SquirrelGod 2:2182df2d7810 4 #include "F469_GUI.hpp"
SquirrelGod 2:2182df2d7810 5 #include "ident_crac.h"
SquirrelGod 2:2182df2d7810 6 #include <CAN.h>
SquirrelGod 2:2182df2d7810 7 #include "fonts.h"
SquirrelGod 2:2182df2d7810 8
SquirrelGod 2:2182df2d7810 9 #define BLEU 0xFF0000FF
SquirrelGod 2:2182df2d7810 10 #define ROUGE 0xFFFF0000
SquirrelGod 2:2182df2d7810 11 #define VERT 0xFF7FFF00
SquirrelGod 2:2182df2d7810 12 #define JAUNE 0xFF8F8F25
SquirrelGod 2:2182df2d7810 13 #define BLANC 0xFF000000
SquirrelGod 2:2182df2d7810 14 #define SIZE_FIFO 16
SquirrelGod 2:2182df2d7810 15
SquirrelGod 2:2182df2d7810 16 CAN can1(PB_8, PB_9); //laisser le 1er CAN car probleme sinon
SquirrelGod 2:2182df2d7810 17 CAN can2(PB_5, PB_13);
SquirrelGod 2:2182df2d7810 18
SquirrelGod 2:2182df2d7810 19 CANMessage msgRxBuffer[SIZE_FIFO];
SquirrelGod 2:2182df2d7810 20
SquirrelGod 2:2182df2d7810 21 Ticker ticker;
SquirrelGod 2:2182df2d7810 22 TS_DISCO_F469NI ts;
SquirrelGod 2:2182df2d7810 23 LCD_DISCO_F469NI lcd;
SquirrelGod 2:2182df2d7810 24 DigitalOut led1(LED1);
SquirrelGod 2:2182df2d7810 25 DigitalOut led2(LED2);
SquirrelGod 2:2182df2d7810 26 Timeout timeout;
SquirrelGod 2:2182df2d7810 27 Timeout AffTime;
SquirrelGod 2:2182df2d7810 28 Timer timerAck;
SquirrelGod 2:2182df2d7810 29 Timer timer;
SquirrelGod 2:2182df2d7810 30
SquirrelGod 2:2182df2d7810 31 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};
SquirrelGod 2:2182df2d7810 32
SquirrelGod 2:2182df2d7810 33 char counter = 0;
SquirrelGod 2:2182df2d7810 34 char check;
SquirrelGod 2:2182df2d7810 35 char Jack = 1;
SquirrelGod 2:2182df2d7810 36 int check_cartes = 0, demo_fin = 0;
SquirrelGod 2:2182df2d7810 37 char Ack_strat = 0;
SquirrelGod 2:2182df2d7810 38 signed char Strat = 0;
SquirrelGod 2:2182df2d7810 39
SquirrelGod 2:2182df2d7810 40 void SendRawId (unsigned short id);
SquirrelGod 2:2182df2d7810 41 void SelectionStrat (unsigned char numeroStrat);
SquirrelGod 2:2182df2d7810 42 void Setflag(void);
SquirrelGod 2:2182df2d7810 43 void canProcessRx(void);
SquirrelGod 2:2182df2d7810 44 void canRx_ISR(void);
SquirrelGod 2:2182df2d7810 45 signed char Bouton_Strat (void);
SquirrelGod 2:2182df2d7810 46 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement);
SquirrelGod 2:2182df2d7810 47
SquirrelGod 2:2182df2d7810 48 typedef enum {ATT, CHOIX, DEMO, DEMO_EN_COURS, SELECT_SIDE, TACTIQUE, DETAILS, LAUNCH, WAIT_JACK, FIN} T_etat;
SquirrelGod 2:2182df2d7810 49 T_etat etat = ATT;
SquirrelGod 2:2182df2d7810 50 unsigned char FIFO_ecriture=0; //Position du fifo pour la reception CAN
SquirrelGod 2:2182df2d7810 51 signed char FIFO_lecture=0;//Position du fifo de lecture des messages CAN
SquirrelGod 2:2182df2d7810 52 int flagSendCan=1;
SquirrelGod 2:2182df2d7810 53 unsigned char Cote = 0; //0 -> bleu | 1 -> jaune
SquirrelGod 2:2182df2d7810 54
SquirrelGod 2:2182df2d7810 55 int main()
SquirrelGod 2:2182df2d7810 56 {
SquirrelGod 2:2182df2d7810 57 ts.Init(lcd.GetXSize(), lcd.GetYSize());
SquirrelGod 2:2182df2d7810 58 TS_StateTypeDef TS_State;
SquirrelGod 2:2182df2d7810 59 CANMessage trame_Tx = CANMessage();
SquirrelGod 2:2182df2d7810 60 can2.frequency(1000000); // fréquence de travail 1Mbit/s
SquirrelGod 2:2182df2d7810 61 can2.attach(&canRx_ISR); //interrutpion can en reception
SquirrelGod 2:2182df2d7810 62 int cpt_dizaine,cpt_unite;
SquirrelGod 2:2182df2d7810 63
SquirrelGod 2:2182df2d7810 64 //Initialisation CAN
SquirrelGod 2:2182df2d7810 65 trame_Tx.len = 1;
SquirrelGod 2:2182df2d7810 66 trame_Tx.format = CANStandard;
SquirrelGod 2:2182df2d7810 67 trame_Tx.type = CANData;
SquirrelGod 2:2182df2d7810 68
SquirrelGod 2:2182df2d7810 69 /////////////////DEFINITION DES BOUTONS////////////////////
SquirrelGod 2:2182df2d7810 70 Button COTE_BLEU(20, 25, 755, 200, "Bleu");
SquirrelGod 2:2182df2d7810 71 Button COTE_JAUNE(20, 255, 500, 200, "Jaune");
SquirrelGod 2:2182df2d7810 72 Button RETOUR (530, 255, 245, 200, "--Precedent--");
SquirrelGod 2:2182df2d7810 73 Button LANCER (20, 255, 230, 200, "--LANCER--");
SquirrelGod 2:2182df2d7810 74 Button CHECK (275, 255, 230, 200, "Valider");
SquirrelGod 2:2182df2d7810 75 Button MATCH (10, 25, 780, 200, "Match");
SquirrelGod 2:2182df2d7810 76 Button DEMONSTRATION (10, 255, 780, 200, "Demo");
SquirrelGod 2:2182df2d7810 77 Button TEST_MOTEUR(20, 25, 200, 200, "Moteur");
SquirrelGod 2:2182df2d7810 78 Button TEST_BRAS(240, 25, 200, 200, "Bras");
SquirrelGod 2:2182df2d7810 79 Button FORCE_LAUNCH(530, 255, 245, 200, "Force Launch");
SquirrelGod 2:2182df2d7810 80 ////////////////////////////////////////////////////////////
SquirrelGod 2:2182df2d7810 81
SquirrelGod 2:2182df2d7810 82 signed char Strategie = 0; //N° de la strategie (1-10)
SquirrelGod 2:2182df2d7810 83
SquirrelGod 2:2182df2d7810 84 lcd.SetBackColor(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 85 lcd.SetTextColor(LCD_COLOR_BLACK);
SquirrelGod 2:2182df2d7810 86 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 87 lcd.SetFont(&Font24);
SquirrelGod 2:2182df2d7810 88 lcd.DisplayStringAt(0, 200, (uint8_t *)"Verification des cartes ...", CENTER_MODE);
SquirrelGod 2:2182df2d7810 89 FORCE_LAUNCH.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 90
SquirrelGod 2:2182df2d7810 91 while(1)
SquirrelGod 2:2182df2d7810 92 {
SquirrelGod 2:2182df2d7810 93 canProcessRx();
SquirrelGod 2:2182df2d7810 94 ts.GetState(&TS_State);
SquirrelGod 2:2182df2d7810 95 wait(0.1);
SquirrelGod 2:2182df2d7810 96 switch (etat)
SquirrelGod 2:2182df2d7810 97 {
SquirrelGod 2:2182df2d7810 98 case ATT :
SquirrelGod 2:2182df2d7810 99 if(check_cartes == 1)
SquirrelGod 2:2182df2d7810 100 {
SquirrelGod 2:2182df2d7810 101 etat = CHOIX;
SquirrelGod 2:2182df2d7810 102 check_cartes = 0;
SquirrelGod 2:2182df2d7810 103
SquirrelGod 2:2182df2d7810 104 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 105 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE);
SquirrelGod 2:2182df2d7810 106 DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
SquirrelGod 2:2182df2d7810 107 MATCH.Draw(0xFFF01010, 0);
SquirrelGod 2:2182df2d7810 108 //canProcessRx();
SquirrelGod 2:2182df2d7810 109 }
SquirrelGod 2:2182df2d7810 110 if (FORCE_LAUNCH.Touched())
SquirrelGod 2:2182df2d7810 111 {
SquirrelGod 2:2182df2d7810 112 //etat = CHOIX;
SquirrelGod 2:2182df2d7810 113 SendRawId(ECRAN_ALL_CHECK);
SquirrelGod 2:2182df2d7810 114 etat = CHOIX;
SquirrelGod 2:2182df2d7810 115 while(FORCE_LAUNCH.Touched())
SquirrelGod 2:2182df2d7810 116 canProcessRx();
SquirrelGod 2:2182df2d7810 117
SquirrelGod 2:2182df2d7810 118 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 119 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE);
SquirrelGod 2:2182df2d7810 120 DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
SquirrelGod 2:2182df2d7810 121 MATCH.Draw(0xFFF01010, 0);
SquirrelGod 2:2182df2d7810 122 }
SquirrelGod 2:2182df2d7810 123 break;
SquirrelGod 2:2182df2d7810 124
SquirrelGod 2:2182df2d7810 125 case CHOIX :
SquirrelGod 2:2182df2d7810 126 //canProcessRx();
SquirrelGod 2:2182df2d7810 127 if(DEMONSTRATION.Touched())
SquirrelGod 2:2182df2d7810 128 {
SquirrelGod 2:2182df2d7810 129 etat = DEMO;
SquirrelGod 2:2182df2d7810 130 while(DEMONSTRATION.Touched())
SquirrelGod 2:2182df2d7810 131 canProcessRx();
SquirrelGod 2:2182df2d7810 132
SquirrelGod 2:2182df2d7810 133 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 134 TEST_MOTEUR.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 135 TEST_BRAS.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 136 RETOUR.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 137 trame_Tx.id = 0x602;
SquirrelGod 2:2182df2d7810 138 trame_Tx.data[0] = 0;
SquirrelGod 2:2182df2d7810 139 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 140 }
SquirrelGod 2:2182df2d7810 141
SquirrelGod 2:2182df2d7810 142 if(MATCH.Touched())
SquirrelGod 2:2182df2d7810 143 {
SquirrelGod 2:2182df2d7810 144 etat = SELECT_SIDE;
SquirrelGod 2:2182df2d7810 145 while(MATCH.Touched())
SquirrelGod 2:2182df2d7810 146 canProcessRx();
SquirrelGod 2:2182df2d7810 147
SquirrelGod 2:2182df2d7810 148 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 149 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis un cote gros", CENTER_MODE);
SquirrelGod 2:2182df2d7810 150 COTE_BLEU.Draw(0xFF0070FF, 0);
SquirrelGod 2:2182df2d7810 151 COTE_JAUNE.Draw(0xFFFFF000, 0);
SquirrelGod 2:2182df2d7810 152 RETOUR.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 153 trame_Tx.id = 0x602;
SquirrelGod 2:2182df2d7810 154 }
SquirrelGod 2:2182df2d7810 155 break;
SquirrelGod 2:2182df2d7810 156
SquirrelGod 2:2182df2d7810 157 case DEMO :
SquirrelGod 2:2182df2d7810 158
SquirrelGod 2:2182df2d7810 159 trame_Tx.id=0x601;
SquirrelGod 2:2182df2d7810 160 //canProcessRx();
SquirrelGod 2:2182df2d7810 161 if(TEST_MOTEUR.Touched())
SquirrelGod 2:2182df2d7810 162 {
SquirrelGod 2:2182df2d7810 163 Strat = 0x10;
SquirrelGod 2:2182df2d7810 164 trame_Tx.data[0] = Strat;
SquirrelGod 2:2182df2d7810 165 while(TEST_MOTEUR.Touched())
SquirrelGod 2:2182df2d7810 166 canProcessRx();
SquirrelGod 2:2182df2d7810 167 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 168 TEST_MOTEUR.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 169 //etat = DEMO_EN_COURS;
SquirrelGod 2:2182df2d7810 170 }
SquirrelGod 2:2182df2d7810 171
SquirrelGod 2:2182df2d7810 172 if(TEST_BRAS.Touched())
SquirrelGod 2:2182df2d7810 173 {
SquirrelGod 2:2182df2d7810 174 Strat = 0x11;
SquirrelGod 2:2182df2d7810 175 trame_Tx.data[0] = Strat;
SquirrelGod 2:2182df2d7810 176 while(TEST_BRAS.Touched())
SquirrelGod 2:2182df2d7810 177 canProcessRx();
SquirrelGod 2:2182df2d7810 178 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 179 TEST_MOTEUR.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 180 //etat = DEMO_EN_COURS;
SquirrelGod 2:2182df2d7810 181 }
SquirrelGod 2:2182df2d7810 182
SquirrelGod 2:2182df2d7810 183 if(RETOUR.Touched())
SquirrelGod 2:2182df2d7810 184 {
SquirrelGod 2:2182df2d7810 185 etat = CHOIX;
SquirrelGod 2:2182df2d7810 186 while(RETOUR.Touched())
SquirrelGod 2:2182df2d7810 187 canProcessRx();
SquirrelGod 2:2182df2d7810 188
SquirrelGod 2:2182df2d7810 189 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 190 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE);
SquirrelGod 2:2182df2d7810 191 DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
SquirrelGod 2:2182df2d7810 192 MATCH.Draw(0xFFF01010, 0);
SquirrelGod 2:2182df2d7810 193 }
SquirrelGod 2:2182df2d7810 194 //SelectionStrat(trame_Tx.data[0]);
SquirrelGod 2:2182df2d7810 195 if (Ack_strat == 1)
SquirrelGod 2:2182df2d7810 196 {
SquirrelGod 2:2182df2d7810 197 etat = DEMO_EN_COURS;
SquirrelGod 2:2182df2d7810 198 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 199 lcd.SetFont(&Font24);
SquirrelGod 2:2182df2d7810 200 lcd.DisplayStringAt(0, 190, (uint8_t *)"DEMONSTRATION EN COURS", CENTER_MODE);
SquirrelGod 2:2182df2d7810 201 Ack_strat = 0;
SquirrelGod 2:2182df2d7810 202 }
SquirrelGod 2:2182df2d7810 203
SquirrelGod 2:2182df2d7810 204 break;
SquirrelGod 2:2182df2d7810 205
SquirrelGod 2:2182df2d7810 206 case DEMO_EN_COURS:
SquirrelGod 2:2182df2d7810 207
SquirrelGod 2:2182df2d7810 208 if (demo_fin == 1)
SquirrelGod 2:2182df2d7810 209 {
SquirrelGod 2:2182df2d7810 210 etat = DEMO;
SquirrelGod 2:2182df2d7810 211 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 212 TEST_MOTEUR.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 213 TEST_BRAS.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 214 RETOUR.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 215 trame_Tx.id = 0x602;
SquirrelGod 2:2182df2d7810 216 trame_Tx.data[0] = 0;
SquirrelGod 2:2182df2d7810 217 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 218 }
SquirrelGod 2:2182df2d7810 219 Ack_strat = 0;
SquirrelGod 2:2182df2d7810 220
SquirrelGod 2:2182df2d7810 221 case SELECT_SIDE :
SquirrelGod 2:2182df2d7810 222
SquirrelGod 2:2182df2d7810 223 //canProcessRx();
SquirrelGod 2:2182df2d7810 224 if(COTE_BLEU.Touched())
SquirrelGod 2:2182df2d7810 225 {
SquirrelGod 2:2182df2d7810 226 Cote = 0x0;
SquirrelGod 2:2182df2d7810 227 trame_Tx.data[0] = Cote;
SquirrelGod 2:2182df2d7810 228 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 229 while(COTE_BLEU.Touched())
SquirrelGod 2:2182df2d7810 230 canProcessRx();
SquirrelGod 2:2182df2d7810 231 }
SquirrelGod 2:2182df2d7810 232
SquirrelGod 2:2182df2d7810 233 if(COTE_JAUNE.Touched())
SquirrelGod 2:2182df2d7810 234 {
SquirrelGod 2:2182df2d7810 235 Cote = 0x1;
SquirrelGod 2:2182df2d7810 236 trame_Tx.data[0] = Cote;
SquirrelGod 2:2182df2d7810 237 can2.write(trame_Tx);
SquirrelGod 2:2182df2d7810 238 while(COTE_JAUNE.Touched())
SquirrelGod 2:2182df2d7810 239 canProcessRx();
SquirrelGod 2:2182df2d7810 240 }
SquirrelGod 2:2182df2d7810 241
SquirrelGod 2:2182df2d7810 242 if(RETOUR.Touched())
SquirrelGod 2:2182df2d7810 243 {
SquirrelGod 2:2182df2d7810 244 etat = CHOIX;
SquirrelGod 2:2182df2d7810 245 while(RETOUR.Touched())
SquirrelGod 2:2182df2d7810 246 canProcessRx();
SquirrelGod 2:2182df2d7810 247
SquirrelGod 2:2182df2d7810 248 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 249 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Match ou demonstration ?", CENTER_MODE);
SquirrelGod 2:2182df2d7810 250 DEMONSTRATION.Draw(LCD_COLOR_LIGHTGREEN, 0);
SquirrelGod 2:2182df2d7810 251 MATCH.Draw(0xFFF01010, 0);
SquirrelGod 2:2182df2d7810 252 }
SquirrelGod 2:2182df2d7810 253 break;
SquirrelGod 2:2182df2d7810 254
SquirrelGod 2:2182df2d7810 255 case TACTIQUE :
SquirrelGod 2:2182df2d7810 256 if (Cote == 0){
SquirrelGod 2:2182df2d7810 257 lcd.Clear(0xFF0070FF);
SquirrelGod 2:2182df2d7810 258 lcd.SetBackColor(0xFF0070FF);
SquirrelGod 2:2182df2d7810 259 }
SquirrelGod 2:2182df2d7810 260 else if (Cote == 1){
SquirrelGod 2:2182df2d7810 261 lcd.Clear(0xFFFFF000);
SquirrelGod 2:2182df2d7810 262 lcd.SetBackColor(0xFFFFF000);
SquirrelGod 2:2182df2d7810 263 }
SquirrelGod 2:2182df2d7810 264 else {
SquirrelGod 2:2182df2d7810 265 lcd.Clear(0xFF0070FF);
SquirrelGod 2:2182df2d7810 266 lcd.SetBackColor(0xFF0070FF);
SquirrelGod 2:2182df2d7810 267 }
SquirrelGod 2:2182df2d7810 268
SquirrelGod 2:2182df2d7810 269 lcd.SetTextColor(LCD_COLOR_BLACK);
SquirrelGod 2:2182df2d7810 270 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis une strat gros", CENTER_MODE);
SquirrelGod 2:2182df2d7810 271
SquirrelGod 2:2182df2d7810 272 Strategie = Bouton_Strat(); // retourne valeur de Strategie si bouton strat renvoi -1 on reviens en arriere
SquirrelGod 2:2182df2d7810 273 if (Strategie == -1)
SquirrelGod 2:2182df2d7810 274 {
SquirrelGod 2:2182df2d7810 275 etat = SELECT_SIDE;
SquirrelGod 2:2182df2d7810 276 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 277 lcd.SetBackColor(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 278 lcd.SetTextColor(LCD_COLOR_BLACK);
SquirrelGod 2:2182df2d7810 279 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"Choisis un cote gros", CENTER_MODE);
SquirrelGod 2:2182df2d7810 280 COTE_BLEU.Draw(0xFF0070FF, 0);
SquirrelGod 2:2182df2d7810 281 COTE_JAUNE.Draw(0xFFFFF000, 0);
SquirrelGod 2:2182df2d7810 282 RETOUR.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 283 trame_Tx.id = 0x602;
SquirrelGod 2:2182df2d7810 284 }
SquirrelGod 2:2182df2d7810 285 else
SquirrelGod 2:2182df2d7810 286 {
SquirrelGod 2:2182df2d7810 287 etat = DETAILS;
SquirrelGod 2:2182df2d7810 288 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 289 CHECK.Draw(0xFF00FF00);
SquirrelGod 2:2182df2d7810 290 RETOUR.Draw(0xFFFF0000);
SquirrelGod 2:2182df2d7810 291 SelectionStrat(Strategie);
SquirrelGod 2:2182df2d7810 292 }
SquirrelGod 2:2182df2d7810 293
SquirrelGod 2:2182df2d7810 294 break;
SquirrelGod 2:2182df2d7810 295
SquirrelGod 2:2182df2d7810 296 case DETAILS :
SquirrelGod 2:2182df2d7810 297 //canProcessRx();
SquirrelGod 2:2182df2d7810 298 if (CHECK.Touched())
SquirrelGod 2:2182df2d7810 299 {
SquirrelGod 2:2182df2d7810 300 SendRawId(ECRAN_START_MATCH);
SquirrelGod 2:2182df2d7810 301 //etat = WAIT_JACK;
SquirrelGod 2:2182df2d7810 302 while(CHECK.Touched())
SquirrelGod 2:2182df2d7810 303 canProcessRx();
SquirrelGod 2:2182df2d7810 304 }
SquirrelGod 2:2182df2d7810 305
SquirrelGod 2:2182df2d7810 306 if(RETOUR.Touched())
SquirrelGod 2:2182df2d7810 307 {
SquirrelGod 2:2182df2d7810 308 etat = TACTIQUE;
SquirrelGod 2:2182df2d7810 309 while(RETOUR.Touched());
SquirrelGod 2:2182df2d7810 310 }
SquirrelGod 2:2182df2d7810 311 break;
SquirrelGod 2:2182df2d7810 312
SquirrelGod 2:2182df2d7810 313
SquirrelGod 2:2182df2d7810 314 case WAIT_JACK :
SquirrelGod 2:2182df2d7810 315 lcd.SetBackColor(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 316 lcd.SetTextColor(LCD_COLOR_BLACK);
SquirrelGod 2:2182df2d7810 317 lcd.Clear(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 318 lcd.SetFont(&Font24);
SquirrelGod 2:2182df2d7810 319 if (Cote == 0){
SquirrelGod 2:2182df2d7810 320 lcd.Clear(0xFF0070FF);
SquirrelGod 2:2182df2d7810 321 lcd.SetBackColor(0xFF0070FF);
SquirrelGod 2:2182df2d7810 322 }
SquirrelGod 2:2182df2d7810 323 else if (Cote == 1){
SquirrelGod 2:2182df2d7810 324 lcd.Clear(0xFFFFF000);
SquirrelGod 2:2182df2d7810 325 lcd.SetBackColor(0xFFFFF000);
SquirrelGod 2:2182df2d7810 326 }
SquirrelGod 2:2182df2d7810 327 else {
SquirrelGod 2:2182df2d7810 328 lcd.Clear(0xFF0070FF);
SquirrelGod 2:2182df2d7810 329 lcd.SetBackColor(0xFF0070FF);
SquirrelGod 2:2182df2d7810 330 }
SquirrelGod 2:2182df2d7810 331 SendRawId(DEBUG_FAKE_JAKE); // PERMET DE SIMULER LE RETRAIT DU JACK POUR QUE LE ROBOT DEMARRE APRES LA VALIDATION DE LA STRAT
SquirrelGod 2:2182df2d7810 332 /* while (Jack == 1){
SquirrelGod 2:2182df2d7810 333 lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"En attente du Jack", CENTER_MODE);
SquirrelGod 2:2182df2d7810 334 }*/
SquirrelGod 2:2182df2d7810 335 cpt_dizaine = 57, cpt_unite = 48;
SquirrelGod 2:2182df2d7810 336 while (cpt_dizaine !=47){
SquirrelGod 2:2182df2d7810 337 lcd.DisplayChar(390,190,cpt_dizaine);
SquirrelGod 2:2182df2d7810 338 while (cpt_unite != 47)
SquirrelGod 2:2182df2d7810 339 {
SquirrelGod 2:2182df2d7810 340 lcd.DisplayChar(410,190,cpt_unite);//la fonction affiche un caractere en ASCII d'ou la valeur de cpt
SquirrelGod 2:2182df2d7810 341 cpt_unite--;
SquirrelGod 2:2182df2d7810 342 wait(1);
SquirrelGod 2:2182df2d7810 343 }
SquirrelGod 2:2182df2d7810 344 cpt_dizaine--;
SquirrelGod 2:2182df2d7810 345 cpt_unite = 57;
SquirrelGod 2:2182df2d7810 346 }
SquirrelGod 2:2182df2d7810 347 lcd.DisplayStringAt(0, 190, (uint8_t *)"FIN DU MATCH", CENTER_MODE);
SquirrelGod 2:2182df2d7810 348 wait(5);
SquirrelGod 2:2182df2d7810 349 etat = FIN;
SquirrelGod 2:2182df2d7810 350 break;
SquirrelGod 2:2182df2d7810 351
SquirrelGod 2:2182df2d7810 352 case FIN :
SquirrelGod 2:2182df2d7810 353 lcd.Clear (LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 354 lcd.SetBackColor(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 355 lcd.SetFont(&Font24);
SquirrelGod 2:2182df2d7810 356 lcd.DisplayStringAt(0, 170, (uint8_t *)"REDEMARAGE", CENTER_MODE);
SquirrelGod 2:2182df2d7810 357 lcd.DisplayStringAt(0, 190, (uint8_t *)"NECESSAIRE", CENTER_MODE);
SquirrelGod 2:2182df2d7810 358 while(1); // force le redemarage du robot
SquirrelGod 2:2182df2d7810 359 break;
SquirrelGod 2:2182df2d7810 360
SquirrelGod 2:2182df2d7810 361 }
SquirrelGod 2:2182df2d7810 362
SquirrelGod 2:2182df2d7810 363 }
SquirrelGod 2:2182df2d7810 364 }
SquirrelGod 2:2182df2d7810 365
SquirrelGod 2:2182df2d7810 366
SquirrelGod 2:2182df2d7810 367 void SendRawId (unsigned short id)
SquirrelGod 2:2182df2d7810 368 {
SquirrelGod 2:2182df2d7810 369 CANMessage msgTx=CANMessage();
SquirrelGod 2:2182df2d7810 370 msgTx.id=id;
SquirrelGod 2:2182df2d7810 371 msgTx.len=0;
SquirrelGod 2:2182df2d7810 372 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 373 }
SquirrelGod 2:2182df2d7810 374
SquirrelGod 2:2182df2d7810 375 void SelectionStrat (unsigned char numeroStrat)
SquirrelGod 2:2182df2d7810 376 {
SquirrelGod 2:2182df2d7810 377 lcd.SetBackColor(LCD_COLOR_WHITE);
SquirrelGod 2:2182df2d7810 378 lcd.SetTextColor(LCD_COLOR_BLACK);
SquirrelGod 2:2182df2d7810 379 lcd.SetFont(&Font24);
SquirrelGod 2:2182df2d7810 380 switch (numeroStrat)
SquirrelGod 2:2182df2d7810 381 {
SquirrelGod 2:2182df2d7810 382 case 0x1 :
SquirrelGod 2:2182df2d7810 383 //description de Strategie n°1
SquirrelGod 2:2182df2d7810 384 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 1 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 385 break;
SquirrelGod 2:2182df2d7810 386
SquirrelGod 2:2182df2d7810 387 case 0x2 :
SquirrelGod 2:2182df2d7810 388 //description de Strategie n°2
SquirrelGod 2:2182df2d7810 389 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 2 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 390 break;
SquirrelGod 2:2182df2d7810 391
SquirrelGod 2:2182df2d7810 392 case 0x3 :
SquirrelGod 2:2182df2d7810 393 //description de Strategie n°3
SquirrelGod 2:2182df2d7810 394 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 3 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 395 break;
SquirrelGod 2:2182df2d7810 396
SquirrelGod 2:2182df2d7810 397 case 0x4 :
SquirrelGod 2:2182df2d7810 398 //description de Strategie n°4
SquirrelGod 2:2182df2d7810 399 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 4 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 400 break;
SquirrelGod 2:2182df2d7810 401
SquirrelGod 2:2182df2d7810 402 case 0x5 :
SquirrelGod 2:2182df2d7810 403 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 404 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 5 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 405 break;
SquirrelGod 2:2182df2d7810 406
SquirrelGod 2:2182df2d7810 407 case 0x6 :
SquirrelGod 2:2182df2d7810 408 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 409 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 6 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 410 break;
SquirrelGod 2:2182df2d7810 411
SquirrelGod 2:2182df2d7810 412 case 0x7 :
SquirrelGod 2:2182df2d7810 413 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 414 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 7 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 415 break;
SquirrelGod 2:2182df2d7810 416
SquirrelGod 2:2182df2d7810 417 case 0x8 :
SquirrelGod 2:2182df2d7810 418 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 419 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 8 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 420 break;
SquirrelGod 2:2182df2d7810 421
SquirrelGod 2:2182df2d7810 422 case 0x9 :
SquirrelGod 2:2182df2d7810 423 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 424 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 9 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 425 break;
SquirrelGod 2:2182df2d7810 426
SquirrelGod 2:2182df2d7810 427 case 0xA :
SquirrelGod 2:2182df2d7810 428 //description de Strategie n°5
SquirrelGod 2:2182df2d7810 429 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 10 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 430 break;
SquirrelGod 2:2182df2d7810 431
SquirrelGod 2:2182df2d7810 432 case 0x10 :
SquirrelGod 2:2182df2d7810 433 lcd.DisplayStringAt(20, 100, (uint8_t *)"Strategie 10 :", LEFT_MODE);
SquirrelGod 2:2182df2d7810 434 break;
SquirrelGod 2:2182df2d7810 435 }
SquirrelGod 2:2182df2d7810 436 }
SquirrelGod 2:2182df2d7810 437
SquirrelGod 2:2182df2d7810 438 void Setflag(void)
SquirrelGod 2:2182df2d7810 439 {
SquirrelGod 2:2182df2d7810 440 flagSendCan = 1;
SquirrelGod 2:2182df2d7810 441 }
SquirrelGod 2:2182df2d7810 442
SquirrelGod 2:2182df2d7810 443 void canProcessRx(void)
SquirrelGod 2:2182df2d7810 444 {
SquirrelGod 2:2182df2d7810 445 static signed char FIFO_occupation=0,FIFO_max_occupation=0;
SquirrelGod 2:2182df2d7810 446 char useless1 = 0;
SquirrelGod 2:2182df2d7810 447
SquirrelGod 2:2182df2d7810 448 FIFO_occupation=FIFO_ecriture-FIFO_lecture;
SquirrelGod 2:2182df2d7810 449 if(FIFO_occupation<0)
SquirrelGod 2:2182df2d7810 450 FIFO_occupation=FIFO_occupation+SIZE_FIFO;
SquirrelGod 2:2182df2d7810 451 if(FIFO_max_occupation<FIFO_occupation)
SquirrelGod 2:2182df2d7810 452 FIFO_max_occupation=FIFO_occupation;
SquirrelGod 2:2182df2d7810 453 if(FIFO_occupation!=0) {
SquirrelGod 2:2182df2d7810 454
SquirrelGod 2:2182df2d7810 455 switch(msgRxBuffer[FIFO_lecture].id) {
SquirrelGod 2:2182df2d7810 456 case ECRAN_PRINTF_1:
SquirrelGod 2:2182df2d7810 457 for(useless1 = 0; useless1 <8; useless1++) {
SquirrelGod 2:2182df2d7810 458 test[useless1] = msgRxBuffer[FIFO_lecture].data[useless1];
SquirrelGod 2:2182df2d7810 459 }
SquirrelGod 2:2182df2d7810 460 //updateDisplay();
SquirrelGod 2:2182df2d7810 461 break;
SquirrelGod 2:2182df2d7810 462 case ECRAN_PRINTF_2:
SquirrelGod 2:2182df2d7810 463 for(useless1 = 0; useless1 <8; useless1++) {
SquirrelGod 2:2182df2d7810 464 test[useless1+8] = msgRxBuffer[FIFO_lecture].data[useless1];
SquirrelGod 2:2182df2d7810 465 }
SquirrelGod 2:2182df2d7810 466 //updateDisplay();
SquirrelGod 2:2182df2d7810 467 //Ecrire_CANtxt(test);
SquirrelGod 2:2182df2d7810 468 break;
SquirrelGod 2:2182df2d7810 469 case ECRAN_PRINTF_3:
SquirrelGod 2:2182df2d7810 470 for(useless1 = 0; useless1 <8; useless1++) {
SquirrelGod 2:2182df2d7810 471 test[useless1+2*8] = msgRxBuffer[FIFO_lecture].data[useless1];
SquirrelGod 2:2182df2d7810 472 }
SquirrelGod 2:2182df2d7810 473 //updateDisplay();
SquirrelGod 2:2182df2d7810 474 //Ecrire_CANtxt(test);
SquirrelGod 2:2182df2d7810 475 break;
SquirrelGod 2:2182df2d7810 476 case ECRAN_PRINTF_4:
SquirrelGod 2:2182df2d7810 477 for(useless1 = 0; useless1 <8; useless1++) {
SquirrelGod 2:2182df2d7810 478 test[useless1+3*8] = msgRxBuffer[FIFO_lecture].data[useless1];
SquirrelGod 2:2182df2d7810 479 }
SquirrelGod 2:2182df2d7810 480 //updateDisplay();
SquirrelGod 2:2182df2d7810 481 //Ecrire_CANtxt(test);
SquirrelGod 2:2182df2d7810 482 break;
SquirrelGod 2:2182df2d7810 483 case ECRAN_PRINTF_CLEAR:
SquirrelGod 2:2182df2d7810 484 etat = CHOIX;
SquirrelGod 2:2182df2d7810 485 break;
SquirrelGod 2:2182df2d7810 486 case CHECK_IHM:
SquirrelGod 2:2182df2d7810 487 SendRawId(ALIVE_IHM);
SquirrelGod 2:2182df2d7810 488 break;
SquirrelGod 2:2182df2d7810 489 case RESET_IHM:
SquirrelGod 2:2182df2d7810 490 etat = CHOIX;
SquirrelGod 2:2182df2d7810 491 break;
SquirrelGod 2:2182df2d7810 492 case CHECK_BALISE:
SquirrelGod 2:2182df2d7810 493 //Check[1].color = Orange;
SquirrelGod 2:2182df2d7810 494 //DrawChecks();
SquirrelGod 2:2182df2d7810 495 break;
SquirrelGod 2:2182df2d7810 496 case ALIVE_BALISE:
SquirrelGod 2:2182df2d7810 497 //Check[1].color = Green;
SquirrelGod 2:2182df2d7810 498 //DrawChecks();
SquirrelGod 2:2182df2d7810 499 break;
SquirrelGod 2:2182df2d7810 500 case CHECK_MOTEUR:
SquirrelGod 2:2182df2d7810 501 //Check[2].color = Orange;
SquirrelGod 2:2182df2d7810 502 //DrawChecks();
SquirrelGod 2:2182df2d7810 503 break;
SquirrelGod 2:2182df2d7810 504 case ALIVE_MOTEUR:
SquirrelGod 2:2182df2d7810 505 //Check[2].color = Green;
SquirrelGod 2:2182df2d7810 506 //DrawChecks();
SquirrelGod 2:2182df2d7810 507 break;
SquirrelGod 2:2182df2d7810 508 case CHECK_ACTIONNEURS:
SquirrelGod 2:2182df2d7810 509 //Check[3].color = Orange;
SquirrelGod 2:2182df2d7810 510 //DrawChecks();
SquirrelGod 2:2182df2d7810 511 break;
SquirrelGod 2:2182df2d7810 512 case ALIVE_ACTIONNEURS:
SquirrelGod 2:2182df2d7810 513 //Check[3].color = Green;
SquirrelGod 2:2182df2d7810 514 //DrawChecks();
SquirrelGod 2:2182df2d7810 515 break;
SquirrelGod 2:2182df2d7810 516 case ECRAN_ALL_CHECK:
SquirrelGod 2:2182df2d7810 517 check_cartes=1;
SquirrelGod 2:2182df2d7810 518 //DrawEcran(1);
SquirrelGod 2:2182df2d7810 519 //EcranActuel = 1;
SquirrelGod 2:2182df2d7810 520 //menusOnEcranActuel = Liste_ecrans[EcranActuel-1].menus;
SquirrelGod 2:2182df2d7810 521 break;
SquirrelGod 2:2182df2d7810 522 case ECRAN_ACK_STRAT:
SquirrelGod 2:2182df2d7810 523 if (msgRxBuffer[FIFO_lecture].data[0] == Strat)
SquirrelGod 2:2182df2d7810 524 Ack_strat = 1;
SquirrelGod 2:2182df2d7810 525 break;
SquirrelGod 2:2182df2d7810 526 case ECRAN_ACK_COLOR:
SquirrelGod 2:2182df2d7810 527 if (etat != DEMO)
SquirrelGod 2:2182df2d7810 528 etat = TACTIQUE;
SquirrelGod 2:2182df2d7810 529 break;
SquirrelGod 2:2182df2d7810 530 case ECRAN_ACK_START_MATCH:
SquirrelGod 2:2182df2d7810 531 if (etat == DEMO_EN_COURS)
SquirrelGod 2:2182df2d7810 532 {
SquirrelGod 2:2182df2d7810 533 SendRawId(DEBUG_FAKE_JAKE);
SquirrelGod 2:2182df2d7810 534 }
SquirrelGod 2:2182df2d7810 535 else
SquirrelGod 2:2182df2d7810 536 {
SquirrelGod 2:2182df2d7810 537 etat = WAIT_JACK;
SquirrelGod 2:2182df2d7810 538 }
SquirrelGod 2:2182df2d7810 539 break;
SquirrelGod 2:2182df2d7810 540 case GLOBAL_START:
SquirrelGod 2:2182df2d7810 541 Jack=0;
SquirrelGod 2:2182df2d7810 542 break;
SquirrelGod 2:2182df2d7810 543
SquirrelGod 2:2182df2d7810 544 case DEBUG_STRATEGIE_AUTOMATE :
SquirrelGod 2:2182df2d7810 545 if (msgRxBuffer[FIFO_lecture].data[0] == 19) {
SquirrelGod 2:2182df2d7810 546 demo_fin = 1;
SquirrelGod 2:2182df2d7810 547 }
SquirrelGod 2:2182df2d7810 548 break;
SquirrelGod 2:2182df2d7810 549
SquirrelGod 2:2182df2d7810 550 default:
SquirrelGod 2:2182df2d7810 551 break;
SquirrelGod 2:2182df2d7810 552 }
SquirrelGod 2:2182df2d7810 553 FIFO_lecture=(FIFO_lecture+1)%SIZE_FIFO;
SquirrelGod 2:2182df2d7810 554 }
SquirrelGod 2:2182df2d7810 555 }
SquirrelGod 2:2182df2d7810 556
SquirrelGod 2:2182df2d7810 557 void canRx_ISR (void)
SquirrelGod 2:2182df2d7810 558 {
SquirrelGod 2:2182df2d7810 559 if (can2.read(msgRxBuffer[FIFO_ecriture])) {
SquirrelGod 2:2182df2d7810 560 led2 = !led2;
SquirrelGod 2:2182df2d7810 561 if(msgRxBuffer[FIFO_ecriture].id==RESET_IHM)
SquirrelGod 2:2182df2d7810 562 lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"Erreur", CENTER_MODE);//mbed_reset();
SquirrelGod 2:2182df2d7810 563 else FIFO_ecriture=(FIFO_ecriture+1)%SIZE_FIFO;
SquirrelGod 2:2182df2d7810 564 }
SquirrelGod 2:2182df2d7810 565 }
SquirrelGod 2:2182df2d7810 566
SquirrelGod 2:2182df2d7810 567 signed char Bouton_Strat (void)
SquirrelGod 2:2182df2d7810 568 {
SquirrelGod 2:2182df2d7810 569 CANMessage msgTx=CANMessage();
SquirrelGod 2:2182df2d7810 570 msgTx.id=0x601;
SquirrelGod 2:2182df2d7810 571 msgTx.len=1;
SquirrelGod 2:2182df2d7810 572
SquirrelGod 2:2182df2d7810 573 Button STRAT_1 (20, 10, 150, 150, "Strategie 1");
SquirrelGod 2:2182df2d7810 574 Button STRAT_2 (180, 10, 150, 150, "Strategie 2");
SquirrelGod 2:2182df2d7810 575 Button STRAT_3 (340, 10, 150, 150, "Strategie 3");
SquirrelGod 2:2182df2d7810 576 Button STRAT_4 (20, 165, 150, 150, "Strategie 4");
SquirrelGod 2:2182df2d7810 577 Button STRAT_5 (180, 165, 150, 150, "Strategie 5");
SquirrelGod 2:2182df2d7810 578 Button STRAT_6 (340, 165, 150, 150, "Strategie 6");
SquirrelGod 2:2182df2d7810 579 Button STRAT_7 (20, 320, 150, 150, "Strategie 7");
SquirrelGod 2:2182df2d7810 580 Button STRAT_8 (180, 320, 150, 150, "Strategie 8");
SquirrelGod 2:2182df2d7810 581 Button STRAT_9 (340, 320, 150, 150, "Strategie 9");
SquirrelGod 2:2182df2d7810 582 Button STRAT_10 (530, 25, 245, 200, "Strategie 10");
SquirrelGod 2:2182df2d7810 583 Button RETOUR (530, 255, 245, 200, "--Precedent--");
SquirrelGod 2:2182df2d7810 584 //Definition des boutons
SquirrelGod 2:2182df2d7810 585
SquirrelGod 2:2182df2d7810 586 Ack_strat = 0;
SquirrelGod 2:2182df2d7810 587 Strat = 0;
SquirrelGod 2:2182df2d7810 588 STRAT_1.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 589 STRAT_2.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 590 STRAT_3.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 591 STRAT_4.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 592 STRAT_5.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 593 STRAT_6.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 594 STRAT_7.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 595 STRAT_8.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 596 STRAT_9.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 597 STRAT_10.Draw(0xFFF0F0F0, 0);
SquirrelGod 2:2182df2d7810 598 RETOUR.Draw(0xFFFF0000, 0);
SquirrelGod 2:2182df2d7810 599
SquirrelGod 2:2182df2d7810 600 while(Ack_strat == 0)
SquirrelGod 2:2182df2d7810 601 {
SquirrelGod 2:2182df2d7810 602 canProcessRx();
SquirrelGod 2:2182df2d7810 603 if (RETOUR.Touched())
SquirrelGod 2:2182df2d7810 604 return -1;
SquirrelGod 2:2182df2d7810 605 while(RETOUR.Touched());
SquirrelGod 2:2182df2d7810 606 //////////////////////////////STRATEGIE N°1
SquirrelGod 2:2182df2d7810 607 if (STRAT_1.Touched()){
SquirrelGod 2:2182df2d7810 608 Strat = 1;
SquirrelGod 2:2182df2d7810 609 msgTx.data[0] = 0x1;
SquirrelGod 2:2182df2d7810 610 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 611 while(STRAT_1.Touched());
SquirrelGod 2:2182df2d7810 612 }
SquirrelGod 2:2182df2d7810 613 /////////////////////////////STRATEGIE N°2
SquirrelGod 2:2182df2d7810 614 if (STRAT_2.Touched()){
SquirrelGod 2:2182df2d7810 615 Strat = 2;
SquirrelGod 2:2182df2d7810 616 msgTx.data[0] = 0x2;
SquirrelGod 2:2182df2d7810 617 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 618 while(STRAT_2.Touched());
SquirrelGod 2:2182df2d7810 619 }
SquirrelGod 2:2182df2d7810 620 //////////////////////////////STRATEGIE N°3
SquirrelGod 2:2182df2d7810 621 if (STRAT_3.Touched()){
SquirrelGod 2:2182df2d7810 622 Strat = 3;
SquirrelGod 2:2182df2d7810 623 msgTx.data[0] = 0x3;
SquirrelGod 2:2182df2d7810 624 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 625 while(STRAT_3.Touched());
SquirrelGod 2:2182df2d7810 626 }
SquirrelGod 2:2182df2d7810 627 /////////////////////////////STRATEGIE N°4
SquirrelGod 2:2182df2d7810 628 if (STRAT_4.Touched()){
SquirrelGod 2:2182df2d7810 629 Strat = 4;
SquirrelGod 2:2182df2d7810 630 msgTx.data[0] = 0x4;
SquirrelGod 2:2182df2d7810 631 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 632 while(STRAT_4.Touched());
SquirrelGod 2:2182df2d7810 633 }
SquirrelGod 2:2182df2d7810 634 ///////////////////////////////STRATEGIE N°5
SquirrelGod 2:2182df2d7810 635 if (STRAT_5.Touched()){
SquirrelGod 2:2182df2d7810 636 Strat = 5;
SquirrelGod 2:2182df2d7810 637 msgTx.data[0] = 0x5;
SquirrelGod 2:2182df2d7810 638 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 639 while(STRAT_5.Touched());
SquirrelGod 2:2182df2d7810 640 }
SquirrelGod 2:2182df2d7810 641 ////////////////////////////////STRATEGIE N°6
SquirrelGod 2:2182df2d7810 642 if (STRAT_6.Touched()){
SquirrelGod 2:2182df2d7810 643 Strat = 6;
SquirrelGod 2:2182df2d7810 644 msgTx.data[0] = 0x6;
SquirrelGod 2:2182df2d7810 645 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 646 while(STRAT_6.Touched());
SquirrelGod 2:2182df2d7810 647 }
SquirrelGod 2:2182df2d7810 648 /////////////////////////////////STRATEGIE N°7
SquirrelGod 2:2182df2d7810 649 if (STRAT_7.Touched()){
SquirrelGod 2:2182df2d7810 650 Strat = 7;
SquirrelGod 2:2182df2d7810 651 msgTx.data[0] = 0x7;
SquirrelGod 2:2182df2d7810 652 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 653 while(STRAT_7.Touched());
SquirrelGod 2:2182df2d7810 654 }
SquirrelGod 2:2182df2d7810 655 /////////////////////////////////STRATEGIE N°8
SquirrelGod 2:2182df2d7810 656 if (STRAT_8.Touched()){
SquirrelGod 2:2182df2d7810 657 Strat = 8;
SquirrelGod 2:2182df2d7810 658 msgTx.data[0] = 0x8;
SquirrelGod 2:2182df2d7810 659 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 660 while(STRAT_8.Touched());
SquirrelGod 2:2182df2d7810 661 }
SquirrelGod 2:2182df2d7810 662 /////////////////////////////////STRATEGIE N°9
SquirrelGod 2:2182df2d7810 663 if (STRAT_9.Touched()){
SquirrelGod 2:2182df2d7810 664 Strat = 9;
SquirrelGod 2:2182df2d7810 665 msgTx.data[0] = 0x9;
SquirrelGod 2:2182df2d7810 666 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 667 while(STRAT_9.Touched());
SquirrelGod 2:2182df2d7810 668 }
SquirrelGod 2:2182df2d7810 669 ///////////////////////////////////STRATEGIE N°10
SquirrelGod 2:2182df2d7810 670 if (STRAT_10.Touched()){
SquirrelGod 2:2182df2d7810 671 Strat = 10;
SquirrelGod 2:2182df2d7810 672 msgTx.data[0] = 0xA;
SquirrelGod 2:2182df2d7810 673 can2.write(msgTx);
SquirrelGod 2:2182df2d7810 674 while(STRAT_10.Touched());
SquirrelGod 2:2182df2d7810 675 }
SquirrelGod 2:2182df2d7810 676 }
SquirrelGod 2:2182df2d7810 677 return Strat;
SquirrelGod 2:2182df2d7810 678 }
SquirrelGod 2:2182df2d7810 679
SquirrelGod 2:2182df2d7810 680 //FONCTION DE L'ASSERVISSEMENT POUR LA DEMONSTRATION
SquirrelGod 2:2182df2d7810 681 void GoStraight (signed short distance,unsigned char recalage, unsigned short newValue, unsigned char isEnchainement)
SquirrelGod 2:2182df2d7810 682 {
SquirrelGod 2:2182df2d7810 683 CANMessage msgTx=CANMessage();
SquirrelGod 2:2182df2d7810 684 msgTx.id=ASSERVISSEMENT_RECALAGE;
SquirrelGod 2:2182df2d7810 685 msgTx.len=6;
SquirrelGod 2:2182df2d7810 686 msgTx.format=CANStandard;
SquirrelGod 2:2182df2d7810 687 msgTx.type=CANData;
SquirrelGod 2:2182df2d7810 688 // x sur 2 octets
SquirrelGod 2:2182df2d7810 689 msgTx.data[0]=(unsigned char)distance;
SquirrelGod 2:2182df2d7810 690 msgTx.data[1]=(unsigned char)(distance>>8);
SquirrelGod 2:2182df2d7810 691 //Recalage sur 1 octet
SquirrelGod 2:2182df2d7810 692 msgTx.data[2]=recalage;
SquirrelGod 2:2182df2d7810 693 //Valeur du recalage sur 2 octets
SquirrelGod 2:2182df2d7810 694 msgTx.data[3]=(unsigned char)newValue;
SquirrelGod 2:2182df2d7810 695 msgTx.data[4]=(unsigned char)(newValue>>8);
SquirrelGod 2:2182df2d7810 696 //Enchainement sur 1 octet
SquirrelGod 2:2182df2d7810 697 msgTx.data[5]=isEnchainement;
SquirrelGod 2:2182df2d7810 698
SquirrelGod 2:2182df2d7810 699 can1.write(msgTx);
SquirrelGod 2:2182df2d7810 700 //wait_ms(500);
SquirrelGod 2:2182df2d7810 701 }