Optimaze with new mbed os for study
Dependencies: TS_DISCO_F746NG BSP_DISCO_F746NG Graphics
PointingDevice/TouchScreen.cpp@4:66f13188c26b, 2016-11-05 (annotated)
- Committer:
- karpent
- Date:
- Sat Nov 05 20:24:59 2016 +0000
- Revision:
- 4:66f13188c26b
- Parent:
- 2:8db224cc1fcb
Code refactoring, 400ms timeout added when button is pressed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
karpent | 2:8db224cc1fcb | 1 | // |
karpent | 2:8db224cc1fcb | 2 | // TouchScreen.cpp |
karpent | 2:8db224cc1fcb | 3 | // |
karpent | 2:8db224cc1fcb | 4 | |
karpent | 2:8db224cc1fcb | 5 | #include "TouchScreen.h" |
karpent | 2:8db224cc1fcb | 6 | |
karpent | 4:66f13188c26b | 7 | //Serial pc(USBTX, USBRX); |
karpent | 4:66f13188c26b | 8 | |
karpent | 4:66f13188c26b | 9 | TouchScreen::TouchScreen(Display* display) |
karpent | 4:66f13188c26b | 10 | { |
karpent | 4:66f13188c26b | 11 | _width = display != NULL ? display->DisplayWidth() - 1: 479; |
karpent | 4:66f13188c26b | 12 | _height = display != NULL ? display->DisplayHeight() - 1: 271; |
karpent | 4:66f13188c26b | 13 | } |
karpent | 4:66f13188c26b | 14 | |
karpent | 4:66f13188c26b | 15 | |
karpent | 4:66f13188c26b | 16 | void TouchScreen::Init() |
karpent | 4:66f13188c26b | 17 | { |
karpent | 4:66f13188c26b | 18 | TS_DISCO_F746NG::Init(_width, _height); |
karpent | 4:66f13188c26b | 19 | } |
karpent | 4:66f13188c26b | 20 | |
karpent | 4:66f13188c26b | 21 | |
karpent | 4:66f13188c26b | 22 | pPoint TouchScreen::DetectTouch() |
karpent | 2:8db224cc1fcb | 23 | { |
karpent | 4:66f13188c26b | 24 | GetState(&tsState); |
karpent | 4:66f13188c26b | 25 | // Debug message |
karpent | 4:66f13188c26b | 26 | //pc.printf("."); |
karpent | 4:66f13188c26b | 27 | |
karpent | 4:66f13188c26b | 28 | if(tsState.touchDetected > 0) { |
karpent | 4:66f13188c26b | 29 | touchPoint.X = tsState.touchX[0]; |
karpent | 4:66f13188c26b | 30 | touchPoint.Y = tsState.touchY[0]; |
karpent | 2:8db224cc1fcb | 31 | |
karpent | 4:66f13188c26b | 32 | // Debug message |
karpent | 4:66f13188c26b | 33 | //pc.printf("Touch detected at (%d, %d)\r\n", touchPoint.X, touchPoint.Y); |
karpent | 4:66f13188c26b | 34 | |
karpent | 4:66f13188c26b | 35 | //ResetTouchData(&tsState); |
karpent | 4:66f13188c26b | 36 | return &touchPoint; |
karpent | 2:8db224cc1fcb | 37 | } |
karpent | 4:66f13188c26b | 38 | |
karpent | 4:66f13188c26b | 39 | return NULL; |
karpent | 2:8db224cc1fcb | 40 | } |