1、低电 3.7V 只闪红灯不再 1 分钟后关机;电量低于约 5% 自动关机,未充电开机先闪 5 下红灯再睡回,只能充电后才能开机

2、自动/手动互相切换都闪 2 下灯;APP 发停止后再发自动模式可正常启动,手动残留停止不再挡住自动
3、自动模式 1~6 单次最长跑 10 分钟后回待机;关机时长按 12 秒进 OTA,OTA 期间红绿交替闪
This commit is contained in:
2026-08-27 10:20:48 +08:00
parent 3d445ae5c5
commit fdb43011b7
28 changed files with 945 additions and 165 deletions
+41 -4
View File
@@ -7,9 +7,10 @@
* @history
* - V1.0.0, 2026.08.21, cyWu, 首次发布
* - V1.1.0, 2026.08.25, cyWu, 开机绿灯只提示几秒
* - V2.0.0, 2026.08.25, cyWu, 改用充电板 LED 事件表,红绿通道独立
* - V2.0.0, 2026.08.25, cyWu, 改用 LED 事件表,红绿通道独立
* - V2.1.0, 2026.08.25, cyWu, 自己从 app_power/app_pair 取数并内部组装
* - V2.2.0, 2026.08.25, cyWu, 重启/清场逻辑各提一个小函数,把意图写进注释
* - V2.3.0, 2026.08.27, cyWu, 新增 OTA 红绿交替灯效
******************************************************************************/
#include "app_led.h"
@@ -20,6 +21,7 @@
#include "app_pair.h"
static uint8_t s_initialized;
static uint8_t s_ota; /* 1=OTA 灯效中,app_led_run 不再叠其它灯 */
static void led_start_pair_result(uint8_t ok);
@@ -87,7 +89,7 @@ AppLed_Ret_t app_led_get_status(void)
*/
void app_led_request_mode_blink(void)
{
if (!s_initialized) {
if (!s_initialized || s_ota) {
return;
}
led_restart(LED_EVENT_MODE);
@@ -99,12 +101,36 @@ void app_led_request_mode_blink(void)
*/
void app_led_hint_power_on(void)
{
if (!s_initialized) {
if (!s_initialized || s_ota) {
return;
}
led_restart(LED_EVENT_STANDBY);
}
/**
* @brief 进入 OTA:清掉其它灯,挂红绿交替一直闪
* @return 无
*/
void app_led_request_ota(void)
{
if (!s_initialized) {
return;
}
s_ota = 1;
LED_EventAllDelete();
bsp_led_all_off();
LED_EventAdd(LED_EVENT_OTA);
}
/**
* @brief 查询是否处于 OTA 灯效
* @return 1=OTA 灯效中,0=否
*/
uint8_t app_led_is_ota(void)
{
return s_ota;
}
/**
* @brief 播放一次性配对结果灯
* @param ok 1=成功常绿,0=失败红绿交替
@@ -112,7 +138,7 @@ void app_led_hint_power_on(void)
*/
static void led_start_pair_result(uint8_t ok)
{
LED_EventDelete(LED_EVENT_PAIRING);
LED_EventDelete(LED_EVENT_PAIRING); /* 结果灯盖住配对快闪 */
led_restart(ok ? LED_EVENT_PAIR_OK : LED_EVENT_PAIR_FAIL);
}
@@ -153,6 +179,14 @@ void app_led_run(uint16_t dt, uint8_t app_power)
return;
}
/* OTA 期间只跑红绿交替,充电/待机/配对都不要叠上去 */
if (s_ota) {
LED_EventAdd(LED_EVENT_OTA);
user_led_handle();
return;
}
/* 配对成功/失败是边沿事件,只在那一拍切灯效 */
pair_evt = app_pair_tick_1ms(dt);
if (pair_evt == APP_PAIR_EVT_OK) {
led_start_pair_result(1);
@@ -165,6 +199,7 @@ void app_led_run(uint16_t dt, uint8_t app_power)
func_on = app_power ? 1 : 0;
pairing = (uint8_t)(app_pair_is_active() && func_on);
/* 充电红 / 充满绿:和功能开关无关,关着设备也可能在充电 */
if (charge_led == 1) {
LED_EventAdd(LED_EVENT_CHARGE);
} else {
@@ -177,12 +212,14 @@ void app_led_run(uint16_t dt, uint8_t app_power)
LED_EventDelete(LED_EVENT_CHARGE_FULL);
}
/* 绿灯正被切模式/配对结果占用时,不要再挂配对快闪,避免互相覆盖 */
if (pairing && !green_pattern_busy()) {
LED_EventAdd(LED_EVENT_PAIRING);
} else if (!pairing) {
LED_EventDelete(LED_EVENT_PAIRING);
}
/* 低电红闪:只在功能开、没接电时才挂,充电红优先 */
if (func_on && low_bat && (charge_led == 0)) {
LED_EventAdd(LED_EVENT_LOWBAT);
} else {