Correction
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG
touches.cpp@1:467f801bd037, 2019-12-10 (annotated)
- Committer:
- DValente
- Date:
- Tue Dec 10 08:49:11 2019 +0000
- Revision:
- 1:467f801bd037
TP3b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DValente | 1:467f801bd037 | 1 | |
DValente | 1:467f801bd037 | 2 | #include "touches.h" |
DValente | 1:467f801bd037 | 3 | |
DValente | 1:467f801bd037 | 4 | uint8_t readTouchApp(void) |
DValente | 1:467f801bd037 | 5 | { |
DValente | 1:467f801bd037 | 6 | TS_DISCO_F746NG ts; // instanciation du Touch Screen |
DValente | 1:467f801bd037 | 7 | TS_StateTypeDef TS_State; // Structure liée au Touch Screen |
DValente | 1:467f801bd037 | 8 | uint16_t X,Y,X1,Y1,X2,Y2; // Coordonnées de la touche et des icônes |
DValente | 1:467f801bd037 | 9 | uint8_t Row,Line,Touch=0; // ligne et colonnes de l'icône |
DValente | 1:467f801bd037 | 10 | ts.GetState(&TS_State); |
DValente | 1:467f801bd037 | 11 | if (TS_State.touchDetected) |
DValente | 1:467f801bd037 | 12 | { |
DValente | 1:467f801bd037 | 13 | X=TS_State.touchX[0]; // Lecture de la coordonnée X de la touche |
DValente | 1:467f801bd037 | 14 | Y=TS_State.touchY[0]; // Lecture de la coordonnée Y de la touche |
DValente | 1:467f801bd037 | 15 | for(Line=0;Line<2;Line++) |
DValente | 1:467f801bd037 | 16 | { |
DValente | 1:467f801bd037 | 17 | for(Row=0;Row<4;Row++) |
DValente | 1:467f801bd037 | 18 | { |
DValente | 1:467f801bd037 | 19 | X1=ICON_H_GAP*(Row+1)+ICON_WIDTH*Row; |
DValente | 1:467f801bd037 | 20 | Y1=ICON_V_GAP*(Line+1)+ICON_HEIGHT*Line; |
DValente | 1:467f801bd037 | 21 | X2=X1+ICON_WIDTH; |
DValente | 1:467f801bd037 | 22 | Y2=X2+ICON_HEIGHT; |
DValente | 1:467f801bd037 | 23 | if((X>X1) && (X<X2) && (Y>Y1)&& (Y<Y2)) Touch=(Line*4)+Row+1; |
DValente | 1:467f801bd037 | 24 | } |
DValente | 1:467f801bd037 | 25 | } |
DValente | 1:467f801bd037 | 26 | |
DValente | 1:467f801bd037 | 27 | } |
DValente | 1:467f801bd037 | 28 | return Touch; |
DValente | 1:467f801bd037 | 29 | } |
DValente | 1:467f801bd037 | 30 | |
DValente | 1:467f801bd037 | 31 | bool readTouchClose(uint16_t X1,uint16_t Y1,uint16_t X2,uint16_t Y2) |
DValente | 1:467f801bd037 | 32 | { |
DValente | 1:467f801bd037 | 33 | TS_DISCO_F746NG ts; // instanciation du Touch Screen |
DValente | 1:467f801bd037 | 34 | TS_StateTypeDef TS_State; // Structure liée au Touch Screen |
DValente | 1:467f801bd037 | 35 | uint16_t X,Y; // Coordonnées de la touche et des icônes |
DValente | 1:467f801bd037 | 36 | bool Touch=false; |
DValente | 1:467f801bd037 | 37 | ts.GetState(&TS_State); |
DValente | 1:467f801bd037 | 38 | if (TS_State.touchDetected) |
DValente | 1:467f801bd037 | 39 | { |
DValente | 1:467f801bd037 | 40 | X=TS_State.touchX[0]; // Lecture de la coordonnée X de la touche |
DValente | 1:467f801bd037 | 41 | Y=TS_State.touchY[0]; // Lecture de la coordonnée Y de la touche |
DValente | 1:467f801bd037 | 42 | X2=X1+ICON_WIDTH; |
DValente | 1:467f801bd037 | 43 | Y2=X2+ICON_HEIGHT; |
DValente | 1:467f801bd037 | 44 | if((X>X1) && (X<X2) && (Y>Y1)&& (Y<Y2)) Touch=true; |
DValente | 1:467f801bd037 | 45 | |
DValente | 1:467f801bd037 | 46 | } |
DValente | 1:467f801bd037 | 47 | return Touch; |
DValente | 1:467f801bd037 | 48 | } |