功能:集成SU-03T语音模块,完善UI代码文档

- 在CMakeLists.txt中添加SU-03T语音模块依赖。
- 在main.cpp中实现SU-03T接收回调函数,处理接收消息。
- 完善各UI源文件文档,包括动作、屏幕和字体,明确模块作用与数据流向。
- 更新主应用逻辑,初始化并启动SU-03T接收器。
- 修改过程中确保兼容性,保留原有接口。
This commit is contained in:
Wang Beihong
2026-04-22 01:06:10 +08:00
parent 65de57a49c
commit ffdb7065e3
46 changed files with 1341 additions and 12 deletions

View File

@@ -1,3 +1,12 @@
/*
* 文件: components/sntp_time/include/sntp_time.h
* 角色: SNTP 对时与时间刷新
* 说明:
* - 本文件用于实现当前模块的核心功能或接口定义。
* - 修改前请先确认该模块与其它任务/外设之间的数据流关系。
* - 涉及协议与硬件时,优先保持现有接口兼容,避免联调回归。
*/
#pragma once
#include <stdint.h>

View File

@@ -1,3 +1,12 @@
/*
* 文件: components/sntp_time/sntp_time.c
* 角色: SNTP 对时与时间刷新
* 说明:
* - 本文件用于实现当前模块的核心功能或接口定义。
* - 修改前请先确认该模块与其它任务/外设之间的数据流关系。
* - 涉及协议与硬件时,优先保持现有接口兼容,避免联调回归。
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -23,6 +32,10 @@ static TaskHandle_t s_time_refresh_task = NULL;
static time_t get_current_time(void);
/* 函数: publish_sntp_time_var
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void publish_sntp_time_var(const char *value)
{
if (set_var_sntp_time != NULL) {
@@ -30,6 +43,10 @@ static void publish_sntp_time_var(const char *value)
}
}
/* 函数: format_current_time
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void format_current_time(char *buffer, size_t buffer_size)
{
time_t now = get_current_time();
@@ -39,6 +56,10 @@ static void format_current_time(char *buffer, size_t buffer_size)
strftime(buffer, buffer_size, "%Y-%m-%d %H:%M:%S", &timeinfo);
}
/* 函数: sntp_time_refresh_task
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void sntp_time_refresh_task(void *arg)
{
(void)arg;
@@ -52,6 +73,10 @@ static void sntp_time_refresh_task(void *arg)
}
// =========================== 时间相关函数 ===========================
/* 函数: set_timezone
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void set_timezone(void)
{
// 设置中国标准时间(北京时间)
@@ -60,12 +85,20 @@ static void set_timezone(void)
ESP_LOGI(TAG, "时区设置为北京时间 (CST-8)");
}
/* 函数: get_current_time
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static time_t get_current_time(void)
{
// 使用POSIX函数获取时间
return time(NULL);
}
/* 函数: print_current_time
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void print_current_time(void)
{
char buffer[64];
@@ -74,6 +107,10 @@ static void print_current_time(void)
ESP_LOGI(TAG, "当前时间: %s", buffer);
}
/* 函数: start_time_refresh_task_if_needed
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static esp_err_t start_time_refresh_task_if_needed(void)
{
if (s_time_refresh_task != NULL) {
@@ -89,6 +126,10 @@ static esp_err_t start_time_refresh_task_if_needed(void)
return (ok == pdPASS) ? ESP_OK : ESP_ERR_NO_MEM;
}
/* 函数: configure_sntp_servers
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static void configure_sntp_servers(void)
{
ESP_LOGI(TAG, "初始化SNTP服务");
@@ -105,6 +146,10 @@ static void configure_sntp_servers(void)
#endif
}
/* 函数: wait_for_time_sync
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
static esp_err_t wait_for_time_sync(uint32_t timeout_ms)
{
int64_t start_ms = esp_timer_get_time() / 1000;
@@ -123,6 +168,10 @@ static esp_err_t wait_for_time_sync(uint32_t timeout_ms)
}
}
/* 函数: sntp_timp_sync_time
* 作用: 执行模块内与函数名对应的业务逻辑。
* 重点: 关注输入合法性、返回码与并发安全。
*/
esp_err_t sntp_timp_sync_time(uint32_t timeout_ms)
{
if (timeout_ms == 0) {