删除条件配置功能,修改成联动配置DP,并且增加31天运行记录,修改程序需求

This commit is contained in:
2026-09-03 10:21:11 +08:00
parent 5377186cfb
commit d56d8204e1
31 changed files with 1609 additions and 1430 deletions
+23 -19
View File
@@ -3,8 +3,7 @@
* @brief CBR3 灯效适配:单灯 PC2OTA/配对/常亮
* @author cyWu <1917507415@qq.com>
* @date 2026.08.31
* @version V1.1.0,新增 s_pair_hint:长按满 5s 到松手提交配对这段窗口内维持
* 配对快闪,避免被 app_led_run 叠上开机常亮
* @version V1.1.1,运行时收进 AppLedCtx_tinited / ota / pair_hint
******************************************************************************/
#include "app_led.h"
@@ -13,9 +12,14 @@
#include "board_pin.h"
#include "app_pair.h"
static uint8_t s_initialized;
static uint8_t s_ota; /* 1=OTA 灯效中,app_led_run 不再叠其它灯 */
static uint8_t s_pair_hint; /* 1=长按已满 5s 但还没松手提交配对,维持配对快闪 */
/** 灯效运行时:初始化门闩 + OTA 独占 + 长按配网提示 */
typedef struct {
uint8_t inited; /**< 1=已初始化 */
uint8_t ota; /**< 1=OTA 灯效中,app_led_run 不再叠其它灯 */
uint8_t pair_hint; /**< 1=长按已满 5s 但还没松手提交配对,维持配对快闪 */
} AppLedCtx_t;
static AppLedCtx_t s_led;
/**
* @brief 重新播放一次「一次性/限时」灯效,让它从第 0 帧重新开始
@@ -35,11 +39,11 @@ static void led_restart(LED_Event_t evt)
*/
AppLed_Ret_t app_led_init(void)
{
if (s_initialized) {
if (s_led.inited) {
return APP_LED_OK;
}
user_led_init();
s_initialized = 1;
s_led.inited = 1;
return APP_LED_OK;
}
@@ -49,7 +53,7 @@ AppLed_Ret_t app_led_init(void)
*/
AppLed_Ret_t app_led_get_status(void)
{
return s_initialized ? APP_LED_OK : APP_LED_ERR_NOT_INIT;
return s_led.inited ? APP_LED_OK : APP_LED_ERR_NOT_INIT;
}
/**
@@ -58,7 +62,7 @@ AppLed_Ret_t app_led_get_status(void)
*/
void app_led_hint_power_on(void)
{
if (!s_initialized || s_ota) {
if (!s_led.inited || s_led.ota) {
return;
}
led_restart(LED_EVENT_STANDBY);
@@ -70,10 +74,10 @@ void app_led_hint_power_on(void)
*/
void app_led_hint_pair(void)
{
if (!s_initialized || s_ota) {
if (!s_led.inited || s_led.ota) {
return;
}
s_pair_hint = 1;
s_led.pair_hint = 1;
LED_EventAllDelete();
bsp_led_set(0);
LED_EventAdd(LED_EVENT_PAIRING);
@@ -85,7 +89,7 @@ void app_led_hint_pair(void)
*/
void app_led_clear_pair_hint(void)
{
s_pair_hint = 0;
s_led.pair_hint = 0;
}
/**
@@ -94,11 +98,11 @@ void app_led_clear_pair_hint(void)
*/
void app_led_request_ota(void)
{
if (!s_initialized) {
if (!s_led.inited) {
return;
}
s_ota = 1;
s_pair_hint = 0; /* 已改判 OTA,撤销配网提示 */
s_led.ota = 1;
s_led.pair_hint = 0; /* 已改判 OTA,撤销配网提示 */
LED_EventAllDelete();
bsp_led_set(0);
LED_EventAdd(LED_EVENT_OTA);
@@ -110,7 +114,7 @@ void app_led_request_ota(void)
*/
uint8_t app_led_is_ota(void)
{
return s_ota;
return s_led.ota;
}
/**
@@ -123,12 +127,12 @@ void app_led_run(uint16_t dt, uint8_t power_on)
{
AppPairEvt_t pair_evt;
if (!s_initialized) {
if (!s_led.inited) {
return;
}
/* OTA 期间只跑 200ms 闪 */
if (s_ota) {
if (s_led.ota) {
LED_EventAdd(LED_EVENT_OTA);
user_led_handle();
return;
@@ -147,7 +151,7 @@ void app_led_run(uint16_t dt, uint8_t power_on)
if (!power_on) {
LED_EventDelete(LED_EVENT_STANDBY);
LED_EventDelete(LED_EVENT_PAIRING);
} else if (s_pair_hint || app_pair_is_active()) {
} else if (s_led.pair_hint || app_pair_is_active()) {
LED_EventAdd(LED_EVENT_PAIRING);
LED_EventDelete(LED_EVENT_STANDBY);
} else if (!LED_IsEventExist(LED_EVENT_PAIR_OK) && !LED_IsEventExist(LED_EVENT_PAIR_FAIL)) {