硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3659|回复: 8
收起左侧

[ThreadX全家桶] 打算将ThreadX GUIX的触摸功能加上,发现提供的案例里面找不到触摸任务的原始定义

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107578
QQ
发表于 2020-6-9 16:16:09 | 显示全部楼层 |阅读模式

5.png
回复

使用道具 举报

1

主题

8

回帖

11

积分

新手上路

积分
11
发表于 2020-6-9 16:27:48 | 显示全部楼层
我在用这个demo,touch线程没有,lcd显示 我都还没有出来,只看到一张纯背景色。。。。。。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107578
QQ
 楼主| 发表于 2020-6-9 16:31:50 | 显示全部楼层
24diaos 发表于 2020-6-9 16:27
我在用这个demo,touch线程没有,lcd显示 我都还没有出来,只看到一张纯背景色。。。。。。

貌似真没有,看来只能看文档找下接口函数了。
回复

使用道具 举报

4

主题

18

回帖

45

积分

新手上路

积分
45
发表于 2020-6-9 16:34:58 | 显示全部楼层
2020-06-09_163112.png
这个例子里面
Azure_RTOS_6.0_STM32F746G-DISCO_STM32CubeIDE_Samples_2020_05_17.zip


stm32f746g-disco\stm32cubeide\gx\gx_touch_driver_stm32f746g-disco.c

可供参考。

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107578
QQ
 楼主| 发表于 2020-6-9 16:40:55 | 显示全部楼层
jnny_cn 发表于 2020-6-9 16:34
这个例子里面
Azure_RTOS_6.0_STM32F746G-DISCO_STM32CubeIDE_Samples_2020_05_17.zip

非常感谢,位置太隐蔽了。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107578
QQ
 楼主| 发表于 2020-6-9 16:41:05 | 显示全部楼层

  1. #include   "tx_api.h"
  2. #include   "gx_api.h"
  3. #include   "gx_system.h"
  4. #include   "gx_display.h"
  5. #include   "gx_display_driver_stm32f746g-disco_24xrgb.h"
  6. #include   "stm32746g_discovery_lcd.h"
  7. #include   "stm32746g_discovery_ts.h"

  8. #define TOUCH_STATE_TOUCHED  1
  9. #define TOUCH_STATE_RELEASED 2
  10. #define MIN_DRAG_DELTA       10


  11. static int last_pos_x;
  12. static int last_pos_y;
  13. static int curpos_x;
  14. static int curpos_y;
  15. static int touch_state;

  16. /**************************************************************************/
  17. VOID SendPenDownEvent(VOID)
  18. {
  19.     GX_EVENT event;
  20.     event.gx_event_type = GX_EVENT_PEN_DOWN;
  21.     event.gx_event_payload.gx_event_pointdata.gx_point_x = curpos_x;
  22.     event.gx_event_payload.gx_event_pointdata.gx_point_y = curpos_y;
  23.     event.gx_event_sender = 0;
  24.     event.gx_event_target = 0;
  25.     event.gx_event_display_handle = STM32F746G_DISCO_SCREEN_HANDLE;
  26.     last_pos_x = curpos_x;
  27.     last_pos_y = curpos_y;
  28.     gx_system_event_send(&event);
  29. }

  30. /**************************************************************************/
  31. VOID SendPenDragEvent(VOID)
  32. {
  33.     GX_EVENT event;
  34.     int x_delta = abs(curpos_x - last_pos_x);
  35.     int y_delta = abs(curpos_y - last_pos_y);

  36.     if (x_delta > MIN_DRAG_DELTA || y_delta > MIN_DRAG_DELTA)
  37.     {
  38.         event.gx_event_type = GX_EVENT_PEN_DRAG;
  39.         event.gx_event_payload.gx_event_pointdata.gx_point_x = curpos_x;
  40.         event.gx_event_payload.gx_event_pointdata.gx_point_y = curpos_y;
  41.         event.gx_event_sender = 0;
  42.         event.gx_event_target = 0;
  43.         event.gx_event_display_handle = STM32F746G_DISCO_SCREEN_HANDLE;
  44.         last_pos_x = curpos_x;
  45.         last_pos_y = curpos_y;
  46.    
  47.         gx_system_event_fold(&event);
  48.     }
  49. }

  50. /**************************************************************************/
  51. VOID SendPenUpEvent(VOID)
  52. {
  53.     GX_EVENT event;
  54.     event.gx_event_type = GX_EVENT_PEN_UP;
  55.     event.gx_event_payload.gx_event_pointdata.gx_point_x = curpos_x;
  56.     event.gx_event_payload.gx_event_pointdata.gx_point_y = curpos_y;
  57.     event.gx_event_sender = 0;
  58.     event.gx_event_target = 0;
  59.     event.gx_event_display_handle = STM32F746G_DISCO_SCREEN_HANDLE;
  60.     last_pos_x = curpos_x;
  61.     last_pos_y = curpos_y;
  62.     gx_system_event_send(&event);
  63. }

  64. /*
  65.   *                     ReadBuffer [0]: The Byte count (0x0A)   
  66.   *                     ReadBuffer [1]: X1 coordinate [15,8]  
  67.   *                     ReadBuffer [2]: X1 coordinate [7,0]
  68.   *                     ReadBuffer [3]: Y1 coordinate [15,8]
  69.   *                     ReadBuffer [4]: Y1 coordinate [7,0]
  70.   *                     ReadBuffer [5]: X2 coordinate [15,8]
  71.   *                     ReadBuffer [6]: X2 coordinate [7,0]
  72.   *                     ReadBuffer [7]: Y2 coordinate [15,8]
  73.   *                     ReadBuffer [8]: Y2 coordinate [7,0]
  74.   *                     ReadBuffer [9]: Gesture command (01: Zoom In 02: Zoom out)
  75.   *                     ReadBuffer [10]: unused byte
  76. */
  77. VOID  touch_thread_entry(ULONG thread_input)
  78. {

  79.     TS_StateTypeDef TS_State;
  80.     touch_state = TOUCH_STATE_RELEASED;

  81.     BSP_TS_Init(RK043FN48H_WIDTH, RK043FN48H_HEIGHT);
  82.    
  83.     while(1)
  84.     {
  85.         tx_thread_sleep(2);

  86.         BSP_TS_GetState(&TS_State);

  87.         if (!(TS_State.touchDetected))
  88.         {
  89.             // no touch, check so see if last was touched
  90.             if (touch_state == TOUCH_STATE_TOUCHED)
  91.             {
  92.                 touch_state = TOUCH_STATE_RELEASED;
  93.                 SendPenUpEvent();
  94.             }
  95.         }
  96.         else
  97.         {

  98.             if (TS_State.touchX[0] > RK043FN48H_WIDTH ||
  99.                 TS_State.touchY[0] > RK043FN48H_HEIGHT)
  100.                 continue;

  101.             // screen is touched, update coords:
  102.             curpos_x = TS_State.touchX[0];
  103.             
  104.             curpos_y = TS_State.touchY[0];

  105.             if (touch_state == TOUCH_STATE_RELEASED)
  106.             {
  107.                 touch_state = TOUCH_STATE_TOUCHED;
  108.                 SendPenDownEvent();
  109.             }
  110.             else
  111.             {
  112.                 // test and send pen drag
  113.                 SendPenDragEvent();
  114.             }
  115.         }
  116.     }
  117. }
复制代码


回复

使用道具 举报

3

主题

1255

回帖

1264

积分

至尊会员

积分
1264
发表于 2020-6-9 22:07:23 | 显示全部楼层
回复

使用道具 举报

1

主题

10

回帖

13

积分

新手上路

积分
13
发表于 2020-6-10 07:53:33 | 显示全部楼层
用vscode打开文件夹,搜索就好,vscode的搜索很好用的。
代码跳转之类的也很好用。微软大法好。
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107578
QQ
 楼主| 发表于 2020-6-10 09:52:10 | 显示全部楼层
usecool 发表于 2020-6-10 07:53
用vscode打开文件夹,搜索就好,vscode的搜索很好用的。
代码跳转之类的也很好用。微软大法好。

还是VS方便, IAR默认打开是的库,自己手动添加就有点太繁琐了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-6-6 16:46 , Processed in 0.363327 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表