突然需要用到littleVGL,开始上手。
littleVGL是啥?
先看官网:LVGL (littleVGL应该是由更名,目前官网、github仓库都是lvgl命名了):
LVGL is an open-source graphics library providing everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
简单说,LVGL是一个使用C语言开发的开源图形资源库(GUI),小而美,是嵌入式GUI不错的选择。
官网上Docs目录看着比较简洁,那就跟着Docs开始学习。概述、examples暂时先不看,先看'Get started':
做GUI,模拟器是相对高效的调试手段,直奔‘Simulator on PC’。
模拟器环境搭建
我当前是在window下,LVGL官方推荐的是Visual Studio 或者CodeBlocks,Visual Studio感觉太重,CodeBlocks没用过,还是选CodeBlocks吧。下面图示的地方可以直接跳转到基于CodeBlocks的模拟器指导:
跳转过去,可以看到是https://github.com/lvgl/的仓库,配有使用说明:
下面就按照说明开始搭建模拟器环境:
下载GIT
本来就有,略过。
下载CodeBlocks
建议下载带有MINGW的版本,省去单独配置MINGW的麻烦。
clone 模拟器代码
- 配置key:
usr@DESKTOP-CMO3CLI MINGW64 ~/.ssh
$ ssh-keygen -t ed25519 -C "xxxx@163.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/c/Users/usr/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/usr/.ssh/id_ed25519
Your public key has been saved in /c/Users/usr/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:wEWKf1w3fBvWfb2PDexQ8mnw8/piBsdplqEKiJQOluo xxxx@163.com
The key's randomart image is:
+--[ED25519 256]--+
| .o |
| o o . .o|
| ...+ . * = =|
| + o. o . . @.+o|
| o + ...S .oX= |
|. o ... o+B*.|
|. . . =o +|
| E . +. |
| o.o.|
+----[SHA256]-----+
usr@DESKTOP-CMO3CLI MINGW64 ~/.ssh
$ clip < id_ed25519.pub
- git clone
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/嵌入式/GUI/LVGL
$ git clone git@github.com:lvgl/lvgl.git
Cloning into 'lvgl'...
remote: Enumerating objects: 61505, done.
remote: Counting objects: 100% (734/734), done.
remote: Compressing objects: 100% (439/439), done.
下载还是比较慢,试了几个方法,也不是太好用,设置代理勉强可以下载(速度不太稳定),哪位大神有相对简单稳定的方法吗?
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/嵌入式/GUI/LVGL/code
$ git config --global http.proxy 127.0.0.1:1081
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/嵌入式/GUI/LVGL/code
$ git config --global https.proxy 127.0.0.1:1081
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/嵌入式/GUI/LVGL/code
$ git config --global http.proxy
127.0.0.1:1081
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/嵌入式/GUI/LVGL/code
$ git config --global https.proxy
127.0.0.1:1081
说明上,需要使用git submodule update --init --recursive
来继续下载lvgl、lv_demos、lv_drivers文件夹,不过我这下下载失败,就分别clone 对应仓库了。
- 编译运行模拟器
用CodeBlocks打开下载的模拟器工程,F9居然报错。查看错误提示,对比发现:lv_port_win_codeblocks是基于lv_demos、lvgl仓库v8.1的版本,不同版本的结构体定义有差异,导致编译失败,那么切换一下分支:
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/built_in/GUI/LVGL/code/lv_port_win_codeblocks/lv_demos (master)
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/dev
remotes/origin/interactive_docs
remotes/origin/master
remotes/origin/release/v5
remotes/origin/release/v6
remotes/origin/release/v7
remotes/origin/release/v8.0
remotes/origin/release/v8.1
usr@DESKTOP-CMO3CLI MINGW64 /e/workspace/built_in/GUI/LVGL/code/lv_port_win_codeblocks/lv_demos (master)
$ git checkout -b v8.1 origin/release/v8.1
Switched to a new branch 'v8.1'
Branch 'v8.1' set up to track remote branch 'release/v8.1' from 'origin'.
重新编译,OK了: