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

简介:


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

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

复制代码
 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 }
复制代码
相关文章
|
3月前
|
图形学
小功能⭐️不用传参,Unity获得鼠标悬浮处的物体、UI!
小功能⭐️不用传参,Unity获得鼠标悬浮处的物体、UI!
|
图形学
unity判断鼠标在不在UI上
unity判断鼠标在不在UI上
|
Python
飞机大战-创建窗口(1)
用Python编程,编写飞机大战-创建窗口。
58 0
QT应用编程: QSlider设置滚动块定位到鼠标点击的地方
QT应用编程: QSlider设置滚动块定位到鼠标点击的地方
553 0
QT应用编程: QSlider设置滚动块定位到鼠标点击的地方
QT软件开发: 窗口打开固定在屏幕中间或者右下角
QT软件开发: 窗口打开固定在屏幕中间或者右下角
388 0