luat_tp.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "luat_base.h"
  2. #include "luat_tp.h"
  3. #include "luat_mem.h"
  4. #define LUAT_LOG_TAG "tp"
  5. #include "luat_log.h"
  6. luat_rtos_task_handle tp_task_handle = NULL;
  7. void luat_tp_task_entry(void* param){
  8. uint32_t message_id = 0;
  9. luat_tp_config_t *luat_tp_config;
  10. luat_tp_data_t tp_data[10];
  11. while (1){
  12. luat_rtos_message_recv(tp_task_handle, &message_id, &luat_tp_config, LUAT_WAIT_FOREVER);
  13. uint8_t touch_num = luat_tp_config->opts->read(luat_tp_config,tp_data);
  14. for (uint8_t i=0; i<10; i++){
  15. if ((TP_EVENT_TYPE_DOWN == tp_data[i].event) || (TP_EVENT_TYPE_UP == tp_data[i].event) || (TP_EVENT_TYPE_MOVE == tp_data[i].event)){
  16. LLOGD("event=%d, track_id=%d, x=%d, y=%d, s=%d, timestamp=%u.\r\n",
  17. tp_data[i].event,
  18. tp_data[i].track_id,
  19. tp_data[i].x_coordinate,
  20. tp_data[i].y_coordinate,
  21. tp_data[i].width,
  22. tp_data[i].timestamp);
  23. }
  24. if (luat_tp_config->callback){
  25. luat_tp_config->callback(luat_tp_config,&tp_data[i]);
  26. }
  27. }
  28. }
  29. }
  30. int luat_tp_init(luat_tp_config_t* luat_tp_config){
  31. if (tp_task_handle == 0){
  32. luat_rtos_task_create(&tp_task_handle, 2048, 50, "tp", luat_tp_task_entry, NULL, 10);
  33. }
  34. tp_config_gt911.init(luat_tp_config);
  35. return 0;
  36. }