Files
Smart-granary-code/components/MQ-2/include/MQ-2.h
Wang Beihong 79b546632b 添加对额外 UI 资源和火焰状态变量的支持
- 增加了 `ui.h` 中资源数组的大小以容纳新的 UI 元素。
- 更新了 `ui_font_chinese_16.c`,添加了更多中文字符以更好地支持本地化。
- 在 `vars.h` 中添加了用于管理火焰状态的新函数,增强了系统的监测能力。
2026-04-21 02:25:20 +08:00

44 lines
772 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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