前言
- 上篇博客整合了lvgl到项目中,采用的是自己编写源码的方式,实现了个简单的界面。
- 实际过程中一般情况开发界面都借助设计工具,这里使用的是gui guider来进行示例记录
项目结构(生成代码路径依然放到项目路径下)
CMakeLists配置(改为引用LVGL的源码)
file(GLOB_RECURSE EmWinSrc
EmWin/Source/*.c
EmWin/Resource/*.c
)
file(GLOB_RECURSE LVGL_SRC
LVGL/Code/*.c
)
set(LVGL_INC
LVGL/Code/custom
LVGL/Code/generated
LVGL/Code/generated/guider_fonts
LVGL/Code/generated/guider_customer_fonts
)
target_sources(${PROJECT_NAME}.elf
PRIVATE
${LVGL_SRC}
)
target_include_directories(${PROJECT_NAME}.elf
PUBLIC
${LVGL_INC}
)
LVGL任务线程调整
/*
* Copyright (c) 2024-2024,shchl
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-4-20 shchl first version
*/
#include "includes.h"
#include "lv_api_map.h"
#if 1
#define APP_TASK_GUI_LVGL_PRIO 15
#define APP_TASK_GUI_LVGL_STK_SIZE 4096
/*
*******************************************************************************************************
* 外部引入变量
*******************************************************************************************************
*/
/*
*******************************************************************************************************
* 变量
*******************************************************************************************************
*/
TX_THREAD gui_lvgl_thread;
VOID *gui_thread_stack_area;
/*
*********************************************************************************************************
* 静态全局变量
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* 函数声明
*********************************************************************************************************
*/
static VOID gui_lvgl_thread_entry(ULONG input);
/*
*********************************************************************************************************
* 外部函数
*********************************************************************************************************
*/
/**
* @brief cpu 状态任务
* @param first_thread 第一个启动的任务线程首地址
*/
int tx_task_gui_lvgl_create() {
UINT status;
gui_thread_stack_area = app_malloc(APP_TASK_GUI_LVGL_STK_SIZE);
if(!gui_thread_stack_area){
tx_printf("app malloc error\r\n");
return -1;
}
status = tx_thread_create(&gui_lvgl_thread, /* 任务控制块地址 */
"gui lvgl thread", /* 任务名 */
gui_lvgl_thread_entry, /* 启动任务函数地址 */
0, /* 传递给任务的参数 */
gui