LVGL 移植
LVGL源码
https://github.com/lvgl/lvgl/tree/release/v8.3
主要文件
// 其余文件根据自己需要
- examples
- env_support
- src
lv_conf.h
lvgl.h
接口对接
examples
中port
文件夹,其中有显示接口,触控接口
将需要的对接文件复制到根目录,并改文件中的 #if 0
为#if 1
显示对接
定义屏幕尺寸在 lv_conf.h
#define MY_DISP_HOR_RES 240
#define MY_DISP_VER_RES 240
双缓存刷新和单缓存刷新在lv_port_disp.c
第 87 行
对接画点函数在lv_port_disp.c
第 167 行
输入对接
例子
#include <math.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#include "GC9A01.h"
#include "LVGL/lvgl.h"
#include "lv_port_disp.h"
#include "benchmark/lv_demo_benchmark.h"
#include "ui.h"
void lv_ex_label(void) {
lv_obj_t *label = lv_label_create(lv_scr_act());//创建一个标签
lv_label_set_recolor(label, true);//通过内联命令启用重新着色
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);//使用比对象大小更长的文本设置标签的行为
lv_obj_set_width(label, 240);
lv_label_set_text_fmt(label, "#ff0000 6666666666666666666666666666666666666666666666#");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 10);//对齐方式
}
void LCD(void * arg)
{
lv_init();
lv_port_disp_init();
//lv_demo_benchmark();
//lv_ex_label();
ui_init();
while (vTaskDelay(1),true)
{
lv_task_handler();
GC9A01_Update();
}
}
void lv_tick_task() {
lv_tick_inc(10);
}
void app_main(void)
{
const esp_timer_create_args_t periodic_timer_args = {
.callback = &lv_tick_task,
.name = "periodic_gui"
};
esp_timer_handle_t periodic_timer;
esp_timer_create(&periodic_timer_args, &periodic_timer);
esp_timer_start_periodic(periodic_timer, 10000);
xTaskCreate(LCD, "Test LCD", 24 * 1024, NULL, tskIDLE_PRIORITY, NULL);
License:
CC BY 4.0