
Proj3Kornreich
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Revision 0:77c6d064a44f, committed 2021-11-15
- Comitter:
- wkornreich
- Date:
- Mon Nov 15 06:10:23 2021 +0000
- Commit message:
- FinalOfProj3;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#53d9067a4feb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,114 @@ +#include "mbed.h" +#include "TS_DISCO_F429ZI.h" +#include "LCD_DISCO_F429ZI.h" + +LCD_DISCO_F429ZI lcd; +TS_DISCO_F429ZI ts; + +uint16_t winningSection = 1; +uint32_t counter1 = 0; + + +extern "C" void AddOne(uint32_t *); +extern "C" bool compare(uint32_t *, uint16_t *); + +InterruptIn user_button(USER_BUTTON); + +void button_pressed() { + lcd.Clear(LCD_COLOR_BLUE); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + wait(.5); + lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"RESETING", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"GAME", CENTER_MODE); + wait(1); + lcd.Clear(LCD_COLOR_BLUE); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + wait(.5); + winningSection = rand()%3+1; + lcd.Clear(LCD_COLOR_BLUE); + lcd.SetBackColor(LCD_COLOR_BLUE); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.FillRect(0, 105, 240, 2); + lcd.FillRect(0, 212, 240, 2); + } + + +void button_released() +{ + +} + +int main() +{ + + user_button.rise(&button_pressed); + user_button.fall(&button_released); + + TS_StateTypeDef TS_State; + uint16_t x, y; + uint8_t text[30]; + uint8_t status; + + BSP_LCD_SetFont(&Font20); + + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"KORNREICH GAMES!", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"Try and Win!", CENTER_MODE); + + wait(1); + + status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); + + if (status != TS_OK) + { + lcd.Clear(LCD_COLOR_RED); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT FAIL", CENTER_MODE); + } + else + { + lcd.Clear(LCD_COLOR_GREEN); + lcd.SetBackColor(LCD_COLOR_GREEN); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"INIT OK", CENTER_MODE); + } + + wait(1); + lcd.Clear(LCD_COLOR_BLUE); + lcd.SetBackColor(LCD_COLOR_BLUE); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.FillRect(0, 105, 240, 2); + lcd.FillRect(0, 212, 240, 2); + + while(1) + { + + + ts.GetState(&TS_State); + if (TS_State.TouchDetected) + { + x = TS_State.X; + y = TS_State.Y; + sprintf((char*)text, "x=%d y=%d ", x, y); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + + bool winner = compare((uint32_t *) &winningSection,(uint16_t *) &y); + + + + if(winner) { + + sprintf((char*)text, "You WIN!"); + lcd.DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE); + } + else{ + sprintf((char*)text, "You Lose!"); + lcd.DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myAsm.S Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,16 @@ + AREA myAsm, CODE, READONLY + GLOBAL AddOne + + ; void AddOne(uint32_t *) +AddOne LDR R1,[R0] + ADD R1,R1,#1 + STR R1,[R0] + BX LR + + GLOBAL AddTwo + + ; uint32_t AddOne(uint32_t) +AddTwo ADD R0,R0,#2 + BX LR + + END \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/myAss.S Mon Nov 15 06:10:23 2021 +0000 @@ -0,0 +1,26 @@ + AREA myAss, CODE, READONLY + GLOBAL compare + + ; bool compare(uint32_t *, uint16_t *) +compare LDR R2,[R0]; screen section + LDRH R3,[R1]; Y position + + + MOV R1, #106; 1/3 of y length of screen + MUL R2, R1, R2 + + CMP R3, R2 ; return true if screen section is withing the 1/3 of the screen selected. + + MOV R0, #1 + MOVGE R0, #0 + SUB R2, R2, R1 + CMP R3, R2 + MOVLE R0, #0 + + + + + BX LR + + + END \ No newline at end of file