1
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG mbed
Revision 0:8f0206e51e1b, committed 2016-03-15
- Comitter:
- love750s
- Date:
- Tue Mar 15 00:48:41 2016 +0000
- Commit message:
- 1
Changed in this revision
diff -r 000000000000 -r 8f0206e51e1b BSP_DISCO_F746NG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F746NG.lib Tue Mar 15 00:48:41 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#ee089790cdbb
diff -r 000000000000 -r 8f0206e51e1b LCD_DISCO_F746NG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F746NG.lib Tue Mar 15 00:48:41 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
diff -r 000000000000 -r 8f0206e51e1b TS_DISCO_F746NG.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F746NG.lib Tue Mar 15 00:48:41 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
diff -r 000000000000 -r 8f0206e51e1b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 15 00:48:41 2016 +0000 @@ -0,0 +1,73 @@ +#include "mbed.h" +#include "TS_DISCO_F746NG.h" +#include "LCD_DISCO_F746NG.h" + +LCD_DISCO_F746NG lcd; +TS_DISCO_F746NG ts; + +int main() +{ + TS_StateTypeDef TS_State; + uint16_t x, y; + uint8_t text[30]; + uint8_t status; + uint8_t idx; + uint8_t cleared = 0; + uint8_t prev_nb_touches = 0; + + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", 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 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 INIT OK", CENTER_MODE); + } + + wait(1); + lcd.SetFont(&Font12); + lcd.SetBackColor(LCD_COLOR_BLUE); + lcd.SetTextColor(LCD_COLOR_WHITE); + + while(1) { + + ts.GetState(&TS_State); + if (TS_State.touchDetected) { + // Clear lines corresponding to old touches coordinates + if (TS_State.touchDetected < prev_nb_touches) { + for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) { + lcd.ClearStringLine(idx); + } + } + prev_nb_touches = TS_State.touchDetected; + + cleared = 0; + + sprintf((char*)text, "Touches: %d", TS_State.touchDetected); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + + for (idx = 0; idx < TS_State.touchDetected; idx++) { + x = TS_State.touchX[idx]; + y = TS_State.touchY[idx]; + sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y); + lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE); + } + + lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE); + } else { + if (!cleared) { + lcd.Clear(LCD_COLOR_BLUE); + sprintf((char*)text, "Touches: 0"); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + cleared = 1; + } + } + } +}
diff -r 000000000000 -r 8f0206e51e1b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 15 00:48:41 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file