2a
Dependencies: BSP_DISCO_F429ZI LCD_DISCO_F429ZI TS_DISCO_F429ZI mbed
Revision 0:6d8b197659af, committed 2017-05-05
- Comitter:
- Robsonik16
- Date:
- Fri May 05 19:30:39 2017 +0000
- Commit message:
- a
Changed in this revision
diff -r 000000000000 -r 6d8b197659af BSP_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F429ZI.lib Fri May 05 19:30:39 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F429ZI/#de9280158372
diff -r 000000000000 -r 6d8b197659af LCD_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Fri May 05 19:30:39 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 000000000000 -r 6d8b197659af TS_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F429ZI.lib Fri May 05 19:30:39 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F429ZI/#4f8b6df8e235
diff -r 000000000000 -r 6d8b197659af main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 05 19:30:39 2017 +0000 @@ -0,0 +1,90 @@ +#include "mbed.h" +#include "TS_DISCO_F429ZI.h" +#include "LCD_DISCO_F429ZI.h" + +LCD_DISCO_F429ZI lcd; +TS_DISCO_F429ZI ts; +bool touchInRect(uint16_t TouchXpos, uint16_t TouchYpos,uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) +{ + if((TouchXpos>=Xpos)&&(TouchXpos<=Xpos+Width)&&(TouchYpos>=Ypos)&&(TouchYpos<=Ypos+Height))return (true); + else return(false); +} + +void drawNumber() +{ + uint8_t text[3]; + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.SetBackColor(LCD_COLOR_RED); + for(uint8_t i=0; i<4; i++) { + sprintf((char*)text, "%d", i); + lcd.DisplayStringAt(0, 0+i*80, (uint8_t *)&text, LEFT_MODE); + } + lcd.SetBackColor(LCD_COLOR_BLACK); +} +int main() +{ + TS_StateTypeDef TS_State; + uint16_t x, y; + uint8_t text[30]; + uint8_t status; + bool UpdateAfterTouch=true; + + BSP_LCD_SetFont(&Font20); + + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN", CENTER_MODE); + lcd.DisplayStringAt(0, LINE(6), (uint8_t *)"DEMO", CENTER_MODE); + wait_ms(500); + + 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_ms(500); + + + lcd.Clear(LCD_COLOR_BLACK); + lcd.SetBackColor(LCD_COLOR_BLACK); + lcd.SetTextColor(LCD_COLOR_GREEN); + + for(uint8_t i=0; i<4; i++) + lcd.DrawRect(0,0+80*i,80,80); + + lcd.SetFont(&Font24); + + while(1) { + wait_ms(100); + + + ts.GetState(&TS_State); + if (TS_State.TouchDetected) { + UpdateAfterTouch=true; + x = TS_State.X; + y = TS_State.Y; + lcd.SetTextColor(LCD_COLOR_GREEN); + for(uint8_t i=0; i<4; i++) + if(touchInRect(x,y,1,1+80*i,79,79)) + lcd.FillRect(1,1+80*i,79,79); + drawNumber(); + } else if(UpdateAfterTouch == true) { + UpdateAfterTouch=false; + lcd.SetTextColor(LCD_COLOR_BLUE); + for(uint8_t i=0; i<4; i++) + lcd.FillRect(1,1+80*i,79,79); + drawNumber(); + } + + + } +}
diff -r 000000000000 -r 6d8b197659af mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 05 19:30:39 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file