功能:集成SU-03T语音模块,完善UI代码文档
- 在CMakeLists.txt中添加SU-03T语音模块依赖。 - 在main.cpp中实现SU-03T接收回调函数,处理接收消息。 - 完善各UI源文件文档,包括动作、屏幕和字体,明确模块作用与数据流向。 - 更新主应用逻辑,初始化并启动SU-03T接收器。 - 修改过程中确保兼容性,保留原有接口。
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* 文件: components/JW01/JW01.c
|
||||
* 角色: JW01 气体传感器串口解析与数据提取
|
||||
* 说明:
|
||||
* - 本文件用于实现当前模块的核心功能或接口定义。
|
||||
* - 修改前请先确认该模块与其它任务/外设之间的数据流关系。
|
||||
* - 涉及协议与硬件时,优先保持现有接口兼容,避免联调回归。
|
||||
*/
|
||||
|
||||
#include "JW01.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -13,6 +22,10 @@ static const char *TAG = "JW01";
|
||||
static bool s_inited = false;
|
||||
static uint32_t s_parse_fail_count = 0;
|
||||
|
||||
/* 函数: jw01_parse_binary_frames
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
static esp_err_t jw01_parse_binary_frames(const uint8_t *buf, int len, jw01_data_t *out)
|
||||
{
|
||||
bool found = false;
|
||||
@@ -43,6 +56,10 @@ static esp_err_t jw01_parse_binary_frames(const uint8_t *buf, int len, jw01_data
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* 函数: str_to_upper_inplace
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
static void str_to_upper_inplace(char *s)
|
||||
{
|
||||
while (*s != '\0') {
|
||||
@@ -51,6 +68,10 @@ static void str_to_upper_inplace(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
/* 函数: extract_float_by_key
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
static bool extract_float_by_key(const char *line, const char *key, float *out)
|
||||
{
|
||||
char up_line[160];
|
||||
@@ -91,6 +112,10 @@ static bool extract_float_by_key(const char *line, const char *key, float *out)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 函数: jw01_parse_line
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
static esp_err_t jw01_parse_line(const char *line, jw01_data_t *out)
|
||||
{
|
||||
jw01_data_t data = {0};
|
||||
@@ -115,6 +140,10 @@ static esp_err_t jw01_parse_line(const char *line, jw01_data_t *out)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* 函数: jw01_init
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
esp_err_t jw01_init(void)
|
||||
{
|
||||
if (s_inited) {
|
||||
@@ -148,6 +177,10 @@ esp_err_t jw01_init(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/* 函数: jw01_read
|
||||
* 作用: 执行模块内与函数名对应的业务逻辑。
|
||||
* 重点: 关注输入合法性、返回码与并发安全。
|
||||
*/
|
||||
esp_err_t jw01_read(jw01_data_t *out_data, int timeout_ms)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(out_data != NULL, ESP_ERR_INVALID_ARG, TAG, "out_data is null");
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* 文件: components/JW01/include/JW01.h
|
||||
* 角色: JW01 气体传感器串口解析与数据提取
|
||||
* 说明:
|
||||
* - 本文件用于实现当前模块的核心功能或接口定义。
|
||||
* - 修改前请先确认该模块与其它任务/外设之间的数据流关系。
|
||||
* - 涉及协议与硬件时,优先保持现有接口兼容,避免联调回归。
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
Reference in New Issue
Block a user