Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG
Revision 5:2756abb97c4d, committed 2019-06-07
- Comitter:
- Antoine98
- Date:
- Fri Jun 07 08:00:40 2019 +0000
- Parent:
- 4:abedada304bf
- Commit message:
- FINAL
Changed in this revision
diff -r abedada304bf -r 2756abb97c4d BSP_DISCO_F746NG.lib --- a/BSP_DISCO_F746NG.lib Thu Jun 08 13:47:01 2017 +0000 +++ b/BSP_DISCO_F746NG.lib Fri Jun 07 08:00:40 2019 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#56384bddaba5 +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#df2ea349c37a
diff -r abedada304bf -r 2756abb97c4d TS_DISCO_F746NG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F746NG.lib Fri Jun 07 08:00:40 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
diff -r abedada304bf -r 2756abb97c4d main.cpp --- a/main.cpp Thu Jun 08 13:47:01 2017 +0000 +++ b/main.cpp Fri Jun 07 08:00:40 2019 +0000 @@ -1,46 +1,162 @@ #include "mbed.h" #include "LCD_DISCO_F746NG.h" +#include "TS_DISCO_F746NG.h" +AnalogIn xAxis(A0); +AnalogIn yAxis(A2); + +int x,y,button,x_touch,y_touch; // global variables to hold values +Ticker joystick; // recurring interrupt to get joystick data*/ +TS_DISCO_F746NG ts; LCD_DISCO_F746NG lcd; +Serial pc(USBTX, USBRX); + +#define MAX 10 + +float Xaxe; +float Yaxe; + +float position_x = 0; +float position_y = 0; + +TS_StateTypeDef TS_State; + +const char laby[11][11] = { + "**********", + "* * * *", + "* ***** **", + "* *", + "****** ***", + "* **", + "* ** * * *", + "* ** *** *", + "* * F", + "**********", + }; + //largeur 450 + //hauteur 250 +bool debut = false; +bool win; +int idx = 0; +uint8_t init; +void TryMove(int* joueurX,int* joueurY,int vx,int vy) +{ + if (laby[*joueurY+vy][*joueurX+vx]=='*') + return; + (*joueurX)+=vx; + (*joueurY)+=vy; +} + + -DigitalOut led1(LED1); +void Afficher(int joueurX,int joueurY) +{ + for (int i = 0; i < MAX; i++) { + for (int j = 0; j < MAX; j++) { + if (j == joueurX && i == joueurY) { + // lcd.DisplayChar(x + (48 / 2) - 8, y + (27 / 2) - 8, ''); + lcd.DrawRect(x +(48 / 2) - 8, y + (27 / 2) - 8, 10, 10); + } + if (laby[i][j] == '*') { + lcd.DrawRect(x, y, 48, 27); + } + if (laby[i][j] == 'F') { + lcd.DrawCircle(x + 48 / 2, y + 27 / 2, 13); + } + + x += 48; + } + y += 27; + x = 0; + } + y=0; +} +/*********************/ +void menu_jeu() +{ + + lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Voici le jeu LabyLaby", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Debut du jeu", CENTER_MODE); + +while(debut == false) + { +ts.GetState(&TS_State); + if (TS_State.touchDetected) + { + x = TS_State.touchX[idx]; + y = TS_State.touchY[idx]; + if ((x>10)&&(x<300)&&(y>10)&&(y<300)) + { + debut = true; + + } + + } + } + } + +/********************/ int main() { - led1 = 1; - - lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE); - wait(1); - - while(1) - { - lcd.Clear(LCD_COLOR_BLUE); - lcd.SetBackColor(LCD_COLOR_BLUE); +menu_jeu(); + int joueurX = 1, joueurY = 1,xtouch,ytouch; + + lcd.Clear(LCD_COLOR_BLACK); + lcd.SetBackColor(LCD_COLOR_BLACK); lcd.SetTextColor(LCD_COLOR_WHITE); - wait(0.3); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"DISCOVERY STM32F746NG", CENTER_MODE); - wait(1); - lcd.Clear(LCD_COLOR_GREEN); - - lcd.SetTextColor(LCD_COLOR_BLUE); - lcd.DrawRect(10, 20, 50, 50); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_BROWN); - lcd.DrawCircle(80, 80, 50); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_YELLOW); - lcd.DrawEllipse(150, 150, 50, 100); - wait(0.1); - lcd.SetTextColor(LCD_COLOR_RED); - lcd.FillCircle(200, 200, 40); - wait(1); - - lcd.SetBackColor(LCD_COLOR_ORANGE); - lcd.SetTextColor(LCD_COLOR_CYAN); - lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"HAVE FUN !!!", CENTER_MODE); - wait(1); - - led1 = !led1; +while(debut == true) +{ + Xaxe=xAxis.read(); + Yaxe=yAxis.read(); +//En bas + if((Xaxe > 0.73) && (Xaxe < 0.78) && (Yaxe > 0.33) && (Yaxe < 0.36)) { + /*lcd.FillRect(position_x - 0.5, position_y - 0.5, 10, 10); + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.FillRect(position_x , position_y, 10, 10); + position_y = position_y + 10;*/ + lcd.Clear(LCD_COLOR_BLACK); + TryMove(&joueurX,&joueurY,0,-1); + wait_ms(250); + } +//A droite + if((Yaxe > 0.7) && (Yaxe < 0.78) && (Xaxe > 0.3) && (Xaxe < 0.4)) { + /*lcd.FillRect(position_x - 0.5, position_y - 0.5, 10, 10); + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.FillRect(position_x , position_y, 10, 10); + position_x = position_x + 10;*/ + lcd.Clear(LCD_COLOR_BLACK); + TryMove(&joueurX,&joueurY,-1,0); + wait_ms(250); + } +//A gauche + if((Yaxe > 0.6) && (Yaxe < 0.8) && (Xaxe == 1)) { + /*lcd.FillRect(position_x - 0.5, position_y, 10, 10); + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.FillRect(position_x + 1, position_y, 10, 10); + position_x = position_x - 10;*/ + lcd.Clear(LCD_COLOR_BLACK); + TryMove(&joueurX,&joueurY,1,0); + wait_ms(250); + } +//En haut + if((Xaxe > 0.6) && (Xaxe < 0.8) && (Yaxe == 1)) { + /*lcd.FillRect(position_x, position_y - 0.5, 10, 10); + lcd.SetTextColor(LCD_COLOR_GREEN); + lcd.FillRect(position_x, position_y + 1, 10, 10); + position_y = position_y - 10;*/ + lcd.Clear(LCD_COLOR_BLACK); + TryMove(&joueurX,&joueurY,0,1); + wait_ms(250); + } + Afficher(joueurX,joueurY); + if ((joueurX == 9) && (joueurY == 8)) + { + lcd.Clear(LCD_COLOR_BLACK); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"BRAVO T'AS GAGNE YOUHOU", CENTER_MODE); + debut = false; + + } } -} + }
diff -r abedada304bf -r 2756abb97c4d mbed.bld --- a/mbed.bld Thu Jun 08 13:47:01 2017 +0000 +++ b/mbed.bld Fri Jun 07 08:00:40 2019 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file