一、简介
LittlevGL 是一个免费的开源图形库(GUI),具有易于使用的图形元素、美观的视觉效果,支持触摸屏操作,移植简单方便,适用于 MCU级别的设备,支持各类输入输出接口与芯片,支持使用 GPU。
特性:
- LittlevGL 以 C 语言编写,支持 OS,内存占用低(16K RAM,64K Flash);
- LittlevGL 自带了丰富的控件:窗口、按键、标签、列表、图表等,还可以自定义控件;
- 支持很多特效:透明、阴影、自动显示隐藏滚动条、界面切换动画、图标打开关闭动画、平滑的拖拽控件、分层显示、反锯齿、仅耗少量内存的字体等等。
- 超过 30 多种丰富的用户自定义控件,如按钮,滑条,文本框,键盘等
- 支持各种图片类型,可从 Flash 和 SD 卡中读取图片显示
- 采用 UTF-8 编码,支持多语言,多字体的文本
- 支持 Micropython
资料:
二、配置使用
1、获取示例 lv_port_esp32
git clone --recurse-submodules https://github.com/lvgl/lv_port_esp32.git
git clone --recurse-submodules https://gitee.com/JavonPeng/lvgl_port_esp32.git
git submodule update
lv_port_esp32 包含的库:(在 components 文件夹)
注意: 目前master分支:
ESP-IDF 版本要求4.2- 使用的
LVGL 版本:7.9 - 使用的
lv_examples 版本:7.9
2、配置
make menuconfig :
Component config --->
lv_examples configuration --->
LVGL configuration --->
LVGL TFT Display controller --->
LVGL Touch controller --->
Component config → lv_examples configuration :
[ ] Enable printf-ing data in demos and examples.
Select the demo you want to run. (Show demo widgets.) --->
(X) Show demo widgets.
( ) Demonstrate the usage of encoder and keyboard.
( ) Benchmark your system.
( ) Stress test for LVGL.
[*] Slide demo widgets automatically.
Component config → LVGL configuration :
[ ] Set IRAM as LV_ATTRIBUTE_FAST_MEM
[ ] LVGL minimal configuration.
(160) Maximal horizontal resolution to support by the library.
(128) Maximal vertical resolution to support by the library.
Color depth. (16: RGB565) --->
[*] Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI).
[*] Enable anti-aliasing (lines, and radiuses will be smoothed).
(30) Default display refresh period (ms).
(130) DPI (Dots per inch in px).
(30) Small display limit
(50) Medium display limit
(70) Large display limit
Memory manager settings --->
Indev device settings --->
Feature usage --->
Image decoder and cache --->
Compiler Settings --->
HAL Settings --->
Log Settings --->
Debug Settings --->
Font usage --->
Theme usage --->
Text Settings --->
Widgets --->
Component config → LVGL TFT Display controller :
Select predefined display configuration (None) --->
Display orientation (Landscape) --->
Select predefined board pinouts (None) --->
Select a display controller model. (ST7735S) --->
[ ] Use custom display buffer size (bytes)
TFT SPI Bus. (HSPI) --->
TFT Data Transfer Mode (SIO (MOSI/MISO)) --->
TFT SPI Duplex Mode (HALF DUPLEX) --->
[ ] Use custom SPI clock frequency.
[ ] Invert colors in display
[ ] Handle Backlight and TFT power for M5StickC using AXP192. (NEW)
Display Pin Assignments --->
Component config → LVGL TFT Display controller → Display Pin Assignments :
(13) GPIO for MOSI (Master Out Slave In)
[ ] GPIO for MISO (Master In Slave Out)
(14) GPIO for CLK (SCK / Serial Clock)
[*] Use CS signal to control the display
(15) GPIO for CS (Slave Select)
[*] Use DC signal to control the display
(2) GPIO for DC (Data / Command)
(4) GPIO for Reset
[*] Enable control of the display backlight by using an GPIO.
[*] Is backlight turn on with a HIGH (1) logic level?
(27) GPIO for Backlight Control (NEW)
Component config → LVGL Touch controller :
Select a touch panel controller model. (None) --->
(X) None
( ) XPT2046
( ) FT6X06
( ) STMPE610
( ) ADCRAW
( ) FT81X
( ) RA8875
Select a touch panel controller model. (XPT2046) --->
Touch Controller SPI Bus. (VSPI) --->
Touchpanel (XPT2046) Pin Assignments --->
Touchpanel Configuration (XPT2046) --->
Component config → LVGL Touch controller → Touchpanel Configuration (XPT2046) :
(200) Minimum X coordinate value.
(120) Minimum Y coordinate value.
(1900) Maximum X coordinate value.
(1900) Maximum Y coordinate value.
[*] Swap XY.
[*] Invert X coordinate value.
[*] Invert Y coordinate value.
Select touch detection method. (IRQ pin only) --->
Component config → LVGL Touch controller → Touchpanel Configuration (XPT2046) → Select touch detection method. :
(19) GPIO for MISO (Master In Slave Out) (NEW)
(23) GPIO for MOSI (Master Out Slave In) (NEW)
(18) GPIO for CLK (SCK / Serial Clock) (NEW)
(5) GPIO for CS (Slave Select) (NEW)
(25) GPIO for IRQ (Interrupt Request) (NEW)
如果显示异常,修改显示方向 Display orientation 和 水平分辨率、垂直分辨率。
3、报错与修改
报错修改: 选择 ST7735S 驱动后报错:
/home/pjw/Item/esp32_maix/reference/lvgl_port_esp32/components/lvgl_esp32_drivers/lvgl_tft/st7735s.h:31:22: error: 'CONFIG_LV_AXP192_PIN_SDA' undeclared (first use in this function); did you mean 'CONFIG_LV_DISP_PIN_SDA'?
这是因为我没有启用 AXP192 的配置,而代码里面又没有处理导致的。 解决: st7735s.h : 增加是否定义了 CONFIG_LV_M5STICKC_HANDLE_AXP192 的判断:
st7735s.c : i2c 和 axp192 相关的函数全部增加 CONFIG_LV_M5STICKC_HANDLE_AXP192 是否定义的判断
示例修改: create_demo_application 函数默认 st7735s 只显示 hello world 。修改:
//
三、屏幕资料
屏幕外观 | 屏幕接口 |
1.8寸TFT模块 液晶显示模块 SPI串口
1、规格
- 1.8’’TFT
- ST7735S
- 3.3V
- CE6209稳压芯片
- LED接的 LED+
每英寸像素点数(DPI)= 像素个数/英寸 1英寸(inch)=2.54厘米(cm)=25.4毫米(mm)
2、裸屏引脚
3、屏幕原理图
4、稳压芯片资料
|