apps/examples/lvgldemo: Update touchpad read callback for LittleVGL V6.1

Signed-off-by: Qi Huang <huangqi3@xiaomi.com>
Change-Id: I8df8ff81832ce651a4c2678d534a6aeb85cff6a7
This commit is contained in:
Qi Huang 2020-04-07 00:51:12 +00:00 committed by Alan Carvalho de Assis
parent abdc745412
commit 20f3db7317
2 changed files with 23 additions and 16 deletions

View File

@ -60,7 +60,8 @@
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
static int fd;static bool calibrated = false; static int fd;
static bool calibrated = false;
static int x_range; static int x_range;
static int y_range; static int y_range;
static int x_offset; static int x_offset;
@ -118,6 +119,7 @@ errout:
* Read a TP data and store in 'data' argument * Read a TP data and store in 'data' argument
* *
* Input Parameters: * Input Parameters:
* indev_drv - Input device handler
* data - Store the x, y and state information here * data - Store the x, y and state information here
* *
* Returned Value: * Returned Value:
@ -125,7 +127,7 @@ errout:
* *
****************************************************************************/ ****************************************************************************/
bool tp_read(FAR lv_indev_data_t *data) bool tp_read(struct _lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
{ {
struct touch_sample_s sample; struct touch_sample_s sample;
int nbytes; int nbytes;
@ -150,7 +152,8 @@ bool tp_read(FAR lv_indev_data_t *data)
return false; return false;
} }
if (sample.point[0].flags & TOUCH_DOWN || sample.point[0].flags & TOUCH_MOVE) if (sample.point[0].flags & TOUCH_DOWN
|| sample.point[0].flags & TOUCH_MOVE)
{ {
if (calibrated) if (calibrated)
{ {
@ -158,7 +161,6 @@ bool tp_read(FAR lv_indev_data_t *data)
{ {
last_x = sample.point[0].y; last_x = sample.point[0].y;
last_y = sample.point[0].x; last_y = sample.point[0].x;
} }
else else
{ {
@ -174,7 +176,6 @@ bool tp_read(FAR lv_indev_data_t *data)
last_x = (int)((int)last_x * LV_HOR_RES) / x_range; last_x = (int)((int)last_x * LV_HOR_RES) / x_range;
last_y = (int)((int)last_y * LV_VER_RES) / y_range; last_y = (int)((int)last_y * LV_VER_RES) / y_range;
if (x_inv) if (x_inv)
{ {
last_x = LV_HOR_RES - last_x; last_x = LV_HOR_RES - last_x;
@ -194,13 +195,13 @@ bool tp_read(FAR lv_indev_data_t *data)
last_state = LV_INDEV_STATE_PR; last_state = LV_INDEV_STATE_PR;
} }
else if (sample.point[0].flags & TOUCH_UP) else if (sample.point[0].flags & TOUCH_UP)
{ {
last_state = LV_INDEV_STATE_REL; last_state = LV_INDEV_STATE_REL;
} }
else if (sample.point[0].flags & TOUCH_UP) else if (sample.point[0].flags & TOUCH_UP)
{ {
last_state = LV_INDEV_STATE_REL; last_state = LV_INDEV_STATE_REL;
} }
/* Update touchpad data */ /* Update touchpad data */
@ -236,7 +237,9 @@ void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur,
if (abs(ul->x - ur->x) < LV_HOR_RES / 2) if (abs(ul->x - ur->x) < LV_HOR_RES / 2)
{ {
xy_inv = true; /*No real change in x horizontally*/ /* No real change in x horizontally */
xy_inv = true;
} }
if (xy_inv) if (xy_inv)
@ -285,7 +288,7 @@ void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur,
calibrated = true; calibrated = true;
printf("tp_cal result\n"); printf("tp_cal result\n");
printf("offset x:%d, y:%d\n",x_offset, y_offset); printf("offset x:%d, y:%d\n", x_offset, y_offset);
printf("range x:%d, y:%d\n",x_range, y_range); printf("range x:%d, y:%d\n", x_range, y_range);
printf("invert x/y:%d, x:%d, y:%d\n\n", xy_inv,x_inv,y_inv); printf("invert x/y:%d, x:%d, y:%d\n\n", xy_inv, x_inv, y_inv);
} }

View File

@ -46,7 +46,9 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* CONFIG_EXAMPLES_LGVLDEMO_MINOR - The minor device number. Minor=N /* CONFIG_EXAMPLES_LGVLDEMO_MINOR - The minor device number. Minor=N
* corresponds to touchscreen device /dev/input0. Note this value must * corresponds to touchscreen device /dev/input0. Note this value must
* with CONFIG_EXAMPLES_LGVLDEMO_DEVPATH. Default 0. * with CONFIG_EXAMPLES_LGVLDEMO_DEVPATH. Default 0.
@ -108,6 +110,7 @@ int tp_init(void);
* Read a TP data and store in 'data' argument * Read a TP data and store in 'data' argument
* *
* Input Parameters: * Input Parameters:
* indev_drv - Input device handler
* data - Store the x, y and state information here * data - Store the x, y and state information here
* *
* Returned Value: * Returned Value:
@ -115,7 +118,8 @@ int tp_init(void);
* *
****************************************************************************/ ****************************************************************************/
bool tp_read(FAR lv_indev_data_t *data); bool tp_read(FAR struct _lv_indev_drv_t *indev_drv,
FAR lv_indev_data_t *data);
/**************************************************************************** /****************************************************************************
* Name: tp_read * Name: tp_read