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