- 在CMakeLists.txt中添加SU-03T语音模块依赖。 - 在main.cpp中实现SU-03T接收回调函数,处理接收消息。 - 完善各UI源文件文档,包括动作、屏幕和字体,明确模块作用与数据流向。 - 更新主应用逻辑,初始化并启动SU-03T接收器。 - 修改过程中确保兼容性,保留原有接口。
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
/*
|
||
* 文件: components/MQ-2/include/MQ-2.h
|
||
* 角色: MQ-2 模拟气体传感器采样与百分比映射
|
||
* 说明:
|
||
* - 本文件用于实现当前模块的核心功能或接口定义。
|
||
* - 修改前请先确认该模块与其它任务/外设之间的数据流关系。
|
||
* - 涉及协议与硬件时,优先保持现有接口兼容,避免联调回归。
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <stdbool.h>
|
||
#include <stdint.h>
|
||
|
||
#include "esp_err.h"
|
||
#include "esp_adc/adc_oneshot.h"
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
// ESP32-S3: GPIO8 -> ADC1_CHANNEL_7
|
||
#define MQ2_ADC_GPIO 8
|
||
|
||
/**
|
||
* @brief 初始化 MQ-2 ADC 通道
|
||
*/
|
||
esp_err_t mq2_init(void);
|
||
|
||
/**
|
||
* @brief 读取 MQ-2 原始 ADC 值(0~4095)
|
||
*/
|
||
esp_err_t mq2_read_raw(int *raw_out);
|
||
|
||
/**
|
||
* @brief 读取 MQ-2 归一化百分比(0~100)
|
||
*/
|
||
esp_err_t mq2_read_percent(float *percent_out);
|
||
|
||
/**
|
||
* @brief 根据阈值判断是否疑似有害气体/烟雾超标
|
||
*/
|
||
bool mq2_is_alarm(float percent, float threshold_percent);
|
||
|
||
/**
|
||
* @brief 获取 MQ-2 使用的 ADC oneshot 句柄(ADC1)
|
||
*/
|
||
adc_oneshot_unit_handle_t mq2_get_adc_handle(void);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|