Rdzleo 99aef2c4e5 1、新增电池电量ADC检测;
2、ScreenSet界面的电量进度条实施更新和电量文本显示实施更新
2026-02-10 10:42:03 +08:00

30 lines
825 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 "esp_err.h"
#include <stdint.h>
// 电池ADC引脚配置
#define PIN_BAT_ADC 3 // GPIO3
#define BAT_ADC_CHANNEL ADC_CHANNEL_2 // ADC1_CH2
// 分压比(实际电池电压 = ADC测量电压 * 此系数)
// 根据硬件电路中的分压电阻调整1:1分压器设为2
#define BAT_VOLTAGE_DIVIDER 2
// 采样次数(取平均值,提高精度)
#define BAT_SAMPLE_COUNT 32
// 监控间隔(毫秒)
#define BAT_MONITOR_INTERVAL_MS 5000
// 初始化电池ADC检测
esp_err_t battery_init(void);
// 获取电池电压(毫伏)
uint32_t battery_get_voltage_mv(void);
// 获取电池电量百分比0-100
uint8_t battery_get_level(void);
// 启动电池监控任务周期性读取ADC并更新UI
void battery_monitor_start(void);