Rdzleo 4547e9e732 适配ESP32-C3开发板成功
1、原有ESP32-S3功能基本实现,有些小Bug需要修复;
2、RAM内存不够导致Img界面图片显示画质不完整,并且当前未开启蓝牙功能,开机蓝牙功能后RAM内存压力加剧;
2026-02-12 15:45:36 +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 2 // GPIO2
#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);