特性 (UI):实现包含屏幕、图像和字体的 UI 组件
新增资源文件:添加了字体、图像和屏幕相关的头文件与源文件。 定义数据结构:创建了用于描述字体和图像的数据结构。 实现主屏逻辑:实现了主屏幕的创建函数以及周期性刷新(tick)函数。 集成 LVGL 管理:集成了 LVGL 主题初始化及屏幕管理功能。 添加 UI 初始化:新增 UI 初始化及刷新函数,用于管理界面更新。 重构主入口:重构主应用程序入口,以支持 UI 任务及 FreeRTOS 多任务调度。 更新构建配置:更新了 CMakeLists 及组件配置,以包含新的依赖项。
This commit is contained in:
50
main/main.cpp
Executable file
50
main/main.cpp
Executable file
@@ -0,0 +1,50 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "wifi-connect.h"
|
||||
#include "ws2812.h"
|
||||
#include "esp_lvgl_port.h" // 包含 LVGL 端口头文件,提供 LVGL 相关的类型定义和函数声明
|
||||
#include "lvgl_st7789_use.h" // 使用EEZStudio提供的LVGL和ST7789驱动,便于后续扩展
|
||||
#include "ui.h" // 使用EEZStudio提供的ui组件,便于后续扩展
|
||||
#include "screens.h" // 包含屏幕ID定义
|
||||
|
||||
|
||||
static void ui_task(void *arg); // 声明UI更新任务函数
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
wifi_connect_init(); // 初始化 Wi-Fi 配网模块
|
||||
|
||||
start_lvgl_demo(); // 初始化 LVGL 和 LCD 显示
|
||||
// 初始化 UI 组件(需在 LVGL 锁内进行对象创建)
|
||||
lvgl_port_lock(0);
|
||||
ui_init();
|
||||
lvgl_port_unlock();
|
||||
// 创建一个 FreeRTOS 任务来更新 UI 显示(字符串拼接需要更多栈空间)
|
||||
xTaskCreate(ui_task, "ui_task", 4096, NULL, 10, NULL);
|
||||
ws2812_start_task(); // 启动 WS2812 LED 灯控制任务,大小为 4096 字节,优先级为 5
|
||||
for (;;)
|
||||
{
|
||||
vTaskDelay(100000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UI 任务函数
|
||||
*
|
||||
* 负责定期驱动 UI 刷新,并实现屏幕自动轮播。
|
||||
*
|
||||
* @param arg 任务参数(未使用)
|
||||
*/
|
||||
static void ui_task(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
lvgl_port_lock(0);
|
||||
ui_tick();
|
||||
lvgl_port_unlock();
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user