首页 > 其他 > 详细

[ucgui] 对话框6——触屏位置简单例子

时间:2014-08-24 23:34:13      阅读:292      评论:0      收藏:0      [点我收藏+]

>_<:直接调用函数获得触屏位置:

  • xPhys = GUI_TOUCH_GetxPhys(); /* Get the A/D mesurement result in x */
  • yPhys = GUI_TOUCH_GetyPhys(); /* Get the A/D mesurement result in y */

bubuko.com,布布扣

 1 void MainTask_touch(void) {
 2   GUI_Init();
 3   GUI_CURSOR_Show();
 4   GUI_CURSOR_Select(&GUI_CursorCrossL);
 5   GUI_SetBkColor(GUI_WHITE);
 6   GUI_SetColor(GUI_BLACK);
 7   GUI_Clear();
 8   GUI_DispString("Measurement of\nA/D converter values");
 9   while (1) {
10     GUI_PID_STATE TouchState;
11     int xPhys, yPhys;
12     GUI_TOUCH_GetState(&TouchState);  /* Get the touch position in pixel */
13     xPhys = GUI_TOUCH_GetxPhys();     /* Get the A/D mesurement result in x */
14     yPhys = GUI_TOUCH_GetyPhys();     /* Get the A/D mesurement result in y */
15     /* Display the measurement result */
16     GUI_SetColor(GUI_BLUE);
17     GUI_DispStringAt("Analog input:\n", 0, 20);
18     GUI_GotoY(GUI_GetDispPosY() + 2);
19     GUI_DispString("x:");
20     GUI_DispDec(xPhys, 4);
21     GUI_DispString(", y:");
22     GUI_DispDec(yPhys, 4);
23     /* Display the according position */
24     GUI_SetColor(GUI_RED);
25     GUI_GotoY(GUI_GetDispPosY() + 4);
26     GUI_DispString("\nPosition:\n");
27     GUI_GotoY(GUI_GetDispPosY() + 2);
28     GUI_DispString("x:");
29     GUI_DispDec(TouchState.x,4);
30     GUI_DispString(", y:");
31     GUI_DispDec(TouchState.y,4);
32     /* Wait a while */
33     GUI_Delay(100);
34   };
35 }

 

[ucgui] 对话框6——触屏位置简单例子

原文:http://www.cnblogs.com/zjutlitao/p/3933639.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!