修改配置文件
[env:esp32-c3-devkitm-1]
;平台
platform = espressif32@5.4.0
;模块
board = esp32-c3-devkitm-1
;闪存芯片接口方式
board_build.flash_mode = dio
;框架
framework = espidf
;串口监视波特率
monitor_speed = 115200
;串口监视过滤器 解码异常 颜色展示
monitor_filters = direct, esp32_exception_decoder
;内置调试器 重点是配置这个
debug_tool = esp-builtin
安装依赖
我这里git拉取都使用的ssh的方式,如果是http的方式,自己修改一下连接
LVGL 依赖库
git submodule add -b release/v7 git@github.com:lvgl/lvgl.git components/lvgl
ESP32 芯片系列的 LVGL 驱动库
git submodule add git@github.com:lvgl/lvgl_esp32_drivers.git components/lvgl_esp32_drivers
直接编译会提示'SPI_HOST_MAX' undeclared
错误
components\lvgl_esp32_drivers\lvgl_helpers.c: In function 'lvgl_spi_driver_init':
components\lvgl_esp32_drivers\lvgl_helpers.c:157:28: error: 'SPI_HOST_MAX' undeclared (first use in this function); did you mean 'GPIO_PORT_MAX'?
assert((0 <= host) && (SPI_HOST_MAX > host));
在components\lvgl_esp32_drivers\lvgl_helpers.h
头部增加
#define SPI\_HOST\_MAX 2
在components\lvgl_esp32_drivers
目录提交一下git更改
Lvgl 示例
git submodule add -b release/v7 git@github.com:littlevgl/lv_examples.git components/lv_examples/lv_examples
为了等下测试方便,我们这里自己新增一些文件
增加自定义文件
增加文件:components\lv_examples\CMakeLists.txt
if(ESP_PLATFORM)
file(GLOB_RECURSE SOURCES lv_examples/*.c)
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS .
REQUIRES lvgl)
else()
message(FATAL_ERROR "LVGL LV examples: ESP_PLATFORM is not defined. Try reinstalling ESP-IDF.")
endif()
增加文件:components\lv_examples\component.mk
#
# Component Makefile
#
CFLAGS += -DLV_LVGL_H_INCLUDE_SIMPLE
COMPONENT_SRCDIRS := lv_examples \
lv_examples/src/lv_demo_benchmark \
lv_examples/src/lv_demo_keypad_encoder \
lv_examples/src/demo_stress \
lv_examples/src/lv_demo_widgets \
lv_examples/src/lv_ex_style \
lv_examples/src/lv_ex_widgets \
lv_examples/assets
COMPONENT_ADD_INCLUDEDIRS := $(COMPONENT_SRCDIRS) .
增加文件:components\lv_examples\Kconfig
# Kconfig for lv\_examples v7.4.0
menu "lv\_examples configuration"
config LV_EX_PRINTF
bool "Enable printf-ing data in demos and examples."
choice LV_EX_CHOICE
prompt "Select the demo you want to run."
default LV_USE_DEMO_WIDGETS
confi