fit touch postion for lvgl

This commit is contained in:
wuzheng 2022-11-21 16:46:46 +08:00
parent ebc61431bd
commit 987fd6c798
5 changed files with 11 additions and 9 deletions

View File

@ -268,7 +268,7 @@ static bool touchpad_is_pressed(void)
ret = PrivRead(touch_fd, &touch_data, 1); ret = PrivRead(touch_fd, &touch_data, 1);
if(ret && touch_data.x >= 0 && touch_data.x < MY_INDEV_X && touch_data.y >= 0 && touch_data.y < MY_INDEV_Y) if(ret && touch_data.x >= 0 && touch_data.x < MY_INDEV_X && touch_data.y >= 0 && touch_data.y < MY_INDEV_Y)
{ {
// printf("touch x %d touch y %d\n",touch_data.x,touch_data.y); printf("touch x %d touch y %d\n",touch_data.x,touch_data.y);
return true; return true;
} }

View File

@ -1,5 +1,6 @@
include $(LVGL_DIR)/$(LVGL_DIR_NAME)/examples/examples.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/examples/examples.mk
include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra/extra.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra/extra.mk
include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core/lv_core.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core/lv_core.mk
include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/lv_draw.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/lv_draw.mk
include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font/lv_font.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font/lv_font.mk

View File

@ -292,7 +292,7 @@ static bool touchpad_is_pressed(struct TouchDataStandard* touch_data_ptr)
press_failed_cnt = 0; press_failed_cnt = 0;
return true; return true;
} }
printf("lv_touch:%d,%d\n",touch_data_ptr->x,touch_data_ptr->y);
press_failed_cnt++; press_failed_cnt++;
if (press_failed_cnt >= PRESS_FAILED_LIMIT) { if (press_failed_cnt >= PRESS_FAILED_LIMIT) {
PrivClose(touch_fd); PrivClose(touch_fd);

View File

@ -65,8 +65,8 @@ typedef enum _touch_event
#define GTP_REG_VERSION 0x8140 #define GTP_REG_VERSION 0x8140
#define LCD_SIZE 320 #define LCD_SIZE 320
#define TOUCH_WIDTH 1024 #define TOUCH_WIDTH 1080
#define TOUCH_HEIGHT 664 #define TOUCH_HEIGHT 720
#define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0]))

View File

@ -77,7 +77,7 @@ static x_err_t ReadRegs(struct HardwareDev* dev, uint8 len, uint8* buf)
// not used in polling mode // not used in polling mode
static void touch_pin_irqhandler(void* arg) static void touch_pin_irqhandler(void* arg)
{ {
// KPrintf("int hdr working.\n"); KPrintf("int hdr working.\n");
if (!SemReleaseFlag) if (!SemReleaseFlag)
{ {
KSemaphoreAbandon(touch_sem); KSemaphoreAbandon(touch_sem);
@ -277,7 +277,7 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param)
char status_reg = 0x80; char status_reg = 0x80;
struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer;
read_param->read_length = 0;
result = KSemaphoreObtain(touch_sem, 10); result = KSemaphoreObtain(touch_sem, 10);
// if (EOK == result) // if (EOK == result)
// { // {
@ -292,15 +292,16 @@ 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].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].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; uint32_t pos_y = 308 - 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].x = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT;
ts_event.fingers[i].y = pos_y;
ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch 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; data->x = ts_event.fingers[ts_event.NBfingers - 1].x;
data->y = ts_event.fingers[ts_event.NBfingers - 1].y; data->y = ts_event.fingers[ts_event.NBfingers - 1].y;
read_param->read_length = ts_event.NBfingers;
SemReleaseFlag = 0; SemReleaseFlag = 0;
// } // }