[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 }