📄 gui_touch_driveranalog.lst
字号:
C51 COMPILER V8.05a GUI_TOUCH_DRIVERANALOG 04/11/2008 14:18:51 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUI_TOUCH_DRIVERANALOG
OBJECT MODULE PLACED IN GUI_TOUCH_DriverAnalog.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUI_TOUCH_DriverAnalog.c LARGE BROWSE MDU_F120 DEBUG
- OBJECTEXTEND PRINT(.\GUI_TOUCH_DriverAnalog.lst) OBJECT(GUI_TOUCH_DriverAnalog.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : GUITOUCH.C
16 Purpose : Touch screen manager
17 ----------------------------------------------------------------------
18 This module handles the touch screen. It is configured in the file
19 GUITouch.conf.h (Should be located in the Config\ directory).
20 ----------------------------------------------------------------------
21 */
22
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "gui\Core\LCD_Private.h" /* private modul definitions & config */
28 #include "gui\Core\GUI_Protected.h"
29
30 /* Generate code only if configuration says so ! */
31 #if GUI_SUPPORT_TOUCH
32
33 #include "Config\GUITouchconf.h" /* Located in GUIx, will include GUITouch.conf.h */
34
35 /*
36 **********************************************************************
37 *
38 * Config defaults
39 *
40 **********************************************************************
41 */
42 #ifndef GUI_TOUCH_AD_LEFT /* max value returned by AD-converter */
#define GUI_TOUCH_AD_LEFT 30
#endif
45
46 #ifndef GUI_TOUCH_AD_RIGHT /* min value returned by AD-converter */
#define GUI_TOUCH_AD_RIGHT 220
#endif
49
50 #ifndef GUI_TOUCH_AD_TOP /* max value returned by AD-converter */
51 #define GUI_TOUCH_AD_TOP 30
52 #endif
53
54 #ifndef GUI_TOUCH_AD_BOTTOM /* min value returned by AD-converter */
C51 COMPILER V8.05a GUI_TOUCH_DRIVERANALOG 04/11/2008 14:18:51 PAGE 2
55 #define GUI_TOUCH_AD_BOTTOM 220
56 #endif
57
58 #ifndef GUI_TOUCH_SWAP_XY /* Is XY of touch swapped ? */
#define GUI_TOUCH_SWAP_XY 0
#endif
61
62 #ifndef GUI_TOUCH_MIRROR_X
#define GUI_TOUCH_MIRROR_X 0
#endif
65
66 #ifndef GUI_TOUCH_MIRROR_Y
#define GUI_TOUCH_MIRROR_Y 0
#endif
69
70 #ifndef GUI_TOUCH_YSIZE
71 #define GUI_TOUCH_YSIZE LCD_YSIZE
72 #endif
73
74 #ifndef GUI_TOUCH_XSIZE
75 #define GUI_TOUCH_XSIZE LCD_XSIZE
76 #endif
77
78 /*********************************************************************
79 *
80 * Config check
81 *
82 **********************************************************************
83 */
84
85
86 /****************************************************************
87 *
88 * Static data
89 *
90 *****************************************************************
91 */
92
93 typedef struct {int Min; int Max; } tMinMax;
94 static int xPhys, yPhys;
95
96 static tMinMax xyMinMax[2] = {
97 #if ((GUI_TOUCH_SWAP_XY==0) && (GUI_TOUCH_MIRROR_X==0)) || ((GUI_TOUCH_SWAP_XY) && (GUI_TOUCH_MIRROR_Y==0)
-)
{ GUI_TOUCH_AD_LEFT, GUI_TOUCH_AD_RIGHT },
#else
100 { GUI_TOUCH_AD_RIGHT, GUI_TOUCH_AD_LEFT },
101 #endif
102 #if ((GUI_TOUCH_SWAP_XY==0) && (GUI_TOUCH_MIRROR_Y==0)) || ((GUI_TOUCH_SWAP_XY) && (GUI_TOUCH_MIRROR_X==0)
-)
103 { GUI_TOUCH_AD_TOP, GUI_TOUCH_AD_BOTTOM }
104 #else
{ GUI_TOUCH_AD_BOTTOM, GUI_TOUCH_AD_TOP }
#endif
107 };
108
109 #ifndef WIN32
110 static int xMin;
111 static int xMax;
112 static int yMin;
113 static int yMax;
114 #endif
C51 COMPILER V8.05a GUI_TOUCH_DRIVERANALOG 04/11/2008 14:18:51 PAGE 3
115
116
117
118 /*********************************************************************
119 *
120 * Convert physical value into (logical) coordinates
121 */
122 int AD2X(int adx) {
123 1 I32 r = adx - xyMinMax[GUI_COORD_X].Min;
124 1 r *= GUI_TOUCH_XSIZE - 1;
125 1 return r / (xyMinMax[GUI_COORD_X].Max - xyMinMax[GUI_COORD_X].Min);
126 1 }
127
128 int AD2Y(int ady) {
129 1 I32 r = ady - xyMinMax[GUI_COORD_Y].Min;
130 1 r *= GUI_TOUCH_YSIZE - 1;
131 1 return r/(xyMinMax[GUI_COORD_Y].Max - xyMinMax[GUI_COORD_Y].Min);
132 1 }
133
134 /*********************************************************************
135 *
136 * Diagnostic routines
137 */
138 int GUI_TOUCH_GetxPhys(void) {
139 1 return xPhys;
140 1 }
141
142 int GUI_TOUCH_GetyPhys(void) {
143 1 return yPhys;
144 1 }
145
146
147
148 /*********************************************************************
149 *
150 * SetDefaultCalibration
151 */
152
153 void GUI_TOUCH_SetDefaultCalibration(void) {
154 1 xyMinMax[0].Min = GUI_TOUCH_AD_LEFT;
155 1 xyMinMax[0].Max = GUI_TOUCH_AD_RIGHT;
156 1 xyMinMax[1].Min = GUI_TOUCH_AD_TOP;
157 1 xyMinMax[1].Max = GUI_TOUCH_AD_BOTTOM;
158 1 }
159
160 /*********************************************************************
161 *
162 * Calibration
163 */
164
165
166 static int Log2Phys(int l, I32 l0, I32 l1, I32 p0, I32 p1) {
167 1 return p0+ ((p1-p0) * (l-l0)) / (l1-l0);
168 1 }
169
170 int GUI_TOUCH_Calibrate(int Coord, int Log0, int Log1, int Phys0, int Phys1) {
171 1 int l0 = 0;
172 1 int l1 = (Coord==GUI_COORD_X) ? LCD_XSIZE-1 : LCD_YSIZE-1;
173 1 if (labs(Phys0-Phys1) < 20)
174 1 return 1;
175 1 if (labs(Log0-Log1) < 20)
176 1 return 1;
C51 COMPILER V8.05a GUI_TOUCH_DRIVERANALOG 04/11/2008 14:18:51 PAGE 4
177 1 xyMinMax[Coord].Min = Log2Phys(l0, Log0, Log1, Phys0, Phys1);
178 1 xyMinMax[Coord].Max = Log2Phys(l1, Log0, Log1, Phys0, Phys1);
179 1 return 0;
180 1 }
181
182 void GUI_TOUCH_GetCalData(int Coord, int* pMin,int* pMax) {
183 1 *pMin = xyMinMax[Coord].Min;
184 1 *pMax = xyMinMax[Coord].Max;
185 1 }
186
187
188 /*********************************************************************
189 *
190 * GUI_TOUCH_Exec
191 */
192
193 void GUI_TOUCH_Exec(void) {
194 1 #ifndef WIN32
195 1 static U8 ReadState;
196 1 int x,y;
197 1 /* calculate Min / Max values */
198 1 if (xyMinMax[GUI_COORD_X].Min < xyMinMax[GUI_COORD_X].Max) {
199 2 xMin = xyMinMax[GUI_COORD_X].Min;
200 2 xMax = xyMinMax[GUI_COORD_X].Max;
201 2 } else {
202 2 xMax = xyMinMax[GUI_COORD_X].Min;
203 2 xMin = xyMinMax[GUI_COORD_X].Max;
204 2 }
205 1 if (xyMinMax[GUI_COORD_Y].Min < xyMinMax[GUI_COORD_Y].Max) {
206 2 yMin = xyMinMax[GUI_COORD_Y].Min;
207 2 yMax = xyMinMax[GUI_COORD_Y].Max;
208 2 } else {
209 2 yMax = xyMinMax[GUI_COORD_Y].Min;
210 2 yMin = xyMinMax[GUI_COORD_Y].Max;
211 2 }
212 1 /* Execute the state machine which reads the touch */
213 1 switch (ReadState) {
214 2 case 0:
215 2 yPhys = TOUCH_X_MeasureY();
216 2 TOUCH_X_ActivateY(); /* Prepare X- measurement */
217 2 ReadState++;
218 2 break;
219 2 default:
220 2 xPhys = TOUCH_X_MeasureX();
221 2 TOUCH_X_ActivateX(); /* Prepare Y- measurement */
222 2 /* Convert values into logical values */
223 2 #if !GUI_TOUCH_SWAP_XY /* Is X/Y swapped ? */
x = xPhys;
y = yPhys;
#else
227 2 x = yPhys;
228 2 y = xPhys;
229 2 #endif
230 2
231 2 if ((x <xMin) | (x>xMax) | (y <yMin) | (y>yMax)) {
232 3 GUI_TOUCH_StoreUnstable(-1,-1);
233 3 } else {
234 3 x = AD2X(x);
235 3 y = AD2Y(y);
236 3 GUI_TOUCH_StoreUnstable(x,y);
237 3 }
238 2 /* Reset state machine */
C51 COMPILER V8.05a GUI_TOUCH_DRIVERANALOG 04/11/2008 14:18:51 PAGE 5
239 2 ReadState=0;
240 2 break;
241 2 }
242 1 #endif /* WIN32 */
243 1 }
244
245
246 #else
void GUI_TOUCH_DriverAnalog_C(void) {}
#endif /* defined(GUI_SUPPORT_TOUCH) && GUI_SUPPORT_TOUCH */
250
251
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1274 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 21 52
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -