Last
Dependencies: BLE_API HCSR04 X_NUCLEO_IDB0XA1 mbed
Fork of contest_IOT5 by
Revision 7:fd3602c86d75, committed 2015-11-04
- Comitter:
- Alex_Hochart
- Date:
- Wed Nov 04 15:29:42 2015 +0000
- Parent:
- 6:55319ed07a08
- Commit message:
- Last But LASt de chez Last version
Changed in this revision
display.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/display.h Wed Nov 04 15:02:59 2015 +0000 +++ b/display.h Wed Nov 04 15:29:42 2015 +0000 @@ -100,4 +100,37 @@ } +int print_ball(Serial &pc, int *distance1, int *distance2, double *posBallX, double *posBallY){ + pc.printf("\033[%d;%dH",(int)*posBallY, (int)*posBallX); //Place le curseur à 0:0 + pc.printf(" "); //Place le curseur à 0:0 + if(*posBallY <= 50){ + if(*distance1 <= 10){ + *posBallX = 4; + } + else if(*distance1 >= 34){ + *posBallX = 27; + } + else{ + *posBallX = *distance1; + } + } + else + { + if(*distance2 <= 10){ + *posBallX = 4; + } + else if(*distance2 >= 34){ + *posBallX = 27; + } + else{ + *posBallX = *distance2; + } + } + pc.printf("\033[%d;%dH",(int)*posBallY, (int)*posBallX); //Place le curseur à 0:0 + pc.printf("o"); //Place le curseur à 0:0 + return 3; +} + + + #endif \ No newline at end of file
--- a/main.cpp Wed Nov 04 15:02:59 2015 +0000 +++ b/main.cpp Wed Nov 04 15:29:42 2015 +0000 @@ -102,6 +102,24 @@ case 0 : if(bp.read() != 1){ jeu.state = 3; pong_init_ttempro(pc); + } + break; + + case 4 : for(int i=0; i<=29; i++){ + jeu.pos1prec[i]= jeu.pos1[i]; + jeu.pos2prec[i]= jeu.pos2[i]; + jeu.pos1[i]= 0; + jeu.pos2[i]= 0; + } + jeu.distance1 = sensor1.distance(1); + jeu.distance2 = sensor2.distance(1); + set_pos_vector(jeu.pos1,jeu.distance1); + set_pos_vector(jeu.pos2,jeu.distance2); + print_cursor_ttempro(pc,jeu.pos1,jeu.pos1prec,jeu.pos2,jeu.pos2prec); + print_ball(pc,&jeu.distance1,&jeu.distance2,&jeu.posBallX,&jeu.posBallY); + if(bp.read() != 1){ + jeu.state = 3; + pong_init_ttempro(pc); jeu.setChronoActive(); } break;