WhyCan Forum(哇酷开发者社区)

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn

您尚未登录。

#1 2020-09-13 23:52:31

TeveT
会员
注册时间: 2019-07-01
累计积分: 23

荔枝派zero-V3S搞上Lvgl7.0带上触摸

如题,这玩意儿很多人都lu过成功了。
老规矩上过程:
1、clone
https://github.com/lvgl/lv_port_linux_frame_buffer.git
2、改Makefile
#CC ?= gcc
CC := arm-linux-gnueabihf-gcc

3、make

4、加触摸
荔枝派zero 已经有电阻屏了,直接用 evdev,校准也搞一下,diff一波:

diff --git a/lv_drv_conf.h b/lv_drv_conf.h
index 975c7b4..3623d2d 100644
--- a/lv_drv_conf.h
+++ b/lv_drv_conf.h
@@ -314,18 +314,18 @@
 #endif
 
 /*-------------------------------------------------
  * Mouse or touchpad as evdev interface (for Linux based systems)
  *------------------------------------------------*/
 #ifndef USE_EVDEV
-#  define USE_EVDEV           0
+#  define USE_EVDEV           1
 #endif
 
 #if USE_EVDEV
-#  define EVDEV_NAME   "/dev/input/event0"        /*You can use the "evtest" Linux tool to get the list of devices and test them*/
+#  define EVDEV_NAME   "/dev/input/event1"        /*You can use the "evtest" Linux tool to get the list of devices and test them*/
 #  define EVDEV_SWAP_AXES         0               /*Swap the x and y axes of the touchscreen*/
 
 #  define EVDEV_SCALE             0               /* Scale input, e.g. if touchscreen resolution does not match display resolution */
@@ -334,11 +334,11 @@
 #    define EVDEV_SCALE_VER_RES     (4096)          /* Vertical resolution of touchscreen */
 #  endif  /*EVDEV_SCALE*/
 
-#  define EVDEV_CALIBRATE         0               /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
+#  define EVDEV_CALIBRATE         1               /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
 #  if EVDEV_CALIBRATE
-#    define EVDEV_HOR_MIN   3800                    /*If EVDEV_XXX_MIN > EVDEV_XXX_MAX the XXX axis is automatically inverted*/
-#    define EVDEV_HOR_MAX   200
-#    define EVDEV_VER_MIN   200
+#    define EVDEV_HOR_MIN   200                    /*If EVDEV_XXX_MIN > EVDEV_XXX_MAX the XXX axis is automatically inverted*/
+#    define EVDEV_HOR_MAX   3800
+#    define EVDEV_VER_MIN   400
 #    define EVDEV_VER_MAX   3800
 #  endif  /*EVDEV_SCALE*/
 #endif  /*USE_EVDEV*/

别忘了初始化加入触摸设备注册一下回调函数:

diff --git a/main.c b/main.c
index d286cc7..317a604 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,8 @@
 #include "lvgl/lvgl.h"
 #include "lv_drivers/display/fbdev.h"
 #include "lv_examples/lv_examples.h"
+#include "lv_drivers/indev/evdev.h"
+#include "lvgl/src/lv_hal/lv_hal_indev.h"
 #include <unistd.h>
 #include <pthread.h>
 #include <time.h>
@@ -30,6 +32,14 @@ int main(void)
     disp_drv.flush_cb = fbdev_flush;
     lv_disp_drv_register(&disp_drv);
 
+
+     lv_indev_drv_t indev_drv;
+     lv_indev_drv_init(&indev_drv);          /*Basic initialization*/
+     evdev_init();
+     indev_drv.type = LV_INDEV_TYPE_POINTER; /*See below.*/
+     indev_drv.read_cb = evdev_read;            /*See below.*/
+     lv_indev_drv_register(&indev_drv);      /*Register the driver in LittlevGL*/
+
     /*Create a Demo*/
     lv_demo_widgets();

再编译一下。
起飞!

加图片我还不是很熟悉,lvgl7.0 懂的都懂。

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB