纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。 Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
2.4 KiB
C
94 lines
2.4 KiB
C
#include "ui_cmd.h"
|
|
|
|
#include <string.h>
|
|
|
|
void screen_home_weather_forecast_time_labels_refresh(void);
|
|
|
|
static QueueHandle_t s_ui_cmd_queue = NULL;
|
|
|
|
void ui_cmd_init(void)
|
|
{
|
|
if (s_ui_cmd_queue != NULL)
|
|
return;
|
|
|
|
/* 非阻塞投递:如果队列满则丢弃,避免卡死业务线程 */
|
|
s_ui_cmd_queue = xQueueCreate(32, sizeof(ui_cmd_t));
|
|
}
|
|
|
|
BaseType_t ui_cmd_set_label_text(lv_obj_t *obj, const char *text)
|
|
{
|
|
if (s_ui_cmd_queue == NULL)
|
|
return pdFAIL;
|
|
if (obj == NULL || text == NULL)
|
|
return pdFAIL;
|
|
|
|
ui_cmd_t cmd = {0};
|
|
cmd.type = UI_CMD_SET_LABEL_TEXT;
|
|
cmd.obj = obj;
|
|
strncpy(cmd.u.text, text, sizeof(cmd.u.text) - 1);
|
|
cmd.u.text[sizeof(cmd.u.text) - 1] = '\0';
|
|
|
|
/* 0 超时,队列满就丢弃 */
|
|
return xQueueSend(s_ui_cmd_queue, &cmd, 0);
|
|
}
|
|
|
|
BaseType_t ui_cmd_set_image_src(lv_obj_t *obj, const void *src)
|
|
{
|
|
if (s_ui_cmd_queue == NULL)
|
|
return pdFAIL;
|
|
if (obj == NULL || src == NULL)
|
|
return pdFAIL;
|
|
|
|
ui_cmd_t cmd = {0};
|
|
cmd.type = UI_CMD_SET_IMAGE_SRC;
|
|
cmd.obj = obj;
|
|
cmd.u.img_src = src;
|
|
return xQueueSend(s_ui_cmd_queue, &cmd, 0);
|
|
}
|
|
|
|
BaseType_t ui_cmd_weather_forecast_time_refresh(void)
|
|
{
|
|
if (s_ui_cmd_queue == NULL)
|
|
return pdFAIL;
|
|
|
|
ui_cmd_t cmd = {0};
|
|
cmd.type = UI_CMD_WEATHER_FORECAST_TIME_REFRESH;
|
|
return xQueueSend(s_ui_cmd_queue, &cmd, 0);
|
|
}
|
|
|
|
void ui_cmd_drain(void)
|
|
{
|
|
if (s_ui_cmd_queue == NULL)
|
|
return;
|
|
|
|
ui_cmd_t cmd;
|
|
while (xQueueReceive(s_ui_cmd_queue, &cmd, 0) == pdTRUE)
|
|
{
|
|
if (cmd.type == UI_CMD_SET_LABEL_TEXT)
|
|
{
|
|
if (cmd.obj && lv_obj_is_valid(cmd.obj))
|
|
{
|
|
lv_label_set_text(cmd.obj, cmd.u.text);
|
|
}
|
|
}
|
|
else if (cmd.type == UI_CMD_SET_IMAGE_SRC)
|
|
{
|
|
if (cmd.obj && lv_obj_is_valid(cmd.obj) && cmd.u.img_src)
|
|
{
|
|
lv_image_set_src(cmd.obj, cmd.u.img_src);
|
|
}
|
|
}
|
|
else if (cmd.type == UI_CMD_WEATHER_FORECAST_TIME_REFRESH)
|
|
{
|
|
screen_home_weather_forecast_time_labels_refresh();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* 天气预报时间标签刷新:更新天气页的时间标签(+2小时、+4小时) */
|
|
void screen_home_weather_forecast_time_labels_refresh(void)
|
|
{
|
|
extern void ui_dispatch_refresh_home_weather_slot_hour_labels(void);
|
|
ui_dispatch_refresh_home_weather_slot_hour_labels();
|
|
}
|