当前位置: 首页 > news >正文

LVGL V9.0基于VS2022仿真搭建

完整Demo,lvgl,lvgl_drivers相关资料下载

链接:https://pan.baidu.com/s/1DNJeHdoaPyfe1BsLb9wjRg
提取码:wov7

其它资料下载

链接:https://pan.baidu.com/s/1nV9jojPEPWSWZdYhaCZWTA
提取码:91j8

下载资料后解压文件及安装VS2022 ,选择通用windows平台开发及Visual Studio进行安装,安装步骤略

在这里插入图片描述

打开VS2022,点击创建新项目

在这里插入图片描述

选择Windows Console Application (C++/WinRT),点击下一步

在这里插入图片描述

输入名程lvgl_v9_sim,选择目录,勾选将解决方案和项目放在同一目录中,点击创建,再点击确定

在这里插入图片描述

在工程目录中新建一个文件夹并命名为lvgl_folder

在这里插入图片描述

将下载的lv_drivers,lvgl两个文件夹复制到lvgl_folder文件中

在这里插入图片描述

将lv_drivers中的lv_drv_conf_template.h和lvgl中的lv_conf_template.h的文件复制到lvgl_folder目录下,并分别命名为lv_drv_conf.h和lv_conf.h

在这里插入图片描述

在工程中分别创建lvgl,lvgl_drivers两个筛选器

在这里插入图片描述
在这里插入图片描述

将lvgl_folder文件夹中的文件分别加入到工程

在这里插入图片描述
在这里插入图片描述

点击显示所有文件,包含添加的文件在项目中

在这里插入图片描述

将lv_drv_conf.h文件中的条件编译总开关打开

  • #if 0改成#if 1
#if 1 /*Set it to "1" to enable the content*/
  • 将USE_WIN32DRV宏设为1
/*----------------------------*  Native Windows (win32drv)*---------------------------*/
#ifndef USE_WIN32DRV
#  define USE_WIN32DRV       1
#endif#if USE_WIN32DRV
/* Scale window by this factor (useful when simulating small screens) */
#  define WIN32DRV_MONITOR_ZOOM        1
#endif

将lv_conf.h中的文件配置如下

  • 编译总开关由#if 0改成#if 1
#if 1 /*Set it to "1" to enable content*/
  • LV_MEM_SIZE宏定义为(1024U * 1024U)
 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/#define LV_MEM_SIZE (1024U * 1024U)          /*[bytes]*/
  • LV_TICK_CUSTOM宏设为1,定义windos.h文件,定义时间函数GetTickCount()
/*Use a custom tick source that tells the elapsed time in milliseconds.*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM#define LV_TICK_CUSTOM_INCLUDE <Windows.h>          /*Header for the system time function*/#define LV_TICK_CUSTOM_SYS_TIME_EXPR (GetTickCount())    /*Expression evaluating to current system time in ms*/
#endif   /*LV_TICK_CUSTOM*/
  • 将宏LV_USE_LOG设为1

/*Enable the log module*/
#define LV_USE_LOG 1
  • 将LV_USE_PERF_MONITOR和LV_USE_MEM_MONITOR设为1

/*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 1
#if LV_USE_PERF_MONITOR#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#endif/*1: Show the used memory and the memory fragmentation* Requires LV_MEM_CUSTOM = 0*/
#define LV_USE_MEM_MONITOR 1
#if LV_USE_MEM_MONITOR#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#endif
  • 将LV_FONT_MONTSERRAT_12和LV_FONT_MONTSERRAT_16设为1
/*Montserrat fonts with ASCII range and some symbols using bpp = 4*https://fonts.google.com/specimen/Montserrat*/
#define LV_FONT_MONTSERRAT_8  0
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 1
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 1
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
#define LV_FONT_MONTSERRAT_24 0
#define LV_FONT_MONTSERRAT_26 0
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0
#define LV_FONT_MONTSERRAT_40 0
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0
  • 在lv_config.h中将demo相关例程宏设为1

/*==================
* EXAMPLES
*==================*//*Enable the examples to be built with the library*/
#define LV_BUILD_EXAMPLES 1/*===================* DEMO USAGE====================*//*Show some widget. It might be required to increase `LV_MEM_SIZE` */
#define LV_USE_DEMO_WIDGETS 1
#if LV_USE_DEMO_WIDGETS#define LV_DEMO_WIDGETS_SLIDESHOW 1
#endif/*Demonstrate the usage of encoder and keyboard*/
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 1/*Benchmark your system*/
#define LV_USE_DEMO_BENCHMARK 1
#if LV_USE_DEMO_BENCHMARK/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/#define LV_DEMO_BENCHMARK_RGB565A8 0
#endif/*Stress test for LVGL*/
#define LV_USE_DEMO_STRESS 1/*Music player demo*/
#define LV_USE_DEMO_MUSIC 1
#if LV_USE_DEMO_MUSIC#define LV_DEMO_MUSIC_SQUARE    0#define LV_DEMO_MUSIC_LANDSCAPE 0#define LV_DEMO_MUSIC_ROUND     0#define LV_DEMO_MUSIC_LARGE     0#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif/*Flex layout demo*/
#define LV_USE_DEMO_FLEX_LAYOUT 0

点击项目菜单,点击属性

在这里插入图片描述

点击C/C++,选择常规,在附加包含目录中加入lvgl_folder,点击应用

在这里插入图片描述
在这里插入图片描述

在main.cpp中换成以下内容,并将main.cpp文件重命名为main.c

#include "lvgl/lvgl.h"
#include "lvgl/demos/music/lv_demo_music.h"
#include "lv_drivers/win32drv/win32drv.h"#define IDI_LVGL                       101int main()
{lv_init();if (!lv_win32_init(GetModuleHandleW(NULL),SW_SHOW,800,480,LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_LVGL)))){return -1;}lv_win32_add_all_input_devices_to_group(NULL);lv_demo_music();while (!lv_win32_quit_signal){lv_task_handler();Sleep(1);}return 0;
}

将C/C++中预编译头,选择不使用预编译头

在这里插入图片描述

在C++预处理器中新增加如下内容

在这里插入图片描述

在链接器,输入,附加依赖项加入以下内容

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib

在这里插入图片描述

编译运行,运行结果如下

在这里插入图片描述

http://www.lryc.cn/news/4314.html

相关文章:

  • 多线程面试题开胃菜2(5道)
  • 第三次作业
  • 基础算法(直接插入,希尔排序,快排,归并,折半查找)
  • 电子学会2022年12月青少年软件编程(图形化)等级考试试卷(一级)答案解析
  • 基于JAVA的超级玛丽设计与实现
  • 硬件工程师入门基础知识(一)基础元器件认识(二)
  • Python-项目实战--贪吃蛇小游戏-游戏框架搭建(2)
  • JVM基础
  • Android 内存优化(基础轮)必看~
  • STM32单片机GSM短信自动存取快递柜
  • 力扣(LeetCode)410. 分割数组的最大值(2023.02.12)
  • 管理还原数据
  • c的关键字有那些
  • 链表OJ(一)
  • MySQL第三次作业
  • Python中的类和对象(7)
  • 【JVM】7种经典的垃圾收集器
  • 2023/2/12总结
  • Linux之正则表达式
  • 前端高频面试题-HTML和CSS篇(一)
  • Redis 专题总结
  • 【Python百日进阶-Web开发-Vue3】Day515 - Vue+ts后台项目2:登录页面
  • 【博客620】prometheus如何优化远程读写的性能
  • redis可视工具AnotherRedisDesktopManager的使用
  • 【idea】idea生产类注释和方法注释
  • jenkins +docker+python接口自动化之jenkins容器安装python3(二)
  • go 命令行工具整理
  • RuntimeError: CUDA out of memory
  • Kubernetes1.25中Redis集群部署实例
  • C++11实现计算机网络中的TCP/IP连接(Windows端)