Paneldrv.h
上传用户:zbk8730
上传日期:2017-08-10
资源大小:12168k
文件大小:10k
源码类别:

uCOS

开发平台:

C/C++

  1. #ifndef _PANELDRV_H_
  2. #define _PANELDRV_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define TOUCH_AREA_FEATURE
  7. // screen size
  8. #define SCREEN_CX 239
  9. #define SCREEN_CY 319
  10. // pen state
  11. #define _PEN_UP 0 // pen up
  12. #define _PEN_DOWN 1 // pen down
  13. #define _PEN_ICON 2 // pen down icon
  14. #ifndef  L_PLATFORM
  15. #define TOUCHPEN_UP 0
  16. #define TOUCHPEN_DOWN 1
  17. #define TOUCHPEN_MOVE 2
  18. #else
  19. #define TOUCHPEN_UP 0x00
  20. #define TOUCHPEN_DOWN 0x04
  21. #define TOUCHPEN_MOVE 0x10
  22. #endif
  23. #ifdef _PROJECT_PM368_
  24. #if 0
  25. // 320*320 LCD
  26. #define ADJUST_X_CENTRE 0x175//0x165 //0x175
  27. #define ADJUST_Y_CENTRE             0x175//0x170 //0x175
  28. #define ADJUST_X_LEFTTOP 0x50//0x050 //0x80
  29. #define ADJUST_Y_LEFTTOP            0x50//0x240 //0x80
  30. #define ADJUST_X_RIGHTTOP           0x270//0x239 //0x270
  31. #define ADJUST_Y_RIGHTTOP           0x50//0x240 //0x80
  32. #define ADJUST_X_LEFTBOTTOM         0x50//0x050 //0x80
  33. #define ADJUST_Y_LEFTBOTTOM         0x270//0x270 //0x270
  34. #define ADJUST_X_RIGHTBOTTOM        0x270//0x239 //0x270
  35. #define ADJUST_Y_RIGHTBOTTOM        0x0270//0x270 //0x270
  36. #else
  37. // 320*240 LCD
  38. #define ADJUST_X_CENTRE 0x1e5//0x200
  39. #define ADJUST_Y_CENTRE             0x1f5//0x1f0
  40. #define ADJUST_X_LEFTTOP 0x60//0x90
  41. #define ADJUST_Y_LEFTTOP            0x50//0x60
  42. #define ADJUST_X_RIGHTTOP           0x390//0x390
  43. #define ADJUST_Y_RIGHTTOP           0x50//0x60
  44. #define ADJUST_X_LEFTBOTTOM         0x60//0x90
  45. #define ADJUST_Y_LEFTBOTTOM         0x390//0x390
  46. #define ADJUST_X_RIGHTBOTTOM        0x390//0x390
  47. #define ADJUST_Y_RIGHTBOTTOM        0x390//0x390
  48. /*
  49. #define ADJUST_X_CENTRE 0x1e0
  50. #define ADJUST_Y_CENTRE             0x1c0
  51. #define ADJUST_X_LEFTTOP 0x60
  52. #define ADJUST_Y_LEFTTOP            0x60
  53. #define ADJUST_X_RIGHTTOP           0x350
  54. #define ADJUST_Y_RIGHTTOP           0x60
  55. #define ADJUST_X_LEFTBOTTOM         0x60
  56. #define ADJUST_Y_LEFTBOTTOM         0x380
  57. #define ADJUST_X_RIGHTBOTTOM        0x350
  58. #define ADJUST_Y_RIGHTBOTTOM        0x380
  59. */
  60. #endif
  61. #else
  62. #ifdef _PROJECT_PM388_
  63. #define ADJUST_X_CENTRE 0x200
  64. #define ADJUST_Y_CENTRE             0x200
  65. #define ADJUST_X_LEFTTOP 0x50
  66. #define ADJUST_Y_LEFTTOP            0x40
  67. #define ADJUST_X_RIGHTTOP           0x380
  68. #define ADJUST_Y_RIGHTTOP           0x40
  69. #define ADJUST_X_LEFTBOTTOM         0x50
  70. #define ADJUST_Y_LEFTBOTTOM         0x390
  71. #define ADJUST_X_RIGHTBOTTOM        0x380
  72. #define ADJUST_Y_RIGHTBOTTOM        0x390
  73. #ifdef TOUCH_AREA_FEATURE
  74. #define ADJUST_AREAA_RX_M 119
  75. #define ADJUST_AREAA_RX_N 432
  76. #define ADJUST_AREAA_OFFSETX 22
  77. #define ADJUST_AREAA_RY_M 159
  78. #define ADJUST_AREAA_RY_N 448
  79. #define ADJUST_AREAA_OFFSETY 23
  80. #define ADJUST_AREAB_RX_M 5
  81. #define ADJUST_AREAB_RX_N 16
  82. #define ADJUST_AREAB_OFFSETX 41
  83. #define ADJUST_AREAB_RY_M 159
  84. #define ADJUST_AREAB_RY_N 448
  85. #define ADJUST_AREAB_OFFSETY 23
  86. #define ADJUST_AREAC_RX_M 119
  87. #define ADJUST_AREAC_RX_N 432
  88. #define ADJUST_AREAC_OFFSETX 22
  89. #define ADJUST_AREAC_RY_M 2
  90. #define ADJUST_AREAC_RY_N 5
  91. #define ADJUST_AREAC_OFFSETY 46
  92. #define ADJUST_AREAD_RX_M 5
  93. #define ADJUST_AREAD_RX_N 16
  94. #define ADJUST_AREAD_OFFSETX 41
  95. #define ADJUST_AREAD_RY_M 2
  96. #define ADJUST_AREAD_RY_N 5
  97. #define ADJUST_AREAD_OFFSETY 46
  98. #endif
  99. #else
  100. #define ADJUST_X_CENTRE 0x1e0
  101. #define ADJUST_Y_CENTRE             0x1c0
  102. #define ADJUST_X_LEFTTOP 0x60
  103. #define ADJUST_Y_LEFTTOP            0x60
  104. #define ADJUST_X_RIGHTTOP           0x350
  105. #define ADJUST_Y_RIGHTTOP           0x60
  106. #define ADJUST_X_LEFTBOTTOM         0x60
  107. #define ADJUST_Y_LEFTBOTTOM         0x330
  108. #define ADJUST_X_RIGHTBOTTOM        0x350
  109. #define ADJUST_Y_RIGHTBOTTOM        0x330
  110. #endif
  111. #endif
  112. #define ADJUST_OFFSET 80
  113. #define ADJUST_OFFSET2 200
  114. #define PANELBUFLEN 100
  115. typedef struct tagPEN_POINT
  116. {
  117. unsigned short x;
  118. unsigned short y;
  119. }PEN_POINT, *PPEN_POINT;
  120. typedef struct tagTouchPenState
  121. {
  122. unsigned short wTouchState; // 1: up, 0: down
  123. unsigned short wTouchX; // 
  124. unsigned short wTouchY; // 
  125. }TouchPenState, *pTouchPenState;
  126. typedef struct tagPenQueue
  127. {
  128. TouchPenState PenState[PANELBUFLEN]; // pen queue
  129. unsigned short wHead;
  130. unsigned short wTail;
  131. }PenQueue, *pPenQueue;
  132. typedef struct tagPANEL_STRUC
  133. {
  134. unsigned char PanelState; // TOUCHDOWN, TOUCHUP, TOUCHMOVE
  135. unsigned short PanelDotX;
  136. unsigned short PanelDotY;
  137. unsigned char PanelIconFlag; // indicates icon name. 
  138. }PANEL_STRUC, *PPANEL_STRUC;
  139. typedef struct tagPANELQUEUE
  140. {
  141. PANEL_STRUC PanelBuf[PANELBUFLEN];
  142.     unsigned char PanelFront;
  143. unsigned char PanelRear; /* Panel front and rear vaule */
  144.     unsigned char PanelBufFull; /* Panel buffer empty flag */
  145. }PANELQUEUE, *PPANELQUEUE;
  146. #ifdef TOUCH_AREA_FEATURE
  147. typedef struct floatStruct
  148. {
  149. unsigned short m;
  150. unsigned short n;
  151. }TouchFloatData;
  152. typedef struct touchAreaStruct
  153. {
  154. TouchFloatData Rx;
  155. TouchFloatData Ry;
  156. unsigned short offset_x;
  157. unsigned short offset_y;
  158. }TouchAreaStruct;
  159. typedef enum 
  160. {
  161. TOUCH_AREA_A = 0,
  162. TOUCH_AREA_B,
  163. TOUCH_AREA_C,
  164. TOUCH_AREA_D,
  165. TOUCH_AREA_CENTER,
  166. }TouchArea;
  167. #endif
  168. #ifndef L_PLATFORM
  169. typedef struct tagAdjustTouch
  170. #else
  171. typedef struct tagAdjustTouch
  172. #endif
  173. {
  174. #ifndef TOUCH_AREA_FEATURE
  175. unsigned short wCentreX;
  176. unsigned short wCentreY;
  177. unsigned short wLeftTopX;
  178. unsigned short wLeftTopY;
  179. unsigned short wRightTopX;
  180. unsigned short wRightTopY;
  181. unsigned short wLeftBottomX;
  182. unsigned short wLeftBottomY;
  183. unsigned short wRightBottomX;
  184. unsigned short wRightBottomY;
  185. #else
  186. unsigned short wCentreX;
  187. unsigned short wCentreY;
  188. unsigned short wAreaARx_m;
  189. unsigned short wAreaARx_n;
  190. unsigned short wAreaAOffsetx;
  191. unsigned short wAreaARy_m;
  192. unsigned short wAreaARy_n;
  193. unsigned short wAreaAOffsety;
  194. unsigned short wAreaBRx_m;
  195. unsigned short wAreaBRx_n;
  196. unsigned short wAreaBOffsetx;
  197. unsigned short wAreaBRy_m;
  198. unsigned short wAreaBRy_n;
  199. unsigned short wAreaBOffsety;
  200. unsigned short wAreaCRx_m;
  201. unsigned short wAreaCRx_n;
  202. unsigned short wAreaCOffsetx;
  203. unsigned short wAreaCRy_m;
  204. unsigned short wAreaCRy_n;
  205. unsigned short wAreaCOffsety;
  206. unsigned short wAreaDRx_m;
  207. unsigned short wAreaDRx_n;
  208. unsigned short wAreaDOffsetx;
  209. unsigned short wAreaDRy_m;
  210. unsigned short wAreaDRy_n;
  211. unsigned short wAreaDOffsety;
  212. #endif
  213. #ifndef L_PLATFORM
  214. }AdjustTouchPoints, *pAdjustTouchPoints;
  215. #else
  216. } __attribute__((packed))AdjustTouchPoints, __attribute__((packed)) *pAdjustTouchPoints ;
  217. #endif
  218. extern unsigned char gcPenState;
  219. extern unsigned char gbPenUpFlag;
  220. extern unsigned short gwPreTouchKey;
  221. extern unsigned short gwLaterX;
  222. extern unsigned short gwLaterY;
  223. extern unsigned short gwLastestX;
  224. extern unsigned short gwLastestY;
  225. extern unsigned short gwLastX;
  226. extern unsigned short gwLastY;
  227. extern unsigned short wPrePenMoveX;
  228. extern unsigned short wPrePenMoveY;
  229. extern unsigned short gwTouchXMinValue1;
  230. extern unsigned short gwTouchXMinValue2;
  231. extern unsigned short gwTouchXMaxValue1;
  232. extern unsigned short gwTouchXMaxValue2;
  233. extern unsigned short gwTouchYMinValue1;
  234. extern unsigned short gwTouchYMinValue2;
  235. extern unsigned short gwTouchYMaxValue1;
  236. extern unsigned short gwTouchYMaxValue2;
  237. extern unsigned short gwTouchXValue;
  238. extern unsigned short gwTouchYValue;
  239. extern unsigned short gwTouchXSite;
  240. extern unsigned short gwTouchYSite;
  241. extern unsigned char gbTouchAdjustFlag;
  242. extern unsigned short gwAdjustX;
  243. extern unsigned short gwAdjustY;
  244. void ResetTouchConvert(void);
  245. extern unsigned char _IsTouchPenDown(void);
  246. void InitTouchPen(void);
  247. void RestoreTouchPen(void);
  248. void SetPenState(unsigned char cState);
  249. unsigned char GetPenState(void);
  250. void SetDefaultPenState(void);
  251. TouchPenState GetPenInfo(unsigned short wCurPoint);
  252. unsigned char GetPenUpFlag(void);
  253. void SetPenUpFlag(unsigned char bFlag);
  254. unsigned char ComparePenState(PEN_POINT pt);
  255. void EmptyPenQueue(void);
  256. PEN_POINT CurrentPenPos(void);
  257. unsigned char TouchPanelProc(unsigned short wTouchX, unsigned short wTouchY);
  258. unsigned char TouchPenProc(void);
  259. unsigned char TouchPutOn(TouchPenState *pTouchValue);
  260. void NoUpRestoreTouch(void);
  261. void RestoreTouch(void);
  262. unsigned char GetCurPenPos(unsigned short *x, unsigned short *y);
  263. unsigned short ModulusMinusValue(unsigned short wValue1, unsigned short wValue2);
  264. unsigned short MaxValue(unsigned short wValue1, unsigned short wValue2);
  265. unsigned short MinValue(unsigned short wValue1, unsigned short wValue2);
  266. // adjust touch panel
  267. unsigned char GetPenAdjustState(void);
  268. void PenAdjustBegin(void);
  269. void PenAdjustEnd(void);
  270. void GetAdjustmentAD(unsigned short *wTouchX, unsigned short *wTouchY);
  271. unsigned char CmpRange(unsigned short sx, unsigned short sy, unsigned short tx, unsigned short ty);
  272. unsigned char CalculateTouchCentre(unsigned short wLcdX, unsigned short wLcdY, unsigned short wTouchX, unsigned short wTouchY);
  273. unsigned char CalculateTouchLeftTop(unsigned short wLcdX, unsigned short wLcdY, unsigned short wTouchX, unsigned short wTouchY);
  274. unsigned char CalculateTouchRightTop(unsigned short wLcdX, unsigned short wLcdY, unsigned short wTouchX, unsigned short wTouchY);
  275. unsigned char CalculateTouchLeftBottom(unsigned short wLcdX, unsigned short wLcdY, unsigned short wTouchX, unsigned short wTouchY);
  276. unsigned char CalculateTouchRightBottom(unsigned short wLcdX, unsigned short wLcdY, unsigned short wTouchX, unsigned short wTouchY);
  277. void BorderAverage(void);
  278. void GetPenAdjustment(AdjustTouchPoints *AD);
  279. void SetPenAdjustment(AdjustTouchPoints *AD);
  280. extern unsigned char PutPanelInf(PANEL_STRUC *panelvar);
  281. extern unsigned char GetPanelInf(PANEL_STRUC *panelvar);
  282. #ifdef __cplusplus
  283. }
  284. #endif
  285. #endif