Rdzleo d4303f46fe ESP32-S3按键版非AI电子吧唧代码初始化
1、本项目由Dzbj_ESP32_S3项目复制而来,暂未开始按键功能开发;
2、使用此版本进行按键控制电子吧唧、当前开发板屏幕为非触摸屏;
2026-03-25 09:48:26 +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);