【LVGL 学习】LVGL 在 arduino 环境的安装

1. 前提条件

  • 使用 arduino IDE开发
  • 使用 ESP32 作为主控
  • 屏幕使用 ST7789 驱动,240*240像素TFT屏幕

注意:屏幕驱动部分不再这个赘述,以后开贴另行发布

2. 安装 LVGL 库

打开 arduino 菜单栏中 -> 项目 -> 加载库 -> 管理库
搜索 LVGL 本人使用版本是8.0.2, 8.0一下版本貌似不支持GIF

在这里插入图片描述
1. 成功安装后,LVGL库就安装到了 首选项中, 项目文件夹位置 一栏中所设置的项目文件夹位置,我这里设置的是把库文件安装在该项目文件下。
在这里插入图片描述
2. 编译, 编译的时候会报各种错误,这里主要是 lv_conf.h 找不到一类的,因为库只给了模板,我们把lvgl文件下的 lv_conf_templet.h 改为 lv_conf.h,然后使能 lv_conf.h 文件
在这里插入图片描述
3. 搜索 lv_conf_internal.h 文件,修改一下 lv_conf.h 的路径,如下图所示:
在这里插入图片描述

3. 工程测试

  1. 在库文件lvgl中example文件下有arduino的测试demo,我们拷贝到我们的自己工程目录,以下是拷贝完毕的
  2. 我的工程没有用到 touchpad 触摸屏幕功能,所以我都去掉了
  3. 我的屏幕背光由ESP32控制,所以加入了背光控制,如果直接点亮可以去掉这个功能

//#include <lv_demo.h>
#include <stdint.h>
#include <lvgl.h>
#include <TFT_eSPI.h>
/*If you want to use the LVGL examples,
  make sure to install the lv_examples Arduino library
  and uncomment the following line.
#include <lv_examples.h>
*/

#include "lv_gif.h"


#define LCD_BL_PIN            5
#define LCD_BL_PWM_CHANNEL    0

TFT_eSPI tft = TFT_eSPI(); /* TFT instance */

/*Change to your screen resolution*/
static const uint32_t screenWidth  = 240;
static const uint32_t screenHeight = 240;

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[ screenWidth * 10 ];

#if LV_USE_LOG != 0
/* Serial debugging */
void my_print( 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值