在没有ESP32开发板的情况下,可以使用PC仿真,来学习LVGL。
官方介绍可以使用Simulator的IDE有很多,我采用的是VSCODE+PlatformIO。PlatformIO是跨平台、跨架构、多框架的开发工具,由于我之前学习STM32时已经安装过PlatformIO插件,此处不再介绍

官方网址:https://platformio.org/

环境搭建

编辑器-Visual Studio Code:

https://code.visualstudio.com/

安装SDL drivers

Windows

使用MSYS2

pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2


把Mingw-w64 bin 文件夹添加到环境变量中


注意:此处由于我之前下载过MINGW64并且添加到环境变量过,要把之前的删除掉,不然之后编译会报错,找不到路径。

安装上传驱动(可选)

此处无用到

运行

克隆GIT仓库

git clone https://github.com/lvgl/lv_platformio.git

打开VSCODE,用PlatformIO插件打开

点击PlatformIO插件,开始仿真

显示实例程序

如何更改实例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
  ******************************************************************************
  * @file    main.c
  * @author  Ac6
  * @version V1.0
  * @date    01-December-2013
  * @brief   Default main function.
  ******************************************************************************
*/

#include "lvgl.h"
#include "app_hal.h"

#include "demo.h"

int main(void)
{
    lv_init();

    hal_setup();

    demo_create();

    hal_loop();
}

进入demo_create()函数,便可进行更改。实例程序默认的LVGL库为lvgl@~7.11.0,最新的LVGL 8.0我还没有研究怎么进行仿真,在ESP32可运行LVGL 8.0。这两个版本有差别,但都差不多。仿真时默认的输入设备是鼠标,可以添加键盘和编码器设备。