Files
2026-09-01 17:31:15 +08:00

94 lines
2.5 KiB
C

/******************************************************************************
* @file app_led.h
* @brief CBC4 灯效:红绿独立通道,充电红与待机绿可同时亮
* @author cyWu <1917507415@qq.com>
* @date 2026.08.25
* @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
* - V2.3.0, 2026.08.27, cyWu, 新增 OTA 红绿交替灯效
* - V2.4.0, 2026.08.27, cyWu, 新增空电关机红灯闪 5 下
******************************************************************************/
#ifndef __APP_LED_H__
#define __APP_LED_H__
#include <stdint.h>
typedef enum {
APP_LED_OK = 0,
APP_LED_ERR_NOT_INIT
} AppLed_Ret_t;
/**
* @brief 灯效初始化,先全灭
* @return APP_LED_OK=成功
*/
AppLed_Ret_t app_led_init(void);
/**
* @brief 按优先级刷新灯:充电/低电从 app_power 取,配对从 app_pair 取,
* 只有“功能是否开”这一项由调用方(app_function)传入
* @param dt 距上次调用的毫秒数
* @param app_power 1=功能开(DP0),0=功能关,功能灯全灭
* @return 无
*/
void app_led_run(uint16_t dt, uint8_t app_power);
/**
* @brief 请求切模式绿灯闪两下
* @return 无
*/
void app_led_request_mode_blink(void);
/**
* @brief 重新亮几秒开机绿灯
* @return 无
*/
void app_led_hint_power_on(void);
/**
* @brief 进入 OTA:红绿交替一直闪,盖住其它灯效,直到升级结束或复位
* @return 无
*/
void app_led_request_ota(void);
/** Leave the OTA indication and return LED control to the normal state. */
void app_led_exit_ota(void);
/**
* @brief 查询是否处于 OTA 灯效
* @return 1=OTA 灯效中,0=否
*/
uint8_t app_led_is_ota(void);
/**
* @brief 空电关机灯效:关掉绿灯,只闪红灯 5 下
* @return 无
*/
void app_led_request_empty_off(void);
/**
* @brief 查询是否处于空电关机灯效
* @return 1=空电红闪中,0=否
*/
uint8_t app_led_is_empty_off(void);
/**
* @brief 清空全部灯事件并灭灯(关机前调用)
* @return 无
*/
void app_led_clear(void);
/**
* @brief 查询是否已初始化
* @return APP_LED_OK=已初始化,APP_LED_ERR_NOT_INIT=未初始化
*/
AppLed_Ret_t app_led_get_status(void);
#endif /* __APP_LED_H__ */