esp32 lvgl学习2:乐鑫esp_lvgl_port使用

接着前面一节内容esp32 lvgl学习1:为idf增加依赖库,拉取lvgl代码-CSDN博客

欢迎关注我们虫洞ESP32开发板虫洞ESP32-S3...-淘宝网 (taobao.com)

LVGL库拉下来是需要进行一些配置的,比如输入配置:触摸屏、鼠标按键、编码器等,输出设备一般是一些屏幕,比如串口屏,i2c或者spi、rgb屏,再或者是mipi屏幕等等,另外还有内存的配置,加速器的配置,显存配置等等,这些LVGL都给了一套接口,只要按照其配置要求进行配置基本就差不多了,这里Set up a project(设置项目) — LVGL 文档 (100ask.net)介绍了一下新项目的配置;

但是乐鑫提供了一个他们封装好的组件esp_lvgl_port,利用这个组件,可以快速的在esp32上面运行lvgl,接下来我们学习一下乐鑫esp_lvgl_port组件。

一、项目添加esp_lvgl_port

在乐鑫组件网查lvgl Search • ESP Component Registry (espressif.com)选择这个

看readme介绍,这里就不重复了,看右边这里告诉我们添加组件的方法idf.py add-dependency "espressif/esp_lvgl_port^2.3.2"

运行后,项目yml文件应该多了esp_lvgl_port的信息

我们重新配置一下芯片idf.py set-target esp32s3,可以看到项目多了esp_lvgl_port和lvgl的代码

在esp_lvgl_port目录下src文件夹比较重要,这里的文件是我们运行LVGL主要处理的文件,看文件名字大致知道里面实现的内容

二、配置lvgl

我运行DEMO_MUSIC主要开启一下几项配置

CONFIG_LV_CONF_SKIP=y
CONFIG_LV_USE_ST7789=y
CONFIG_LV_USE_DEMO_MUSIC=y
CONFIG_LV_FONT_MONTSERRAT_12=y
CONFIG_LV_FONT_MONTSERRAT_14=y
CONFIG_LV_FONT_MONTSERRAT_16=y

# CONFIG_LV_USE_BUILTIN_MALLOC is not set
CONFIG_LV_USE_CLIB_MALLOC=y

我们板子没有触摸屏,配置CONFIG_LV_DEMO_MUSIC_AUTO_PLAY可以让例程自动运行;

当然,你也可以直接用esp_lvgl_port里面的例子配置。

三、显示屏配置lcd_init

这个espressif/esp_lvgl_port • v2.3.2 • ESP Component Registry 的Usage里介绍了怎么使用,里面用的正好是我们的st7789驱动

这里主要是配置IO和spi、屏幕分辨率之类的,大家可以参照esp-who/components/modules/lcd/who_lcd.c进行配置;

像触摸屏、键盘的,可以都屏蔽掉,先把lvgl运行起来;最后参考esp-who/chde_example/chde_lvgl/lcd/managed_components/espressif__esp_lvgl_port/examples/rgb_lcd/main/main.c  调用demo函数

四、编译运行

最后编译,把其他报错解决,应该就可以了

好像demo最小分辨是280,我们屏幕分辨率小一点,有的显示不完整,效果可以看这个视频虫洞CHD-ESP32-S3-EYE开箱评测无线图传LVGL-CSDN直播

五、按键的使用

我们虫洞开发板使用了按键作为输入设备,需要用到button库espressif/button • v3.3.1 • ESP Component Registry

增加方法和lvgl一样idf.py add-dependency "espressif/button^3.3.1"

增加的时候需要设置好adc的范围,如果不知道的话,可以在esp-who/chde_example/chde_lvgl/lcd/managed_components/espressif__button/button_adc.c : 307附件增加adc值的打印;

最后想使用button,得用到group,

也就是说,先把button与group绑定,然后在group中加入obj,这样就可以通过button处理我们的obj了;

由于精力有限,这里我就不往下操作了,如果大家感兴趣,可以自动百度教程。

### ESP LVGL Port 7735 Issue Solution When dealing with issues related to `esp_lvgl_port` specifically around port 7735, it's important to understand that this typically pertains to integrating the Littlev Graphics Library (LVGL) with Espressif’s ESP32 microcontroller platform. The integration process can encounter several challenges including configuration settings and library compatibility. For resolving an issue associated with `esp_lvgl_port`, one should ensure proper initialization of both hardware resources and software components involved in rendering graphical interfaces on devices using ESP32. Common troubleshooting steps include verifying display driver configurations, ensuring correct SPI/I2C bus setup for communication between MCU and display module, as well as confirming that all necessary dependencies are included within project files[^1]. Additionally, specific problems might arise from mismatched versions of libraries used during development versus those required by the target environment. Therefore, checking version compatibilities among lvgl, espidf frameworks, and any other third-party modules employed becomes crucial. If custom modifications were made to adapt lvgl functionalities onto esp platforms, reviewing these changes against official documentation could also help identify potential sources of malfunctioning behavior observed at runtime when utilizing port number like 7735 which may be part of network services rather than directly linked to graphic operations but still relevant depending upon application context[^2]. In cases where direct support or more detailed guidance is needed regarding particular aspects such as networking ports alongside GUI implementations on embedded systems based on ESP chips running LVGL graphics engine, consulting community forums dedicated to either technology stack would provide valuable insights contributed by experienced developers who have faced similar scenarios before. ```c // Example C code snippet showing basic structure for initializing LVGL on ESP32. #include "lvgl/lvgl.h" void init_disp_drv(lv_disp_draw_buf_t *draw_buf, lv_color_t *buf1){ static lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); disp_drv.draw_buf = draw_buf; /* Other parameter setups */ lv_disp_drv_register(&disp_drv); } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虫洞嵌入式

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值