From ebc61431bd826f8b7147791828f0cee1f93f5582 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Mon, 21 Nov 2022 15:59:25 +0800 Subject: [PATCH] fit touch position for lcd --- .../edu-riscv64/third_party_driver/include/connect_touch.h | 4 ++++ .../edu-riscv64/third_party_driver/touch/connect_touch.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h index 30ed6008d..0bf7ee7ae 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h @@ -64,6 +64,10 @@ typedef enum _touch_event #define GTP_REG_CONFIG_DATA 0x8047 #define GTP_REG_VERSION 0x8140 +#define LCD_SIZE 320 +#define TOUCH_WIDTH 1024 +#define TOUCH_HEIGHT 664 + #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) int HwTouchInit(void); diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index 24563c51d..aed2bd8c3 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -278,7 +278,7 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; read_param->read_length = 0; - result = KSemaphoreObtain(touch_sem, 1000); + result = KSemaphoreObtain(touch_sem, 10); // if (EOK == result) // { memset(TOUCHRECDATA, 0, 24); @@ -292,8 +292,10 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) { ts_event.fingers[i].x = ((((uint32_t)TOUCHRECDATA[(i * 4) + 5]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 4]) & 0x00000FFF; // 12 bits of X coord ts_event.fingers[i].y = ((((uint32_t)TOUCHRECDATA[(i * 4) + 7]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 6]) & 0x00000FFF; + ts_event.fingers[i].x = 320 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH; + ts_event.fingers[i].y = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT; ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch - printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); + // printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); } data->x = ts_event.fingers[ts_event.NBfingers - 1].x;