[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 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?