57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
/**
|
|
* @file ui_task.c
|
|
* @brief UI 主任务:等待网络就绪 -> 初始化显示/菜单/推流 -> 周期刷新
|
|
* @note 单任务内同时驱动 LVGL 刷新与网络推流轮询,避免任一方阻塞导致界面不刷新。
|
|
*/
|
|
#include "ui_task.h"
|
|
|
|
#include "cmsis_os.h"
|
|
#include "sys_events.h"
|
|
|
|
#include "ui_port.h"
|
|
#include "ui_menu.h"
|
|
#include "ui_net_sink.h"
|
|
|
|
#define DBG_TAG "[UI_TASK]"
|
|
#include "dbg_log.h"
|
|
|
|
static void ui_task_wait_net_ready(void)
|
|
{
|
|
if (sys_evtHandle != NULL) {
|
|
osEventFlagsWait(sys_evtHandle, SYS_EVT_NET_READY,
|
|
osFlagsWaitAny, osWaitForever);
|
|
}
|
|
}
|
|
|
|
void ui_task_func(void *argument)
|
|
{
|
|
(void)argument;
|
|
|
|
DBG_INFO("UI task: started, wait net ready");
|
|
ui_task_wait_net_ready();
|
|
DBG_INFO("UI task: net ready, init port");
|
|
|
|
DBG_INFO("UI task: ui_port_init enter");
|
|
if (ui_port_init() != 0) {
|
|
DBG_ERROR("UI port init: FAIL");
|
|
for (;;) { osDelay(1000); }
|
|
}
|
|
DBG_INFO("UI port init: OK");
|
|
DBG_INFO("UI task: ui_menu_init enter");
|
|
if (ui_menu_init() != 0) {
|
|
DBG_ERROR("UI menu init: FAIL");
|
|
for (;;) { osDelay(1000); }
|
|
}
|
|
DBG_INFO("UI menu init: OK");
|
|
if (ui_net_sink_start(UI_NET_SINK_PORT) != 0) {
|
|
DBG_ERROR("UI net sink: start FAIL");
|
|
}
|
|
DBG_INFO("UI net sink: started (port %u)", (unsigned)UI_NET_SINK_PORT);
|
|
|
|
while (1) {
|
|
ui_port_step(10);
|
|
ui_net_sink_poll();
|
|
osDelay(10);
|
|
}
|
|
}
|