优化程序架构

This commit is contained in:
2026-08-25 14:59:39 +08:00
parent d5ec6ecde0
commit 5252471aca
25 changed files with 2964 additions and 1608 deletions
+12 -17
View File
@@ -1,12 +1,15 @@
/******************************************************************************
* @file app_led.h
* @brief CBC2 灯效优先级:充电 > 配对 > 软关 > 低电 > 切模式闪 > 开机绿灯提示后灭
* @brief CBC2 灯效:红绿独立通道,充电红与待机绿可同时亮
* @author cyWu <1917507415@qq.com>
* @date 2026.08.25
* @version V1.1.0
* @version V2.0.0
* @history
* - V1.0.0, 2026.08.21, cyWu, 首次发布
* - V1.1.0, 2026.08.25, cyWu, 开机绿灯只提示几秒,避免待机常亮耗电
* - V2.0.0, 2026.08.25, cyWu, 改用充电板 LED 事件表
* - V2.1.0, 2026.08.25, cyWu, 改为自己从 app_power/app_pair 取数,
* 调用方不用再手填 AppLedCtx_t
******************************************************************************/
#ifndef __APP_LED_H__
@@ -19,14 +22,6 @@ typedef enum {
APP_LED_ERR_NOT_INIT
} AppLed_Ret_t;
typedef struct {
uint8_t charge_led; /**< 0=无 1=充电红常亮 2=充满绿常亮 */
uint8_t pairing; /**< 1=配对中绿快闪 */
uint8_t app_power; /**< DP0,为 0 则功能灯灭 */
uint8_t low_bat; /**< 1=低电红闪 */
uint8_t life_on; /**< 1=允许显示开机灯效 */
} AppLedCtx_t;
/**
* @brief 灯效初始化,先全灭
* @return APP_LED_OK=成功
@@ -34,12 +29,13 @@ typedef struct {
AppLed_Ret_t app_led_init(void);
/**
* @brief 按优先级刷新灯
* @param ctx 充电/配对/开关/低电状态,不可为空
* @param dt 距上次调用的毫秒数
* @brief 按优先级刷新灯:充电/低电从 app_power 取,配对从 app_pair 取,
* 只有“功能是否开”这一项由调用方(app_function)传入
* @param dt 距上次调用的毫秒数
* @param app_power 1=功能开(DP0),0=功能关,功能灯全灭
* @return 无
*/
void app_led_tick_1ms(const AppLedCtx_t *ctx, uint16_t dt);
void app_led_run(uint16_t dt, uint8_t app_power);
/**
* @brief 请求切模式绿灯闪两下
@@ -54,11 +50,10 @@ void app_led_request_mode_blink(void);
void app_led_hint_power_on(void);
/**
* @brief 播放一次性配对结果灯
* @param ok 1=成功常绿,0=失败红绿交替
* @brief 清空全部灯事件并灭灯(关机前调用)
* @return 无
*/
void app_led_start_pair_result(uint8_t ok);
void app_led_clear(void);
/**
* @brief 查询是否已初始化