You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/04/15 14:38:34 UTC

[incubator-nuttx-apps] 02/15: apps/examples/lvgldemo: Update touchpad read callback for LittleVGL V6.1

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 20f3db73170fcde715ec85a99121a372d8d05f8a
Author: Qi Huang <hu...@xiaomi.com>
AuthorDate: Tue Apr 7 00:51:12 2020 +0000

    apps/examples/lvgldemo: Update touchpad read callback for LittleVGL V6.1
    
    Signed-off-by: Qi Huang <hu...@xiaomi.com>
    Change-Id: I8df8ff81832ce651a4c2678d534a6aeb85cff6a7
---
 examples/lvgldemo/tp.c | 33 ++++++++++++++++++---------------
 examples/lvgldemo/tp.h |  6 +++++-
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/examples/lvgldemo/tp.c b/examples/lvgldemo/tp.c
index 18f9c8a..9b48410 100644
--- a/examples/lvgldemo/tp.c
+++ b/examples/lvgldemo/tp.c
@@ -60,7 +60,8 @@
  * Private Data
  ****************************************************************************/
 
-static int fd;static bool calibrated = false;
+static int fd;
+static bool calibrated = false;
 static int x_range;
 static int y_range;
 static int x_offset;
@@ -118,6 +119,7 @@ errout:
  *   Read a TP data and store in 'data' argument
  *
  * Input Parameters:
+ *   indev_drv - Input device handler
  *   data - Store the x, y and state information here
  *
  * 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;
   int nbytes;
@@ -150,7 +152,8 @@ bool tp_read(FAR lv_indev_data_t *data)
       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)
         {
@@ -158,7 +161,6 @@ bool tp_read(FAR lv_indev_data_t *data)
             {
               last_x = sample.point[0].y;
               last_y = sample.point[0].x;
-
             }
           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_y = (int)((int)last_y * LV_VER_RES) / y_range;
 
-
           if (x_inv)
             {
               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;
     }
   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)
-   {
-     last_state = LV_INDEV_STATE_REL;
-   }
+    {
+      last_state = LV_INDEV_STATE_REL;
+    }
 
   /* 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)
     {
-      xy_inv = true;  /*No real change in x horizontally*/
+      /* No real change in x horizontally */
+
+      xy_inv = true;
     }
 
   if (xy_inv)
@@ -285,7 +288,7 @@ void tp_set_cal_values(FAR lv_point_t *ul, FAR lv_point_t *ur,
   calibrated = true;
 
   printf("tp_cal result\n");
-  printf("offset x:%d, y:%d\n",x_offset, y_offset);
-  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("offset x:%d, y:%d\n", x_offset, y_offset);
+  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);
 }
diff --git a/examples/lvgldemo/tp.h b/examples/lvgldemo/tp.h
index e77cab1..ea4ddf2 100644
--- a/examples/lvgldemo/tp.h
+++ b/examples/lvgldemo/tp.h
@@ -46,7 +46,9 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
+
 /* CONFIG_EXAMPLES_LGVLDEMO_MINOR - The minor device number.  Minor=N
  *   corresponds to touchscreen device /dev/input0.  Note this value must
  *   with CONFIG_EXAMPLES_LGVLDEMO_DEVPATH.  Default 0.
@@ -108,6 +110,7 @@ int tp_init(void);
  *   Read a TP data and store in 'data' argument
  *
  * Input Parameters:
+ *   indev_drv - Input device handler
  *   data - Store the x, y and state information here
  *
  * 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