![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
Diff: PointingDevice/TouchScreen.cpp
- Revision:
- 4:66f13188c26b
- Parent:
- 2:8db224cc1fcb
--- a/PointingDevice/TouchScreen.cpp Sat Nov 05 15:36:59 2016 +0000 +++ b/PointingDevice/TouchScreen.cpp Sat Nov 05 20:24:59 2016 +0000 @@ -4,10 +4,37 @@ #include "TouchScreen.h" -TouchScreen::TouchScreen(RK043FN48H* display) +//Serial pc(USBTX, USBRX); + +TouchScreen::TouchScreen(Display* display) +{ + _width = display != NULL ? display->DisplayWidth() - 1: 479; + _height = display != NULL ? display->DisplayHeight() - 1: 271; +} + + +void TouchScreen::Init() +{ + TS_DISCO_F746NG::Init(_width, _height); +} + + +pPoint TouchScreen::DetectTouch() { - if(display != NULL) - { + GetState(&tsState); + // Debug message + //pc.printf("."); + + if(tsState.touchDetected > 0) { + touchPoint.X = tsState.touchX[0]; + touchPoint.Y = tsState.touchY[0]; + // Debug message + //pc.printf("Touch detected at (%d, %d)\r\n", touchPoint.X, touchPoint.Y); + + //ResetTouchData(&tsState); + return &touchPoint; } + + return NULL; } \ No newline at end of file