yoo

Dependencies:   7SegSRDriver_youcef C12832_lcd EthernetInterface_youcef NetworkAPI TimeZone mbed-rtos mbed

Committer:
sefyou
Date:
Tue Jun 06 13:32:03 2017 +0000
Revision:
0:3bc2fc472428
yo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sefyou 0:3bc2fc472428 1 #include "mbed.h"
sefyou 0:3bc2fc472428 2 #include "7SegSRDriver.h"
sefyou 0:3bc2fc472428 3 #include "EthernetInterface.h"
sefyou 0:3bc2fc472428 4 #include "Time.h"
sefyou 0:3bc2fc472428 5 #include "C12832_lcd.h"
sefyou 0:3bc2fc472428 6
sefyou 0:3bc2fc472428 7 //#include "C12832.h"
sefyou 0:3bc2fc472428 8
sefyou 0:3bc2fc472428 9
sefyou 0:3bc2fc472428 10 #include "NetworkAPI/buffer.hpp"
sefyou 0:3bc2fc472428 11 #include "NetworkAPI/ip/address.hpp"
sefyou 0:3bc2fc472428 12 #include "NetworkAPI/udp/socket.hpp"
sefyou 0:3bc2fc472428 13
sefyou 0:3bc2fc472428 14 DigitalOut Buzzer(p6);
sefyou 0:3bc2fc472428 15
sefyou 0:3bc2fc472428 16 const char* MCAST_GRP = "224.1.1.1";
sefyou 0:3bc2fc472428 17 const int MCAST_PORT = 8888;
sefyou 0:3bc2fc472428 18
sefyou 0:3bc2fc472428 19 const char* ip= "172.16.202.4";
sefyou 0:3bc2fc472428 20 const char* masque= "255.255.0.0";
sefyou 0:3bc2fc472428 21 const char* gateway= "172.16.0.5";
sefyou 0:3bc2fc472428 22
sefyou 0:3bc2fc472428 23 Timer t;
sefyou 0:3bc2fc472428 24
sefyou 0:3bc2fc472428 25 SSegSRDriver_chronometre display(p26,p7,p25, SSegSRDriver_COMN_CATHODE); //data , clock, latch // Chrono
sefyou 0:3bc2fc472428 26 SSegSRDriver_domicile display2(p23,p7,p24, SSegSRDriver_COMN_CATHODE); //data , clock, latch // Visiteur
sefyou 0:3bc2fc472428 27 SSegSRDriver_visiteur display3(p21,p7,p22, SSegSRDriver_COMN_CATHODE); //data , clock, latch // domicile
sefyou 0:3bc2fc472428 28
sefyou 0:3bc2fc472428 29
sefyou 0:3bc2fc472428 30
sefyou 0:3bc2fc472428 31
sefyou 0:3bc2fc472428 32 //C12832 lcd(p5, p7, p6, p8, p11); //le mod d'affichage
sefyou 0:3bc2fc472428 33 /*************************AFFICHE DOMICILE*************************************/
sefyou 0:3bc2fc472428 34 void afficherDOM(SSegSRDriver_domicile display2, int centaine, int dizaine, int unite)
sefyou 0:3bc2fc472428 35 {
sefyou 0:3bc2fc472428 36 display2.write_domicile(centaine,0);//C
sefyou 0:3bc2fc472428 37 display2.write_domicile_2(dizaine,0);//D
sefyou 0:3bc2fc472428 38 display2.write_domicile_3(unite,0);//U
sefyou 0:3bc2fc472428 39 }
sefyou 0:3bc2fc472428 40 /*************************AFFICHE VISITEUR*************************************/
sefyou 0:3bc2fc472428 41 void afficherVIS(SSegSRDriver_visiteur display3, int centaine, int dizaine, int unite)
sefyou 0:3bc2fc472428 42 {
sefyou 0:3bc2fc472428 43 display3.write_visiteur(centaine,0);//C
sefyou 0:3bc2fc472428 44 display3.write_visiteur_2(dizaine,0);//D
sefyou 0:3bc2fc472428 45 display3.write_visiteur_3(unite,0);//U
sefyou 0:3bc2fc472428 46 }
sefyou 0:3bc2fc472428 47 /*************************AFFICHE CHRONOMETRE**********************************/
sefyou 0:3bc2fc472428 48 void affiche_chrono(SSegSRDriver_chronometre display,int unite, int dizaine, int centaine,int millier)
sefyou 0:3bc2fc472428 49 {
sefyou 0:3bc2fc472428 50 display.write_chronometre_4(millier,0);
sefyou 0:3bc2fc472428 51 display.write_chronometre_3(centaine,0);
sefyou 0:3bc2fc472428 52 display.write_chronometre_2(dizaine,0);
sefyou 0:3bc2fc472428 53 display.write_chronometre(unite,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 54 }
sefyou 0:3bc2fc472428 55
sefyou 0:3bc2fc472428 56 /*************************CALCULE INCREMENTE***********************************/
sefyou 0:3bc2fc472428 57 void calculIncremente(int* centaine, int* dizaine, int* unite)
sefyou 0:3bc2fc472428 58 {
sefyou 0:3bc2fc472428 59 if((*unite) >=10)
sefyou 0:3bc2fc472428 60 {
sefyou 0:3bc2fc472428 61 (*unite)=(*unite)-10;
sefyou 0:3bc2fc472428 62 ((*dizaine))++;
sefyou 0:3bc2fc472428 63 }
sefyou 0:3bc2fc472428 64 if(((*dizaine)) >=10)
sefyou 0:3bc2fc472428 65 {
sefyou 0:3bc2fc472428 66 ((*dizaine))-=10;
sefyou 0:3bc2fc472428 67 ((*centaine))++;
sefyou 0:3bc2fc472428 68 }
sefyou 0:3bc2fc472428 69 }
sefyou 0:3bc2fc472428 70 /*************************CALCULE DECREMENTE***********************************/
sefyou 0:3bc2fc472428 71 void calculDecremente(int* centaine, int* dizaine, int* unite)
sefyou 0:3bc2fc472428 72 {
sefyou 0:3bc2fc472428 73 if((*unite)<0) //si l'unité est inférieur a 0
sefyou 0:3bc2fc472428 74 {
sefyou 0:3bc2fc472428 75 (*unite) +=10; // unité sera égale a 10
sefyou 0:3bc2fc472428 76 if((*dizaine) == 0) // si la dizaine est égale a 0
sefyou 0:3bc2fc472428 77 {
sefyou 0:3bc2fc472428 78 if((*centaine) > 0)// et la centaine est suppérieur a 0
sefyou 0:3bc2fc472428 79 {
sefyou 0:3bc2fc472428 80 (*centaine) -= 1; //centaine sera égale a centaine -1
sefyou 0:3bc2fc472428 81 (*dizaine) = 9; // dizaine sera égale a 9
sefyou 0:3bc2fc472428 82 }
sefyou 0:3bc2fc472428 83 }
sefyou 0:3bc2fc472428 84 else //si la dizaine ne sera pas égale a 0
sefyou 0:3bc2fc472428 85 {
sefyou 0:3bc2fc472428 86 (*dizaine) -=1; //dizaine sera égale a dizaine -1
sefyou 0:3bc2fc472428 87 }
sefyou 0:3bc2fc472428 88 }
sefyou 0:3bc2fc472428 89 }
sefyou 0:3bc2fc472428 90 /*************************PLAY CHRONOMETRE*************************************/
sefyou 0:3bc2fc472428 91 void playchrono(SSegSRDriver_chronometre display, int* unite, int* dizaine, int* centaine,int* millier)
sefyou 0:3bc2fc472428 92 {
sefyou 0:3bc2fc472428 93 t.start();
sefyou 0:3bc2fc472428 94 if (t.read_ms() >= 1000)
sefyou 0:3bc2fc472428 95 {
sefyou 0:3bc2fc472428 96
sefyou 0:3bc2fc472428 97 if ((*unite) >= 10) //si unité seconde suppérieur ou égale a 9
sefyou 0:3bc2fc472428 98 {
sefyou 0:3bc2fc472428 99 (*dizaine)++; //dizaine seconde sera égale a dizaine seconde +1
sefyou 0:3bc2fc472428 100 (*unite) =0; //unité seconde sera égale a 0
sefyou 0:3bc2fc472428 101 }
sefyou 0:3bc2fc472428 102 if ((*dizaine) >= 6) //si dizaine seconde suppérieur ou égale a 6 (60secondes)
sefyou 0:3bc2fc472428 103 {
sefyou 0:3bc2fc472428 104 (*dizaine) =0; //dizaine seconde sera égale a 0
sefyou 0:3bc2fc472428 105 (*unite) =0; //unité seconde sera égale a 0
sefyou 0:3bc2fc472428 106 (*centaine) ++; //unité minute sera égale a unité minute +1
sefyou 0:3bc2fc472428 107 }
sefyou 0:3bc2fc472428 108 if ((*centaine) >= 10)
sefyou 0:3bc2fc472428 109 {
sefyou 0:3bc2fc472428 110 (*centaine)=0;
sefyou 0:3bc2fc472428 111 (*millier)++;
sefyou 0:3bc2fc472428 112 }
sefyou 0:3bc2fc472428 113 display.write_chronometre_4(*millier,0);
sefyou 0:3bc2fc472428 114 display.write_chronometre_3(*centaine,0);
sefyou 0:3bc2fc472428 115 display.write_chronometre_2(*dizaine,0);
sefyou 0:3bc2fc472428 116 display.write_chronometre(*unite,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 117
sefyou 0:3bc2fc472428 118 // wait(1);
sefyou 0:3bc2fc472428 119 (*unite)++;
sefyou 0:3bc2fc472428 120 t.reset();
sefyou 0:3bc2fc472428 121 }
sefyou 0:3bc2fc472428 122 }
sefyou 0:3bc2fc472428 123 void resetchrono(SSegSRDriver_chronometre display, int* u_second, int* d_second, int* u_minute, int* d_minute)
sefyou 0:3bc2fc472428 124 {
sefyou 0:3bc2fc472428 125 *u_second = 0;
sefyou 0:3bc2fc472428 126 *d_second = 0;
sefyou 0:3bc2fc472428 127 *u_minute = 0;
sefyou 0:3bc2fc472428 128 *d_minute = 0;
sefyou 0:3bc2fc472428 129 /* stockd_minute = 0;
sefyou 0:3bc2fc472428 130 stocku_minute = 0;
sefyou 0:3bc2fc472428 131 stockd_second = 0;
sefyou 0:3bc2fc472428 132 stocku_second = 0;*/
sefyou 0:3bc2fc472428 133
sefyou 0:3bc2fc472428 134
sefyou 0:3bc2fc472428 135 display.write_chronometre_4(*d_minute,0);
sefyou 0:3bc2fc472428 136 display.write_chronometre_3(*u_minute,0);
sefyou 0:3bc2fc472428 137 display.write_chronometre_2(*d_second,0);
sefyou 0:3bc2fc472428 138 display.write_chronometre(*u_second,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 139
sefyou 0:3bc2fc472428 140
sefyou 0:3bc2fc472428 141
sefyou 0:3bc2fc472428 142 }
sefyou 0:3bc2fc472428 143
sefyou 0:3bc2fc472428 144 void pausechrono(SSegSRDriver_chronometre display, int* u_second, int* d_second, int* u_minute, int* d_minute)
sefyou 0:3bc2fc472428 145 {
sefyou 0:3bc2fc472428 146 /* stockd_minute = *d_minute;
sefyou 0:3bc2fc472428 147 stocku_minute = *u_minute;
sefyou 0:3bc2fc472428 148 stockd_second = *d_second;
sefyou 0:3bc2fc472428 149 stocku_second = *u_second;*/
sefyou 0:3bc2fc472428 150
sefyou 0:3bc2fc472428 151 /* display.write_chronometre_4(stockd_minute,0);
sefyou 0:3bc2fc472428 152 display.write_chronometre_3(stocku_minute,0);
sefyou 0:3bc2fc472428 153 display.write_chronometre_2(stockd_second,0);
sefyou 0:3bc2fc472428 154 display.write_chronometre(stocku_second,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 155
sefyou 0:3bc2fc472428 156 */
sefyou 0:3bc2fc472428 157 }
sefyou 0:3bc2fc472428 158
sefyou 0:3bc2fc472428 159 /*************************RESET DOMICILE***************************************/
sefyou 0:3bc2fc472428 160 void DOM_reset(SSegSRDriver_domicile display2, int u ,int d,int c)
sefyou 0:3bc2fc472428 161 {
sefyou 0:3bc2fc472428 162 display2.write_domicile(c,0);//C
sefyou 0:3bc2fc472428 163 display2.write_domicile_2(d,0);//D
sefyou 0:3bc2fc472428 164 display2.write_domicile_3(u,0);//U
sefyou 0:3bc2fc472428 165
sefyou 0:3bc2fc472428 166 }
sefyou 0:3bc2fc472428 167 /*************************RESET VISITEUR***************************************/
sefyou 0:3bc2fc472428 168 void VIS_reset(SSegSRDriver_visiteur display3)
sefyou 0:3bc2fc472428 169 {
sefyou 0:3bc2fc472428 170
sefyou 0:3bc2fc472428 171 }
sefyou 0:3bc2fc472428 172 /*************************RESET CHRONOMETRE************************************/
sefyou 0:3bc2fc472428 173 void CHRONO_reset(SSegSRDriver_chronometre display)
sefyou 0:3bc2fc472428 174 {
sefyou 0:3bc2fc472428 175
sefyou 0:3bc2fc472428 176 }
sefyou 0:3bc2fc472428 177
sefyou 0:3bc2fc472428 178
sefyou 0:3bc2fc472428 179
sefyou 0:3bc2fc472428 180
sefyou 0:3bc2fc472428 181
sefyou 0:3bc2fc472428 182
sefyou 0:3bc2fc472428 183
sefyou 0:3bc2fc472428 184
sefyou 0:3bc2fc472428 185
sefyou 0:3bc2fc472428 186 int main()
sefyou 0:3bc2fc472428 187 {
sefyou 0:3bc2fc472428 188 C12832_LCD lcd; //Graphics LCD
sefyou 0:3bc2fc472428 189 EthernetInterface interface;
sefyou 0:3bc2fc472428 190 interface.init(ip,masque,gateway);
sefyou 0:3bc2fc472428 191 interface.connect();
sefyou 0:3bc2fc472428 192
sefyou 0:3bc2fc472428 193
sefyou 0:3bc2fc472428 194
sefyou 0:3bc2fc472428 195 UDPSocket server;
sefyou 0:3bc2fc472428 196 server.bind(MCAST_PORT);
sefyou 0:3bc2fc472428 197 server.init();
sefyou 0:3bc2fc472428 198 //Endpoint client;
sefyou 0:3bc2fc472428 199
sefyou 0:3bc2fc472428 200 //Heure
sefyou 0:3bc2fc472428 201
sefyou 0:3bc2fc472428 202
sefyou 0:3bc2fc472428 203 Timer heure;
sefyou 0:3bc2fc472428 204 Endpoint nist;
sefyou 0:3bc2fc472428 205 nist.set_address("utcnist.colorado.edu", 37);
sefyou 0:3bc2fc472428 206
sefyou 0:3bc2fc472428 207 char out_buffer[] = ""; // Does not matter
sefyou 0:3bc2fc472428 208 server.sendTo(nist, out_buffer, sizeof(out_buffer));
sefyou 0:3bc2fc472428 209
sefyou 0:3bc2fc472428 210
sefyou 0:3bc2fc472428 211 char data[255];
sefyou 0:3bc2fc472428 212
sefyou 0:3bc2fc472428 213 int n = server.receiveFrom(nist, data, sizeof(data));
sefyou 0:3bc2fc472428 214
sefyou 0:3bc2fc472428 215
sefyou 0:3bc2fc472428 216
sefyou 0:3bc2fc472428 217 unsigned int timeRes = ntohl( *((unsigned int*)data));
sefyou 0:3bc2fc472428 218
sefyou 0:3bc2fc472428 219
sefyou 0:3bc2fc472428 220 heure.start();
sefyou 0:3bc2fc472428 221
sefyou 0:3bc2fc472428 222 int heure01;
sefyou 0:3bc2fc472428 223 int heure02;
sefyou 0:3bc2fc472428 224
sefyou 0:3bc2fc472428 225 int minute01;
sefyou 0:3bc2fc472428 226 int minute02;
sefyou 0:3bc2fc472428 227
sefyou 0:3bc2fc472428 228 //char data[256];
sefyou 0:3bc2fc472428 229
sefyou 0:3bc2fc472428 230 //CHRONO
sefyou 0:3bc2fc472428 231 int u_second = 0; //unité seconde
sefyou 0:3bc2fc472428 232 int d_second = 0; //dizaine seconde
sefyou 0:3bc2fc472428 233 int u_minute = 0; //unité minute
sefyou 0:3bc2fc472428 234 int d_minute = 0; //dizaine minute
sefyou 0:3bc2fc472428 235
sefyou 0:3bc2fc472428 236 //SCORE DOMICILE
sefyou 0:3bc2fc472428 237 int uniteDOM = 0;
sefyou 0:3bc2fc472428 238 int dizaineDOM = 0;
sefyou 0:3bc2fc472428 239 int centaineDOM = 0;
sefyou 0:3bc2fc472428 240
sefyou 0:3bc2fc472428 241 //SCORE VISITEUR
sefyou 0:3bc2fc472428 242 int uniteVIS =0;
sefyou 0:3bc2fc472428 243 int dizaineVIS =0;
sefyou 0:3bc2fc472428 244 int centaineVIS = 0;
sefyou 0:3bc2fc472428 245
sefyou 0:3bc2fc472428 246 //VERIFICATIONS DES CHANGEMENT 1 = CHANGEMENT EFFECTUER 0 = AUCUN CHANGEMENT EFFECTUER
sefyou 0:3bc2fc472428 247 bool incrementeDOM;
sefyou 0:3bc2fc472428 248 bool decrementeDOM;
sefyou 0:3bc2fc472428 249 bool incrementeVIS;
sefyou 0:3bc2fc472428 250 bool decrementeVIS;
sefyou 0:3bc2fc472428 251
sefyou 0:3bc2fc472428 252 //STOCKAGE
sefyou 0:3bc2fc472428 253 int stockUNITEDOM;
sefyou 0:3bc2fc472428 254 int stockDIZAINEDOM;
sefyou 0:3bc2fc472428 255 int stockCENTAINEDOM;
sefyou 0:3bc2fc472428 256
sefyou 0:3bc2fc472428 257 int stockUNITEVIS;
sefyou 0:3bc2fc472428 258 int stockDIZAINEVIS;
sefyou 0:3bc2fc472428 259 int stockCENTAINEVIS;
sefyou 0:3bc2fc472428 260
sefyou 0:3bc2fc472428 261 int chrono;
sefyou 0:3bc2fc472428 262
sefyou 0:3bc2fc472428 263 /*int stocku_second;
sefyou 0:3bc2fc472428 264 int stockd_second;
sefyou 0:3bc2fc472428 265 int stocku_minute;
sefyou 0:3bc2fc472428 266 int stockd_minute;*/
sefyou 0:3bc2fc472428 267
sefyou 0:3bc2fc472428 268
sefyou 0:3bc2fc472428 269 if(heure.read_ms() >= 1000)
sefyou 0:3bc2fc472428 270 {
sefyou 0:3bc2fc472428 271 set_time(timeRes);
sefyou 0:3bc2fc472428 272 time_t unixTime= time(NULL);
sefyou 0:3bc2fc472428 273 TimeStamp timeStamp(unixTime);
sefyou 0:3bc2fc472428 274 heure01= ((timeStamp.getHour()+2) /10);
sefyou 0:3bc2fc472428 275 heure02= ((timeStamp.getHour()+2) %10);
sefyou 0:3bc2fc472428 276
sefyou 0:3bc2fc472428 277 minute01= ((timeStamp.getMinute()) /10);
sefyou 0:3bc2fc472428 278 minute02= ((timeStamp.getMinute()) %10);
sefyou 0:3bc2fc472428 279
sefyou 0:3bc2fc472428 280 display.write_chronometre_4(heure01,0);
sefyou 0:3bc2fc472428 281 display.write_chronometre_3(heure02,0);
sefyou 0:3bc2fc472428 282 display.write_chronometre_2(minute01,0);
sefyou 0:3bc2fc472428 283 display.write_chronometre(minute02,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 284
sefyou 0:3bc2fc472428 285 lcd.cls();
sefyou 0:3bc2fc472428 286
sefyou 0:3bc2fc472428 287 lcd.printf("%d",timeStamp.getHour()+2);
sefyou 0:3bc2fc472428 288 lcd.printf("\n");
sefyou 0:3bc2fc472428 289 lcd.printf("%d",timeStamp.getMinute());
sefyou 0:3bc2fc472428 290 lcd.printf("\n");
sefyou 0:3bc2fc472428 291 lcd.printf("%d", timeStamp.getSecond());
sefyou 0:3bc2fc472428 292
sefyou 0:3bc2fc472428 293 timeRes+=1;
sefyou 0:3bc2fc472428 294
sefyou 0:3bc2fc472428 295
sefyou 0:3bc2fc472428 296 heure.reset();
sefyou 0:3bc2fc472428 297 }
sefyou 0:3bc2fc472428 298 //char buffer[32]; // test buffer hour
sefyou 0:3bc2fc472428 299
sefyou 0:3bc2fc472428 300 //lcd.printf("%d", timeRes);
sefyou 0:3bc2fc472428 301 while(1)
sefyou 0:3bc2fc472428 302 {
sefyou 0:3bc2fc472428 303 //INITIALISATION DES CHANGEMENT A 0
sefyou 0:3bc2fc472428 304 incrementeDOM = false;
sefyou 0:3bc2fc472428 305 decrementeDOM = false;
sefyou 0:3bc2fc472428 306 incrementeVIS = false;
sefyou 0:3bc2fc472428 307 decrementeVIS = false;
sefyou 0:3bc2fc472428 308 data[1] =0; //changer la data. serveur non blokant
sefyou 0:3bc2fc472428 309
sefyou 0:3bc2fc472428 310 server.receiveFrom(nist, data, sizeof(data));
sefyou 0:3bc2fc472428 311
sefyou 0:3bc2fc472428 312 /***********************************BUZZER*************************************/
sefyou 0:3bc2fc472428 313 if(data[0]=='B' && data[1]=='U' && data[2] =='Z' && data[3] == 'Z')
sefyou 0:3bc2fc472428 314 {
sefyou 0:3bc2fc472428 315 Buzzer = 1;
sefyou 0:3bc2fc472428 316 wait(1);
sefyou 0:3bc2fc472428 317 Buzzer = 0;
sefyou 0:3bc2fc472428 318 }
sefyou 0:3bc2fc472428 319
sefyou 0:3bc2fc472428 320 /********************************RESET DOMICILE********************************/
sefyou 0:3bc2fc472428 321 if (data[0]=='R' && data[1]=='D' && data[2] =='O' && data[3] == 'M')
sefyou 0:3bc2fc472428 322 {
sefyou 0:3bc2fc472428 323 uniteDOM = 0;
sefyou 0:3bc2fc472428 324 dizaineDOM = 0;
sefyou 0:3bc2fc472428 325 centaineDOM = 0;
sefyou 0:3bc2fc472428 326 //DOM_reset(display2,0,0,0);
sefyou 0:3bc2fc472428 327 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 328
sefyou 0:3bc2fc472428 329 }
sefyou 0:3bc2fc472428 330 /********************************RESET VISITEUR********************************/
sefyou 0:3bc2fc472428 331 if (data[0]=='R' && data[1]=='V' && data[2] =='I' && data[3] == 'S')
sefyou 0:3bc2fc472428 332 {
sefyou 0:3bc2fc472428 333 uniteVIS = 0;
sefyou 0:3bc2fc472428 334 dizaineVIS = 0;
sefyou 0:3bc2fc472428 335 centaineVIS = 0;
sefyou 0:3bc2fc472428 336 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 337 }
sefyou 0:3bc2fc472428 338
sefyou 0:3bc2fc472428 339 /***********************************LE RETOUR**********************************/
sefyou 0:3bc2fc472428 340
sefyou 0:3bc2fc472428 341
sefyou 0:3bc2fc472428 342
sefyou 0:3bc2fc472428 343
sefyou 0:3bc2fc472428 344 if (data[0]=='B' && data[1]=='A' && data[2] =='C' && data[3] == 'K')
sefyou 0:3bc2fc472428 345 {
sefyou 0:3bc2fc472428 346 /*uniteDOM = 11;
sefyou 0:3bc2fc472428 347 dizaineDOM = 11;
sefyou 0:3bc2fc472428 348 centaineDOM = 11;
sefyou 0:3bc2fc472428 349 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 350
sefyou 0:3bc2fc472428 351 uniteVIS = 11;
sefyou 0:3bc2fc472428 352 dizaineVIS = 11;
sefyou 0:3bc2fc472428 353 centaineVIS = 11;
sefyou 0:3bc2fc472428 354 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 355
sefyou 0:3bc2fc472428 356 u_second = 11;
sefyou 0:3bc2fc472428 357 d_second = 11;
sefyou 0:3bc2fc472428 358 u_minute = 11;
sefyou 0:3bc2fc472428 359 d_minute = 11;
sefyou 0:3bc2fc472428 360 affiche_chrono(display, u_second, d_second, u_minute, d_minute); */
sefyou 0:3bc2fc472428 361
sefyou 0:3bc2fc472428 362
sefyou 0:3bc2fc472428 363
sefyou 0:3bc2fc472428 364 /*AFFICHER HEURE */
sefyou 0:3bc2fc472428 365 /* time_t seconds = time(NULL);
sefyou 0:3bc2fc472428 366 strftime(buffer, 32, "%I:%M %p", localtime(&seconds));*/
sefyou 0:3bc2fc472428 367
sefyou 0:3bc2fc472428 368
sefyou 0:3bc2fc472428 369
sefyou 0:3bc2fc472428 370 //displayHeure(heure, timeRes, heure01, heure02, minute01, minute02);
sefyou 0:3bc2fc472428 371
sefyou 0:3bc2fc472428 372 }
sefyou 0:3bc2fc472428 373 /***********CONFIGURATION CHRONO & SCORE LORS DU CHOIX DU SPORT****************/
sefyou 0:3bc2fc472428 374 if (//data[0]=='C' && data[1]=='T' && data[2] =='*' && data[3] == '*' || //tenis
sefyou 0:3bc2fc472428 375 //data[0]=='C' && data[1]=='R' && data[2] =='U' && data[3] == 'G' || //rugby
sefyou 0:3bc2fc472428 376 data[0]=='C' && data[1]=='B' && data[2] =='B' && data[3] == '*' || //basket
sefyou 0:3bc2fc472428 377 data[0]=='C' && data[1]=='H' && data[2] =='*' && data[3] == '*' || //handball
sefyou 0:3bc2fc472428 378 data[0]=='C' && data[1]=='F' && data[2] =='U' && data[3] == 'T' || //futsal
sefyou 0:3bc2fc472428 379 //data[0]=='C' && data[1]=='V' && data[2] =='B' && data[3] == '*' || //volley-ball
sefyou 0:3bc2fc472428 380 //data[0]=='C' && data[1]=='B' && data[2] =='A' && data[3] == 'D' || //badminton
sefyou 0:3bc2fc472428 381 //data[0]=='C' && data[1]=='T' && data[2] =='D' && data[3] == 'T' || //tenis de table
sefyou 0:3bc2fc472428 382 data[0]=='C' && data[1]=='B' && data[2] =='O' && data[3] == 'X' || //box
sefyou 0:3bc2fc472428 383 data[0]=='C' && data[1]=='F' && data[2] =='L' && data[3] == 'A' //flag
sefyou 0:3bc2fc472428 384 )
sefyou 0:3bc2fc472428 385 {
sefyou 0:3bc2fc472428 386 uniteDOM = 0;
sefyou 0:3bc2fc472428 387 dizaineDOM = 0;
sefyou 0:3bc2fc472428 388 centaineDOM = 0;
sefyou 0:3bc2fc472428 389 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 390
sefyou 0:3bc2fc472428 391 uniteVIS = 0;
sefyou 0:3bc2fc472428 392 dizaineVIS = 0;
sefyou 0:3bc2fc472428 393 centaineVIS = 0;
sefyou 0:3bc2fc472428 394 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 395
sefyou 0:3bc2fc472428 396 u_second = 0;
sefyou 0:3bc2fc472428 397 d_second = 0;
sefyou 0:3bc2fc472428 398 u_minute = 0;
sefyou 0:3bc2fc472428 399 d_minute = 0;
sefyou 0:3bc2fc472428 400 affiche_chrono(display, u_second, d_second, u_minute, d_minute);
sefyou 0:3bc2fc472428 401 }
sefyou 0:3bc2fc472428 402 /***********************CONFIGURATION CHRONOMETRE******************************/
sefyou 0:3bc2fc472428 403 if (data[0]=='C' && data[1]=='H' && data[2] =='R' && data[3] == 'O') // configuration chronometre
sefyou 0:3bc2fc472428 404 {
sefyou 0:3bc2fc472428 405 u_second = 0;
sefyou 0:3bc2fc472428 406 d_second = 0;
sefyou 0:3bc2fc472428 407 u_minute = 0;
sefyou 0:3bc2fc472428 408 d_minute = 0;
sefyou 0:3bc2fc472428 409 affiche_chrono(display, u_second, d_second, u_minute, d_minute);
sefyou 0:3bc2fc472428 410
sefyou 0:3bc2fc472428 411 uniteVIS = 11;
sefyou 0:3bc2fc472428 412 dizaineVIS = 11;
sefyou 0:3bc2fc472428 413 centaineVIS = 11;
sefyou 0:3bc2fc472428 414 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 415
sefyou 0:3bc2fc472428 416 uniteDOM = 11;
sefyou 0:3bc2fc472428 417 dizaineDOM = 11;
sefyou 0:3bc2fc472428 418 centaineDOM = 11;
sefyou 0:3bc2fc472428 419 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 420
sefyou 0:3bc2fc472428 421 }
sefyou 0:3bc2fc472428 422 /******************CONFIGURATION SCORE LORS DU CHOIX DU SPORT******************/
sefyou 0:3bc2fc472428 423 if (data[0]=='C' && data[1]=='V' && data[2] =='B' && data[3] == '*' || //volley-ball
sefyou 0:3bc2fc472428 424 data[0]=='C' && data[1]=='B' && data[2] =='A' && data[3] == 'D' || //badminton
sefyou 0:3bc2fc472428 425 data[0]=='C' && data[1]=='T' && data[2] =='D' && data[3] == 'T' //tenis de table
sefyou 0:3bc2fc472428 426 )
sefyou 0:3bc2fc472428 427 {
sefyou 0:3bc2fc472428 428 uniteDOM = 0;
sefyou 0:3bc2fc472428 429 dizaineDOM = 0;
sefyou 0:3bc2fc472428 430 centaineDOM = 0;
sefyou 0:3bc2fc472428 431 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 432
sefyou 0:3bc2fc472428 433 uniteVIS = 0;
sefyou 0:3bc2fc472428 434 dizaineVIS = 0;
sefyou 0:3bc2fc472428 435 centaineVIS = 0;
sefyou 0:3bc2fc472428 436 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 437 }
sefyou 0:3bc2fc472428 438
sefyou 0:3bc2fc472428 439 /***********************************SET DOMICILE*******************************/
sefyou 0:3bc2fc472428 440 if (data[0]=='S' && data[1]=='E' && data[2] =='T' && data[3] == 'D')
sefyou 0:3bc2fc472428 441 {
sefyou 0:3bc2fc472428 442 stockUNITEDOM= uniteDOM;
sefyou 0:3bc2fc472428 443 stockDIZAINEDOM= dizaineDOM;
sefyou 0:3bc2fc472428 444 stockCENTAINEDOM= centaineDOM;
sefyou 0:3bc2fc472428 445
sefyou 0:3bc2fc472428 446 stockUNITEVIS= uniteVIS;
sefyou 0:3bc2fc472428 447 stockDIZAINEVIS= dizaineVIS;
sefyou 0:3bc2fc472428 448 stockCENTAINEVIS= centaineVIS;
sefyou 0:3bc2fc472428 449
sefyou 0:3bc2fc472428 450 uniteDOM = 0;
sefyou 0:3bc2fc472428 451 dizaineDOM = 0;
sefyou 0:3bc2fc472428 452 centaineDOM = 0;
sefyou 0:3bc2fc472428 453 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 454
sefyou 0:3bc2fc472428 455 uniteVIS = 0;
sefyou 0:3bc2fc472428 456 dizaineVIS = 0;
sefyou 0:3bc2fc472428 457 centaineVIS = 0;
sefyou 0:3bc2fc472428 458 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 459 // INCREMENTER MATRICE DE LED
sefyou 0:3bc2fc472428 460 }
sefyou 0:3bc2fc472428 461 /***********************************SET VISITEUR*******************************/
sefyou 0:3bc2fc472428 462 if (data[0]=='S' && data[1]=='E' && data[2] =='T' && data[3] == 'V')
sefyou 0:3bc2fc472428 463 {
sefyou 0:3bc2fc472428 464 stockUNITEDOM= uniteDOM;
sefyou 0:3bc2fc472428 465 stockDIZAINEDOM= dizaineDOM;
sefyou 0:3bc2fc472428 466 stockCENTAINEDOM= centaineDOM;
sefyou 0:3bc2fc472428 467
sefyou 0:3bc2fc472428 468 stockUNITEVIS= uniteVIS;
sefyou 0:3bc2fc472428 469 stockDIZAINEVIS= dizaineVIS;
sefyou 0:3bc2fc472428 470 stockCENTAINEVIS= centaineVIS;
sefyou 0:3bc2fc472428 471
sefyou 0:3bc2fc472428 472 uniteDOM = 0;
sefyou 0:3bc2fc472428 473 dizaineDOM = 0;
sefyou 0:3bc2fc472428 474 centaineDOM = 0;
sefyou 0:3bc2fc472428 475 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 476
sefyou 0:3bc2fc472428 477 uniteVIS = 0;
sefyou 0:3bc2fc472428 478 dizaineVIS = 0;
sefyou 0:3bc2fc472428 479 centaineVIS = 0;
sefyou 0:3bc2fc472428 480 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 481 // INCREMENTER MATRICE DE LED
sefyou 0:3bc2fc472428 482 }
sefyou 0:3bc2fc472428 483 /***********************************SET ******************************
sefyou 0:3bc2fc472428 484 if (data[0]=='S' && data[1]=='E' && data[2] =='T' && data[3] == 'V')
sefyou 0:3bc2fc472428 485 {
sefyou 0:3bc2fc472428 486
sefyou 0:3bc2fc472428 487 }*/
sefyou 0:3bc2fc472428 488
sefyou 0:3bc2fc472428 489 /***********************************FIN DU MATCH*******************************/
sefyou 0:3bc2fc472428 490 if (data[0]=='F' && data[1]=='G' && data[2] =='A' && data[3] == 'M')
sefyou 0:3bc2fc472428 491 {
sefyou 0:3bc2fc472428 492 /* stockUNITEDOM= uniteDOM;
sefyou 0:3bc2fc472428 493 stockDIZAINEDOM= dizaineDOM;
sefyou 0:3bc2fc472428 494 stockCENTAINEDOM= centaineDOM;
sefyou 0:3bc2fc472428 495
sefyou 0:3bc2fc472428 496 stockUNITEVIS= uniteVIS;
sefyou 0:3bc2fc472428 497 stockDIZAINEVIS= dizaineVIS;
sefyou 0:3bc2fc472428 498 stockCENTAINEVIS= centaineVIS;*/
sefyou 0:3bc2fc472428 499
sefyou 0:3bc2fc472428 500 Buzzer = 1;
sefyou 0:3bc2fc472428 501 wait(1);
sefyou 0:3bc2fc472428 502 Buzzer = 0;
sefyou 0:3bc2fc472428 503 afficherDOM(display2, stockCENTAINEDOM, stockDIZAINEDOM, stockUNITEDOM);
sefyou 0:3bc2fc472428 504 afficherVIS(display3, stockCENTAINEVIS, stockDIZAINEVIS, stockUNITEVIS);
sefyou 0:3bc2fc472428 505 //FIN DU MATCH MATRICE A LED
sefyou 0:3bc2fc472428 506 }
sefyou 0:3bc2fc472428 507
sefyou 0:3bc2fc472428 508 /************************SCORE DOMICILE****************************************/
sefyou 0:3bc2fc472428 509 /*************************INCREMENTATION DOMICILE******************************/
sefyou 0:3bc2fc472428 510 if (data[0]=='S' && data[1]=='D' && data[2] =='+' && data[3] == '*')
sefyou 0:3bc2fc472428 511 {
sefyou 0:3bc2fc472428 512 uniteDOM++;
sefyou 0:3bc2fc472428 513 incrementeDOM = true;
sefyou 0:3bc2fc472428 514 }
sefyou 0:3bc2fc472428 515
sefyou 0:3bc2fc472428 516 if (data[0]=='S' && data[1]=='D' && data[2] =='+' && data[3] == '2')
sefyou 0:3bc2fc472428 517 {
sefyou 0:3bc2fc472428 518 uniteDOM+=2;
sefyou 0:3bc2fc472428 519 incrementeDOM = true;
sefyou 0:3bc2fc472428 520 }
sefyou 0:3bc2fc472428 521
sefyou 0:3bc2fc472428 522 if (data[0]=='S' && data[1]=='D' && data[2] =='+' && data[3] == '3')
sefyou 0:3bc2fc472428 523 {
sefyou 0:3bc2fc472428 524 uniteDOM+=3;
sefyou 0:3bc2fc472428 525 incrementeDOM = true;
sefyou 0:3bc2fc472428 526 }
sefyou 0:3bc2fc472428 527
sefyou 0:3bc2fc472428 528 if (data[0]=='S' && data[1]=='D' && data[2] =='+' && data[3] == '5')
sefyou 0:3bc2fc472428 529 {
sefyou 0:3bc2fc472428 530 uniteDOM+=5;
sefyou 0:3bc2fc472428 531 incrementeDOM = true;
sefyou 0:3bc2fc472428 532 }
sefyou 0:3bc2fc472428 533
sefyou 0:3bc2fc472428 534 if (data[0]=='S' && data[1]=='D' && data[2] =='+' && data[3] == '6')
sefyou 0:3bc2fc472428 535 {
sefyou 0:3bc2fc472428 536 uniteDOM+=6;
sefyou 0:3bc2fc472428 537 incrementeDOM = true;
sefyou 0:3bc2fc472428 538 }
sefyou 0:3bc2fc472428 539
sefyou 0:3bc2fc472428 540 if (data[0]=='S' && data[1]=='D' && data[2] =='1' && data[3] == '0')
sefyou 0:3bc2fc472428 541 {
sefyou 0:3bc2fc472428 542 dizaineDOM+=1;
sefyou 0:3bc2fc472428 543 incrementeDOM = true;
sefyou 0:3bc2fc472428 544 }
sefyou 0:3bc2fc472428 545
sefyou 0:3bc2fc472428 546 if (data[0]=='S' && data[1]=='D' && data[2] =='1' && data[3] == '5')
sefyou 0:3bc2fc472428 547 {
sefyou 0:3bc2fc472428 548 dizaineDOM+=1;
sefyou 0:3bc2fc472428 549 uniteDOM+=5;
sefyou 0:3bc2fc472428 550 incrementeDOM = true;
sefyou 0:3bc2fc472428 551 }
sefyou 0:3bc2fc472428 552
sefyou 0:3bc2fc472428 553 if(incrementeDOM)//SI UNE MODIFICATIONS EST FAITE FALSE DEVIENT TRUE ET RENTRE DANS LA FONCTION
sefyou 0:3bc2fc472428 554 {
sefyou 0:3bc2fc472428 555 calculIncremente(&centaineDOM, &dizaineDOM, &uniteDOM);
sefyou 0:3bc2fc472428 556 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 557 }
sefyou 0:3bc2fc472428 558
sefyou 0:3bc2fc472428 559 /************************SCORE DOMICILE****************************************/
sefyou 0:3bc2fc472428 560 /*************************DECREMENTATION DOMICILE******************************/
sefyou 0:3bc2fc472428 561
sefyou 0:3bc2fc472428 562 if (data[0]=='S' && data[1]=='D' && data[2] =='-' && data[3] == '*')
sefyou 0:3bc2fc472428 563 {
sefyou 0:3bc2fc472428 564 uniteDOM -= 1;
sefyou 0:3bc2fc472428 565 decrementeDOM = true;
sefyou 0:3bc2fc472428 566 }
sefyou 0:3bc2fc472428 567
sefyou 0:3bc2fc472428 568 if (data[0]=='S' && data[1]=='D' && data[2] =='-' && data[3] == '2')
sefyou 0:3bc2fc472428 569 {
sefyou 0:3bc2fc472428 570 uniteDOM -= 2;
sefyou 0:3bc2fc472428 571 decrementeDOM = true;
sefyou 0:3bc2fc472428 572 }
sefyou 0:3bc2fc472428 573
sefyou 0:3bc2fc472428 574 if (data[0]=='S' && data[1]=='D' && data[2] =='-' && data[3] == '3')
sefyou 0:3bc2fc472428 575 {
sefyou 0:3bc2fc472428 576 uniteDOM -= 3;
sefyou 0:3bc2fc472428 577 decrementeDOM = true;
sefyou 0:3bc2fc472428 578 }
sefyou 0:3bc2fc472428 579
sefyou 0:3bc2fc472428 580 if (data[0]=='S' && data[1]=='D' && data[2] =='-' && data[3] == '5')
sefyou 0:3bc2fc472428 581 {
sefyou 0:3bc2fc472428 582 uniteDOM -= 5;
sefyou 0:3bc2fc472428 583 decrementeDOM = true;
sefyou 0:3bc2fc472428 584 }
sefyou 0:3bc2fc472428 585
sefyou 0:3bc2fc472428 586 if (data[0]=='S' && data[1]=='D' && data[2] =='-' && data[3] == '6')
sefyou 0:3bc2fc472428 587 {
sefyou 0:3bc2fc472428 588 uniteDOM -= 6;
sefyou 0:3bc2fc472428 589 decrementeDOM = true;
sefyou 0:3bc2fc472428 590 }
sefyou 0:3bc2fc472428 591
sefyou 0:3bc2fc472428 592 if (data[0]=='S' && data[1]=='D' && data[2] =='1' && data[3] == '0')
sefyou 0:3bc2fc472428 593 {
sefyou 0:3bc2fc472428 594 dizaineDOM -= 1;
sefyou 0:3bc2fc472428 595 decrementeDOM = true;
sefyou 0:3bc2fc472428 596 }
sefyou 0:3bc2fc472428 597
sefyou 0:3bc2fc472428 598 if (data[0]=='S' && data[1]=='D' && data[2] =='1' && data[3] == '5')
sefyou 0:3bc2fc472428 599 {
sefyou 0:3bc2fc472428 600 dizaineDOM -= 1;
sefyou 0:3bc2fc472428 601 uniteDOM -=5;
sefyou 0:3bc2fc472428 602 decrementeDOM = true;
sefyou 0:3bc2fc472428 603 }
sefyou 0:3bc2fc472428 604 if(decrementeDOM)//SI UNE MODIFICATIONS EST FAITE FALSE DEVIENT TRUE ET RENTRE DANS LA FONCTION
sefyou 0:3bc2fc472428 605 {
sefyou 0:3bc2fc472428 606 calculDecremente(&centaineDOM, &dizaineDOM, &uniteDOM);
sefyou 0:3bc2fc472428 607 afficherDOM(display2, centaineDOM, dizaineDOM, uniteDOM);
sefyou 0:3bc2fc472428 608 }
sefyou 0:3bc2fc472428 609
sefyou 0:3bc2fc472428 610 /************************SCORE VIVITEUR****************************************/
sefyou 0:3bc2fc472428 611 /*************************INCREMENTATION VISITEUR******************************/
sefyou 0:3bc2fc472428 612 if (data[0]=='S' && data[1]=='V' && data[2] =='+' && data[3] == '*')
sefyou 0:3bc2fc472428 613 {
sefyou 0:3bc2fc472428 614 uniteVIS++;
sefyou 0:3bc2fc472428 615 incrementeVIS = true;
sefyou 0:3bc2fc472428 616 }
sefyou 0:3bc2fc472428 617
sefyou 0:3bc2fc472428 618 if (data[0]=='S' && data[1]=='V' && data[2] =='+' && data[3] == '2')
sefyou 0:3bc2fc472428 619 {
sefyou 0:3bc2fc472428 620 uniteVIS+=2;
sefyou 0:3bc2fc472428 621 incrementeVIS = true;
sefyou 0:3bc2fc472428 622 }
sefyou 0:3bc2fc472428 623
sefyou 0:3bc2fc472428 624 if (data[0]=='S' && data[1]=='V' && data[2] =='+' && data[3] == '3')
sefyou 0:3bc2fc472428 625 {
sefyou 0:3bc2fc472428 626 uniteVIS+=3;
sefyou 0:3bc2fc472428 627 incrementeVIS = true;
sefyou 0:3bc2fc472428 628 }
sefyou 0:3bc2fc472428 629
sefyou 0:3bc2fc472428 630 if (data[0]=='S' && data[1]=='V' && data[2] =='+' && data[3] == '5')
sefyou 0:3bc2fc472428 631 {
sefyou 0:3bc2fc472428 632 uniteVIS+=5;
sefyou 0:3bc2fc472428 633 incrementeVIS = true;
sefyou 0:3bc2fc472428 634 }
sefyou 0:3bc2fc472428 635
sefyou 0:3bc2fc472428 636 if (data[0]=='S' && data[1]=='V' && data[2] =='+' && data[3] == '6')
sefyou 0:3bc2fc472428 637 {
sefyou 0:3bc2fc472428 638 uniteVIS+=6;
sefyou 0:3bc2fc472428 639 incrementeVIS = true;
sefyou 0:3bc2fc472428 640 }
sefyou 0:3bc2fc472428 641
sefyou 0:3bc2fc472428 642 if (data[0]=='S' && data[1]=='V' && data[2] =='1' && data[3] == '0')
sefyou 0:3bc2fc472428 643 {
sefyou 0:3bc2fc472428 644 dizaineVIS+=1;
sefyou 0:3bc2fc472428 645 incrementeVIS = true;
sefyou 0:3bc2fc472428 646 }
sefyou 0:3bc2fc472428 647
sefyou 0:3bc2fc472428 648 if (data[0]=='S' && data[1]=='V' && data[2] =='1' && data[3] == '5')
sefyou 0:3bc2fc472428 649 {
sefyou 0:3bc2fc472428 650 dizaineVIS+=1;
sefyou 0:3bc2fc472428 651 uniteVIS+=5;
sefyou 0:3bc2fc472428 652 incrementeVIS = true;
sefyou 0:3bc2fc472428 653 }
sefyou 0:3bc2fc472428 654
sefyou 0:3bc2fc472428 655 if(incrementeVIS)
sefyou 0:3bc2fc472428 656 {
sefyou 0:3bc2fc472428 657 calculIncremente(&centaineVIS, &dizaineVIS, &uniteVIS);
sefyou 0:3bc2fc472428 658 afficherVIS(display3, centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 659 }
sefyou 0:3bc2fc472428 660 /*************************DECREMENTATION VISITEUR******************************/
sefyou 0:3bc2fc472428 661 if (data[0]=='S' && data[1]=='V' && data[2] =='-' && data[3] == '*')
sefyou 0:3bc2fc472428 662 {
sefyou 0:3bc2fc472428 663 uniteVIS -= 1;
sefyou 0:3bc2fc472428 664 decrementeVIS = true;
sefyou 0:3bc2fc472428 665 }
sefyou 0:3bc2fc472428 666
sefyou 0:3bc2fc472428 667 if (data[0]=='S' && data[1]=='V' && data[2] =='-' && data[3] == '2')
sefyou 0:3bc2fc472428 668 {
sefyou 0:3bc2fc472428 669 uniteVIS -= 2;
sefyou 0:3bc2fc472428 670 decrementeVIS = true;
sefyou 0:3bc2fc472428 671 }
sefyou 0:3bc2fc472428 672
sefyou 0:3bc2fc472428 673 if (data[0]=='S' && data[1]=='V' && data[2] =='-' && data[3] == '3')
sefyou 0:3bc2fc472428 674 {
sefyou 0:3bc2fc472428 675 uniteVIS -= 3;
sefyou 0:3bc2fc472428 676 decrementeVIS = true;
sefyou 0:3bc2fc472428 677 }
sefyou 0:3bc2fc472428 678
sefyou 0:3bc2fc472428 679 if (data[0]=='S' && data[1]=='V' && data[2] =='-' && data[3] == '5')
sefyou 0:3bc2fc472428 680 {
sefyou 0:3bc2fc472428 681 uniteVIS -= 5;
sefyou 0:3bc2fc472428 682 decrementeVIS = true;
sefyou 0:3bc2fc472428 683 }
sefyou 0:3bc2fc472428 684
sefyou 0:3bc2fc472428 685 if (data[0]=='S' && data[1]=='V' && data[2] =='-' && data[3] == '6')
sefyou 0:3bc2fc472428 686 {
sefyou 0:3bc2fc472428 687 uniteVIS -= 6;
sefyou 0:3bc2fc472428 688 decrementeVIS = true;
sefyou 0:3bc2fc472428 689 }
sefyou 0:3bc2fc472428 690
sefyou 0:3bc2fc472428 691 if (data[0]=='S' && data[1]=='V' && data[2] =='1' && data[3] == '0')
sefyou 0:3bc2fc472428 692 {
sefyou 0:3bc2fc472428 693 dizaineVIS -= 1;
sefyou 0:3bc2fc472428 694 decrementeVIS = true;
sefyou 0:3bc2fc472428 695 }
sefyou 0:3bc2fc472428 696
sefyou 0:3bc2fc472428 697 if (data[0]=='S' && data[1]=='V' && data[2] =='1' && data[3] == '5')
sefyou 0:3bc2fc472428 698 {
sefyou 0:3bc2fc472428 699 dizaineVIS -= 1;
sefyou 0:3bc2fc472428 700 uniteVIS -= 5;
sefyou 0:3bc2fc472428 701 decrementeVIS = true;
sefyou 0:3bc2fc472428 702 }
sefyou 0:3bc2fc472428 703
sefyou 0:3bc2fc472428 704 if(decrementeVIS)
sefyou 0:3bc2fc472428 705 {
sefyou 0:3bc2fc472428 706 calculDecremente(&centaineVIS, &dizaineVIS, &uniteVIS);
sefyou 0:3bc2fc472428 707 afficherVIS(display3,centaineVIS, dizaineVIS, uniteVIS);
sefyou 0:3bc2fc472428 708 }
sefyou 0:3bc2fc472428 709 /****************************PLAY CHRONOMETRE**********************************/
sefyou 0:3bc2fc472428 710 /*if (data[0]=='P' && data[1]=='L' && data[2] =='C' && data[3] == 'H')
sefyou 0:3bc2fc472428 711 {
sefyou 0:3bc2fc472428 712 //play_chrono(display,&u_second,&d_second,&u_minute,&d_minute);
sefyou 0:3bc2fc472428 713 //affiche_chrono(display,u_second,d_second,u_minute,d_minute);
sefyou 0:3bc2fc472428 714 }*/
sefyou 0:3bc2fc472428 715
sefyou 0:3bc2fc472428 716 /****************************PLAY CHRONOMETRE**********************************/
sefyou 0:3bc2fc472428 717 if (data[0]=='P' && data[1]=='L' && data[2] =='C' && data[3] == 'H') //play
sefyou 0:3bc2fc472428 718 {
sefyou 0:3bc2fc472428 719
sefyou 0:3bc2fc472428 720
sefyou 0:3bc2fc472428 721 /*Buzzer = 1;
sefyou 0:3bc2fc472428 722 wait(1);
sefyou 0:3bc2fc472428 723 Buzzer = 0;*/
sefyou 0:3bc2fc472428 724 //server.receiveFrom(client, data, sizeof(data));
sefyou 0:3bc2fc472428 725 chrono=1;
sefyou 0:3bc2fc472428 726
sefyou 0:3bc2fc472428 727
sefyou 0:3bc2fc472428 728
sefyou 0:3bc2fc472428 729 /*stockd_minute = d_minute;
sefyou 0:3bc2fc472428 730 stocku_minute = u_minute;
sefyou 0:3bc2fc472428 731 stockd_second = d_second;
sefyou 0:3bc2fc472428 732 stocku_second = u_second;*/
sefyou 0:3bc2fc472428 733
sefyou 0:3bc2fc472428 734 /* if (u_second >= 10) //si unité seconde suppérieur ou égale a 9
sefyou 0:3bc2fc472428 735 {
sefyou 0:3bc2fc472428 736 d_second++; //dizaine seconde sera égale a dizaine seconde +1
sefyou 0:3bc2fc472428 737 u_second =0; //unité seconde sera égale a 0
sefyou 0:3bc2fc472428 738 }
sefyou 0:3bc2fc472428 739 if (d_second >= 6) //si dizaine seconde suppérieur ou égale a 6 (60secondes)
sefyou 0:3bc2fc472428 740 {
sefyou 0:3bc2fc472428 741 d_second =0; //dizaine seconde sera égale a 0
sefyou 0:3bc2fc472428 742 u_second =0; //unité seconde sera égale a 0
sefyou 0:3bc2fc472428 743 u_minute ++; //unité minute sera égale a unité minute +1
sefyou 0:3bc2fc472428 744 }
sefyou 0:3bc2fc472428 745 if (u_minute >= 10)
sefyou 0:3bc2fc472428 746 {
sefyou 0:3bc2fc472428 747 u_minute=0;
sefyou 0:3bc2fc472428 748 d_minute++;
sefyou 0:3bc2fc472428 749 }
sefyou 0:3bc2fc472428 750 display.write_chronometre_4(d_minute,0);
sefyou 0:3bc2fc472428 751 display.write_chronometre_3(u_minute,0);
sefyou 0:3bc2fc472428 752 display.write_chronometre_2(d_second,0);
sefyou 0:3bc2fc472428 753 display.write_chronometre(u_second,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 754 wait(1);
sefyou 0:3bc2fc472428 755 u_second++;
sefyou 0:3bc2fc472428 756 server.receiveFrom(client, data, sizeof(data)); */
sefyou 0:3bc2fc472428 757
sefyou 0:3bc2fc472428 758 }
sefyou 0:3bc2fc472428 759 /****************************RESET CHRONOMETRE*********************************/
sefyou 0:3bc2fc472428 760 if (data[0]=='R' && data[1]=='C' && data[2] =='H' && data[3] == '*') //reset
sefyou 0:3bc2fc472428 761 {
sefyou 0:3bc2fc472428 762
sefyou 0:3bc2fc472428 763 chrono=3;
sefyou 0:3bc2fc472428 764 /*u_second = 0;
sefyou 0:3bc2fc472428 765 d_second = 0;
sefyou 0:3bc2fc472428 766 u_minute = 0;
sefyou 0:3bc2fc472428 767 d_minute = 0;
sefyou 0:3bc2fc472428 768 stockd_minute = 0;
sefyou 0:3bc2fc472428 769 stocku_minute = 0;
sefyou 0:3bc2fc472428 770 stockd_second = 0;
sefyou 0:3bc2fc472428 771 stocku_second = 0;
sefyou 0:3bc2fc472428 772
sefyou 0:3bc2fc472428 773
sefyou 0:3bc2fc472428 774 display.write_chronometre_4(d_minute,0);
sefyou 0:3bc2fc472428 775 display.write_chronometre_3(u_minute,0);
sefyou 0:3bc2fc472428 776 display.write_chronometre_2(d_second,0);
sefyou 0:3bc2fc472428 777 display.write_chronometre(u_second,0); // le 0 c'est le dp il es tjf off
sefyou 0:3bc2fc472428 778 */
sefyou 0:3bc2fc472428 779
sefyou 0:3bc2fc472428 780 }
sefyou 0:3bc2fc472428 781 /****************************PAUSE CHRONOMETRE**********************************/
sefyou 0:3bc2fc472428 782 if (data[0]=='P' && data[1]=='C' && data[2] =='H' && data[3] == '*') //pause
sefyou 0:3bc2fc472428 783 {
sefyou 0:3bc2fc472428 784
sefyou 0:3bc2fc472428 785 chrono=2;
sefyou 0:3bc2fc472428 786
sefyou 0:3bc2fc472428 787
sefyou 0:3bc2fc472428 788 /*stockd_minute = d_minute;
sefyou 0:3bc2fc472428 789 stocku_minute = u_minute;
sefyou 0:3bc2fc472428 790 stockd_second = d_second;
sefyou 0:3bc2fc472428 791 stocku_second = u_second;
sefyou 0:3bc2fc472428 792
sefyou 0:3bc2fc472428 793 display.write_chronometre_4(stockd_minute,0);
sefyou 0:3bc2fc472428 794 display.write_chronometre_3(stocku_minute,0);
sefyou 0:3bc2fc472428 795 display.write_chronometre_2(stockd_second,0);
sefyou 0:3bc2fc472428 796 display.write_chronometre(stocku_second,0); // le 0 c'est le dp il es tjf off */
sefyou 0:3bc2fc472428 797 }
sefyou 0:3bc2fc472428 798
sefyou 0:3bc2fc472428 799 if (data[0]=='F' && data[1]=='P' && data[2] =='E' && data[3] == 'R') //FPERIODE
sefyou 0:3bc2fc472428 800 {
sefyou 0:3bc2fc472428 801 chrono=2;
sefyou 0:3bc2fc472428 802 Buzzer = 1;
sefyou 0:3bc2fc472428 803 wait(1);
sefyou 0:3bc2fc472428 804 Buzzer = 0;
sefyou 0:3bc2fc472428 805 }
sefyou 0:3bc2fc472428 806
sefyou 0:3bc2fc472428 807 switch(chrono)
sefyou 0:3bc2fc472428 808 {
sefyou 0:3bc2fc472428 809 case 1:
sefyou 0:3bc2fc472428 810 playchrono(display,&u_second,&d_second,&u_minute,&d_minute);
sefyou 0:3bc2fc472428 811 /* data[1] =0; //changer la data. serveur non blokant */
sefyou 0:3bc2fc472428 812 break;
sefyou 0:3bc2fc472428 813 case 2:
sefyou 0:3bc2fc472428 814 pausechrono(display,&u_second,&d_second,&u_minute,&d_minute);
sefyou 0:3bc2fc472428 815 break;
sefyou 0:3bc2fc472428 816 case 3:
sefyou 0:3bc2fc472428 817 resetchrono(display,&u_second,&d_second,&u_minute,&d_minute);
sefyou 0:3bc2fc472428 818 break;
sefyou 0:3bc2fc472428 819 default:
sefyou 0:3bc2fc472428 820 pausechrono(display,&u_second,&d_second,&u_minute,&d_minute);
sefyou 0:3bc2fc472428 821 }
sefyou 0:3bc2fc472428 822
sefyou 0:3bc2fc472428 823 } // ferme le whimle
sefyou 0:3bc2fc472428 824 } // ferme le int
sefyou 0:3bc2fc472428 825