K1Guitar/APP/app_adc.h

30 lines
1008 B
C
Raw Permalink 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.

#ifndef __APP_ADC_H__
#define __APP_ADC_H__
/* 电池采集状态机
* 开机后首采一次 → 之后每 30s 采一次
* 充电中:先停充电芯片 → 等稳定 → 采集 → 恢复充电
* 电压变化才上报 MSG_ID_BATTERY_VALUE */
#define BAT_SAMPLE_INTERVAL_MS 30000 /* 30s 采集一次 */
#define BAT_CHARGE_OFF_WAIT_MS 50 /* 停充电后等稳定 */
typedef enum {
BAT_IDLE, /* 空闲:等开机首采 / 30s 定时 */
BAT_START, /* 开始:检查是否需停充电 */
BAT_WAIT_CHARGE_OFF, /* 等充电芯片停止稳定 */
BAT_SAMPLE, /* 读 ADC + 滑动平均 */
BAT_RESTORE_CHARGE, /* 恢复充电 */
BAT_DONE, /* 映射 + 上报,回 IDLE */
} bat_state_t;
extern bool pick_hold_up;
extern bool usb_charging_state;
extern bool usb_charging_laststate;
extern uint8_t percentage;
void app_adc_scan_all(void);
void app_adc_in1_scan_part(uint8_t channel);
bool app_adc_usb_is_plugged(void);
/* 开机/主动采样后同步 vol_last 与 level避免扫描任务误触发或跳变 */
void app_adc_sync_volume(uint16_t val);
#endif