fix: 黄灯逻辑 — 断开中快闪, 重连后N短闪
- 线圈断开中: 快闪 (200ms), 无论断开多少次 - 线圈重连后: 按断开次数显示 N 短闪 (1/2/3次) - 无线圈上电后首次接线: 不计入, 黄灯灭 - 判定条件: g_disconnect_active || !g_loop_power_up_state → 快闪
This commit is contained in:
@@ -118,9 +118,9 @@ extern uint16_t g_safe_max_cnt; // 安全复位超时
|
|||||||
* 故障指示相关 — 黄灯 LEDC (PA10)
|
* 故障指示相关 — 黄灯 LEDC (PA10)
|
||||||
*
|
*
|
||||||
* 行为:
|
* 行为:
|
||||||
* - 无线圈上电:黄灯快闪(200ms 周期)
|
* - 当前断开中 或 上电后从未接线圈:快闪 (200ms)
|
||||||
* - 线圈断开 N 次(N≥1):N 短闪(N×80ms 亮,间隔 200ms 灭,长灭 1.2s 重复)
|
* - 线圈已恢复连接, 断开过 N 次:N 短闪 (N≤3)
|
||||||
* - 线圈正常连接:黄灯灭
|
* - 线圈正常连接, 无断开记录:灭
|
||||||
*
|
*
|
||||||
* 注: 绿灯 LEDA (PA9) 由 poll_green_led() 控制;
|
* 注: 绿灯 LEDA (PA9) 由 poll_green_led() 控制;
|
||||||
* 红灯 (PB1) 始终 PWM 呼吸, 不需软件干预.
|
* 红灯 (PB1) 始终 PWM 呼吸, 不需软件干预.
|
||||||
|
|||||||
@@ -219,16 +219,16 @@ void poll_green_led(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
* 黄灯故障指示 (LEDC, PA10)
|
* 黄灯故障指示 — LEDC (PA10)
|
||||||
*
|
*
|
||||||
* 由 TMR15 ISR 每 5ms 驱动一次。
|
* 由 TMR15 ISR 每 5ms 驱动一次。
|
||||||
*
|
*
|
||||||
* 闪烁模式:
|
* 模式判定:
|
||||||
* 无线圈上电 (g_loop_power_up_state==0):
|
* 当前线圈断开 或 上电后从未接线圈:
|
||||||
* → 快闪 (200ms 亮 / 200ms 灭)
|
* → 快闪 (200ms 亮 / 200ms 灭)
|
||||||
* 线圈断开过 N 次 (g_disconnect_count >= 1):
|
* 线圈已恢复连接, 且上电后有断开记录 (g_disconnect_count >= 1):
|
||||||
* → N 短闪 (80ms 亮, 200ms 灭, 重复 N 次后长灭 1.2s)
|
* → N 短闪 (80ms亮/200ms灭 × N, 1.2s间隔, N=断开次数≤3)
|
||||||
* 线圈正常连接:
|
* 线圈正常连接, 无断开记录:
|
||||||
* → 灭
|
* → 灭
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void poll_yellow_led(void)
|
void poll_yellow_led(void)
|
||||||
@@ -238,12 +238,10 @@ void poll_yellow_led(void)
|
|||||||
#define FLT_GAP_LONG 240 // 1.2s (240 × 5ms)
|
#define FLT_GAP_LONG 240 // 1.2s (240 × 5ms)
|
||||||
#define FLT_FAST_HALF 40 // 200ms 快闪半周期
|
#define FLT_FAST_HALF 40 // 200ms 快闪半周期
|
||||||
|
|
||||||
uint8_t N = g_disconnect_count;
|
|
||||||
|
|
||||||
g_fault_tick++;
|
g_fault_tick++;
|
||||||
|
|
||||||
if (!g_loop_power_up_state) {
|
/*--- 模式1: 快闪 — 当前断开中 或 从无线圈上电 ---*/
|
||||||
/*--- 模式0: 无线圈上电 → 快闪 ---*/
|
if (g_disconnect_active || !g_loop_power_up_state) {
|
||||||
if (g_fault_tick >= FLT_FAST_HALF) {
|
if (g_fault_tick >= FLT_FAST_HALF) {
|
||||||
g_fault_tick = 0;
|
g_fault_tick = 0;
|
||||||
LED_YELLOW_GPIO->odt ^= LED_YELLOW_PIN; // toggle
|
LED_YELLOW_GPIO->odt ^= LED_YELLOW_PIN; // toggle
|
||||||
@@ -251,31 +249,30 @@ void poll_yellow_led(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t N = g_disconnect_count;
|
||||||
|
|
||||||
if (N == 0) {
|
if (N == 0) {
|
||||||
/*--- 模式1: 无断开记录 → 灭 ---*/
|
/*--- 模式2: 无断开记录 → 灭 ---*/
|
||||||
LED_YELLOW_OFF;
|
LED_YELLOW_OFF;
|
||||||
g_fault_tick = 0;
|
g_fault_tick = 0;
|
||||||
g_fault_phase = 0;
|
g_fault_phase = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--- 模式2: N 短闪 (N=1,2,3) ---*/
|
/*--- 模式3: N 短闪 (连接中, 但有断开历史) ---*/
|
||||||
if (N > 3) N = 3; // 最多 3 闪
|
if (N > 3) N = 3;
|
||||||
|
|
||||||
uint8_t phases_total = N * 2; // N 个 ON_short + N 个 GAP_short
|
uint8_t phases_total = N * 2; // N 个 ON_short + N 个 GAP_short
|
||||||
uint16_t duration;
|
uint16_t duration;
|
||||||
|
|
||||||
if (g_fault_phase < phases_total) {
|
if (g_fault_phase < phases_total) {
|
||||||
/* ON 或 GAP 阶段 */
|
|
||||||
duration = (g_fault_phase & 1) ? FLT_GAP_SHORT : FLT_ON_SHORT;
|
duration = (g_fault_phase & 1) ? FLT_GAP_SHORT : FLT_ON_SHORT;
|
||||||
|
if (g_fault_phase & 1)
|
||||||
if (g_fault_phase & 1) {
|
LED_YELLOW_OFF;
|
||||||
LED_YELLOW_OFF; // 奇数阶段: 灭
|
else
|
||||||
} else {
|
LED_YELLOW_ON;
|
||||||
LED_YELLOW_ON; // 偶数阶段: 亮
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* LONG 间隔阶段 */
|
/* LONG 间隔 */
|
||||||
duration = FLT_GAP_LONG;
|
duration = FLT_GAP_LONG;
|
||||||
LED_YELLOW_OFF;
|
LED_YELLOW_OFF;
|
||||||
}
|
}
|
||||||
@@ -283,9 +280,8 @@ void poll_yellow_led(void)
|
|||||||
if (g_fault_tick >= duration) {
|
if (g_fault_tick >= duration) {
|
||||||
g_fault_tick = 0;
|
g_fault_tick = 0;
|
||||||
g_fault_phase++;
|
g_fault_phase++;
|
||||||
if (g_fault_phase > phases_total) {
|
if (g_fault_phase > phases_total)
|
||||||
g_fault_phase = 0; // 循环
|
g_fault_phase = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user