lvgl图形库使用
qt
sdl2依赖,flatpak的
io.qt.QtCreator中编译
# https://github.com/libsdl-org/SDL/releases
./configure --prefix=/home/jcleng/desktop/sdl/out
make
make install
# qt5.1项目: https://github.com/Varanda-Labs/lvgl-qt-sim
# 这个分支 https://github.com/Varanda-Labs/lvgl/archive/e19410f8f8a256609da72cff549598e0df6fa4cf.zip
# 驱动: https://github.com/lvgl/lv_drivers
# 配置lvgl-qt-sim.pro文件,把依赖放进去
HEADERS .h要全部文件写进去
SOURCES cpp/c文件写进去
# sdl2的文件和头文件
LIBS += -L/home/jcleng/desktop/sdl/out/lib
INCLUDEPATH += /home/jcleng/desktop/sdl/out/include
# 编译
/usr/bin/qmake lvgl-qt-sim.pro
/usr/bin/qmake -config release lvgl-qt-sim.pro
make
# 不安装运行
./lvgl-qt-sim
ldd ./lvgl-qt-sim
lv_conf.h 基本配置
// http://lvgl.100ask.org/7.11/documentation/02_porting/02_project.html
// 启用当前配置
#if 1
// 配置分辨率
#define LV_HOR_RES_MAX (480)
#define LV_VER_RES_MAX (272)
直接使用,cmake编译
# 项目 https://github.com/lvgl/lv_port_pc_eclipse 可以直接在linux运行
cmake .
make
./bin/main
LD_LIBRARY_PATH=/nix/store/4llb4ymwy2p7nwlq7imivwk7n2373zdq-SDL2-2.24.2/lib/ ldd ./bin/main
# eclipse 国内源
Window–>Preferences: 搜索Available
把所有的
http://download.eclipse.org/
改为
http://mirrors.ustc.edu.cn/eclipse/
gdb 调试
gdb ./lvgl_test_xmake
run
使用docker编译
docker run -itd -v /home/jcleng/desktop/work/:/home/jcleng/desktop/work/ --name=ub daocloud.io/library/ubuntu:20.04 bash
docker cp ub:/etc/apt/sources.list ./
docker cp ./sources.list ub:/etc/apt/sources.list
https://download.docker.com/linux/ubuntu/dists/xenial/
# https://cran.r-project.org/bin/linux/ubuntu/
docker exec -it ub bash
# docker rm -f ub
apt update
apt install cmake
apt install make
apt install file
# 32位兼容
dpkg --add-architecture i386
apt update
apt install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
cd /home/jcleng/desktop/work/mipseltools-gcc412-lnx26-master/bin
cd /home/jcleng/desktop/work/lvgl_test_xmake/src
rm -rf CMakeCache.txt cmake_install.cmake CMakeFiles
cd /home/jcleng/desktop/work/lvgl_test_xmake/src/lv_drivers
rm -rf CMakeCache.txt cmake_install.cmake CMakeFiles
cd /home/jcleng/desktop/work/lvgl_test_xmake/src/lvgl
rm -rf CMakeCache.txt cmake_install.cmake CMakeFiles
交叉编译
// 工具链 https://github.com/OpenNoah/mipseltools-gcc412-lnx26
// v8.3.7.zip + https://github.com/lvgl/lv_port_linux_frame_buffer 使用lv_port_linux_frame_buffer的配置和文件可以通过
// lv_drivers:
// https://github.com/lvgl/lv_drivers/archive/71830257710f430b6d8d1c324f89f2eab52488f1.zip
// 低于2.6的内核,需要新增3个常量
// mipseltools-gcc412-lnx26-master/mipsel-linux/include/linux/input.h
#define ABS_MT_POSITION_X 0x3a /* Center X surface position */
#define ABS_MT_POSITION_Y 0x3b /* Center Y surface position */
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
// 在lv_drivers中遇到 win32drv.c 编译不过,可以直接删除目录
cmake_minimum_required(VERSION 3.1)
# 设置目标系统
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR mips)
set(CMAKE_C_FLAGS "-std=c99")
# 设置工具链目录
set(TOOL_CHAIN_DIR /home/jcleng/desktop/work/mipseltools-gcc412-lnx26-master)
set(TOOL_CHAIN_INCLUDE ${TOOL_CHAIN_DIR}/include ${TOOL_CHAIN_DIR}/mipsel-linux/include)
set(TOOL_CHAIN_LIB ${TOOL_CHAIN_DIR}/lib ${TOOL_CHAIN_DIR}/mipsel-linux/lib)
# 设置编译器位置
set(CMAKE_C_COMPILER "${TOOL_CHAIN_DIR}/bin/mipsel-linux-gcc")
set(CMAKE_CXX_COMPILER "${TOOL_CHAIN_DIR}/bin/mipsel-linux-g++")
# 设置Cmake查找主路径
set(CMAKE_FIND_ROOT_PATH ${TOOL_CHAIN_DIR}/mipsel-linux)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# 只在指定目录下查找库文件
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
# 只在指定目录下查找头文件
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# 只在指定目录下查找依赖包
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
include_directories(${TOOL_CHAIN_DIR}/include ${TOOL_CHAIN_DIR}/mipsel-linux/include)
set(CMAKE_INCLUDE_PATH ${TOOL_CHAIN_INCLUDE})
set(CMAKE_LIBRARY_PATH ${TOOL_CHAIN_LIB})
project(lvgl_fb)
include_directories(.)
add_subdirectory(lvgl)
add_subdirectory(lv_drivers)
add_executable(${PROJECT_NAME} main.c mouse_cursor_icon.c)
target_link_libraries(${PROJECT_NAME} PRIVATE lvgl lvgl::examples lvgl::demos lvgl::drivers)
# 很多示例
ls lvgl/examples
ls lvgl/examples/widgets/btn/lv_example_btn_1.c