|
本帖最后由 devcang 于 2022-4-3 14:23 编辑
简单介绍
LVGL —— Light and Versatile Graphics Library,官网https://lvgl.io/,轻量级图形界面库(versatile 本意多才多艺的),MIT协议。特别适合各种嵌入平台。
图片来自官网
要求:
- 16, 32 or 64 bit microcontroller or processor
- > 16 MHz clock speed is recommended
- Flash/ROM: > 64 kB for the very essential components (> 180 kB is recommended)
- RAM:
- Static RAM usage: ~2 kB depending on the used features and objects types
- Stack: > 2kB (> 8 kB is recommended)
- Dynamic data (heap): > 2 KB (> 16 kB is recommended if using several objects). Set by LV_MEM_SIZE in lv_conf.h.
- Display buffer: > "Horizontal resolution" pixels (> 10 × "Horizontal resolution" is recommended)
- One frame buffer in the MCU or in external display controller
- C99 or newer compiler
- Basic C (or C++)
写在前面,这只是试编译,即是编译没错,但不一定能在真机环境远行,因为未对硬件进行具体配置。要想在真机运行,需要详细配置对应的硬件信息——至少屏幕需要配置,要是有触摸屏也要包括到代码里。
(前面发SDL时,有坛友说LVGL很漂亮,昨晚试编译了一下,分享一下过程)
lv_port_linux_frame_buffer ARM-LINUX试编译
0、环境说明
Linux MyServer 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
arm-none-linux-gnueabi-gcc (ctng-1.6.1) 4.4.3
1、下载源码
https://github.com/lvgl/lvgl
https://github.com/lvgl/lv_port_linux_frame_buffer
https://github.com/lvgl/lv_drivers
2、目录
|-lv_port_linux_frame_buffer 本项目
|-lvgl LVGL源码,准备好lv_conf.h,重点#if 1 和 #define LV_USE_DEMO_WIDGETS 1
|-lv_drivers 来自 https://github.com/lvgl/lv_drivers 准备 lv_drv_conf.h 设置 #define USE_FBDEV 1和 #define USE_EVDEV 1
其它依赖的目录路径(如libz.so),根据实际情况。参看 LDFLAGS
3、修改本项目 Makefile,修改路径、或添加文件引用,等
CC ?= arm-linux-gcc
CUR_DIR = ${shell pwd}
LVGL_DIR ?= $(CUR_DIR)
CFLAGS ?= --std=c99 -I$(CUR_DIR)/ -I$(CUR_DIR)/lvgl -I$(CUR_DIR)/lv_drivers
LDFLAGS ?= -L/opt/_arm/lib -lz -lm
BIN = lv_fb_demo
#Collect the files to compile
MAINSRC = ./main.c
include $(CUR_DIR)/lvgl/lvgl.mk
include $(CUR_DIR)/lv_drivers/lv_drivers.mk
CSRCS +=$(CUR_DIR)/mouse_cursor_icon.c
OBJEXT ?= .o
...........(后边的,不用修改)
4、系统环境变量
export CC=arm-linux-gcc
export LDFLAGS=-L/opt/_arm/lib
5、make
编译结果
6、把 lv_fb_demo 下载到试验板,运行测试
大致如是,后期试了,再补充。
官方GH上有多种平台的移植如STM32、ESP32等,还有各种IDE的移植。
补充,替换 lv_conf.h 中定义的tick,main.c中的custom_tick_get 写一个头文件,my_head.h
// #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
// #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#define LV_TICK_CUSTOM_INCLUDE "my_head.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (custom_tick_get()) /*Expression evaluating to current system time in ms*/
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
打赏
-
查看全部打赏
|