fix: 黄灯逻辑 — 断开中快闪, 重连后N短闪
- 线圈断开中: 快闪 (200ms), 无论断开多少次 - 线圈重连后: 按断开次数显示 N 短闪 (1/2/3次) - 无线圈上电后首次接线: 不计入, 黄灯灭 - 判定条件: g_disconnect_active || !g_loop_power_up_state → 快闪
This commit is contained in:
@@ -219,16 +219,16 @@ void poll_green_led(void)
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
* 黄灯故障指示 (LEDC, PA10)
|
||||
* 黄灯故障指示 — LEDC (PA10)
|
||||
*
|
||||
* 由 TMR15 ISR 每 5ms 驱动一次。
|
||||
*
|
||||
* 闪烁模式:
|
||||
* 无线圈上电 (g_loop_power_up_state==0):
|
||||
* 模式判定:
|
||||
* 当前线圈断开 或 上电后从未接线圈:
|
||||
* → 快闪 (200ms 亮 / 200ms 灭)
|
||||
* 线圈断开过 N 次 (g_disconnect_count >= 1):
|
||||
* → N 短闪 (80ms 亮, 200ms 灭, 重复 N 次后长灭 1.2s)
|
||||
* 线圈正常连接:
|
||||
* 线圈已恢复连接, 且上电后有断开记录 (g_disconnect_count >= 1):
|
||||
* → N 短闪 (80ms亮/200ms灭 × N, 1.2s间隔, N=断开次数≤3)
|
||||
* 线圈正常连接, 无断开记录:
|
||||
* → 灭
|
||||
*===========================================================================*/
|
||||
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_FAST_HALF 40 // 200ms 快闪半周期
|
||||
|
||||
uint8_t N = g_disconnect_count;
|
||||
|
||||
g_fault_tick++;
|
||||
|
||||
if (!g_loop_power_up_state) {
|
||||
/*--- 模式0: 无线圈上电 → 快闪 ---*/
|
||||
/*--- 模式1: 快闪 — 当前断开中 或 从无线圈上电 ---*/
|
||||
if (g_disconnect_active || !g_loop_power_up_state) {
|
||||
if (g_fault_tick >= FLT_FAST_HALF) {
|
||||
g_fault_tick = 0;
|
||||
LED_YELLOW_GPIO->odt ^= LED_YELLOW_PIN; // toggle
|
||||
@@ -251,31 +249,30 @@ void poll_yellow_led(void)
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t N = g_disconnect_count;
|
||||
|
||||
if (N == 0) {
|
||||
/*--- 模式1: 无断开记录 → 灭 ---*/
|
||||
/*--- 模式2: 无断开记录 → 灭 ---*/
|
||||
LED_YELLOW_OFF;
|
||||
g_fault_tick = 0;
|
||||
g_fault_phase = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*--- 模式2: N 短闪 (N=1,2,3) ---*/
|
||||
if (N > 3) N = 3; // 最多 3 闪
|
||||
/*--- 模式3: N 短闪 (连接中, 但有断开历史) ---*/
|
||||
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;
|
||||
|
||||
if (g_fault_phase < phases_total) {
|
||||
/* ON 或 GAP 阶段 */
|
||||
duration = (g_fault_phase & 1) ? FLT_GAP_SHORT : FLT_ON_SHORT;
|
||||
|
||||
if (g_fault_phase & 1) {
|
||||
LED_YELLOW_OFF; // 奇数阶段: 灭
|
||||
} else {
|
||||
LED_YELLOW_ON; // 偶数阶段: 亮
|
||||
}
|
||||
if (g_fault_phase & 1)
|
||||
LED_YELLOW_OFF;
|
||||
else
|
||||
LED_YELLOW_ON;
|
||||
} else {
|
||||
/* LONG 间隔阶段 */
|
||||
/* LONG 间隔 */
|
||||
duration = FLT_GAP_LONG;
|
||||
LED_YELLOW_OFF;
|
||||
}
|
||||
@@ -283,9 +280,8 @@ void poll_yellow_led(void)
|
||||
if (g_fault_tick >= duration) {
|
||||
g_fault_tick = 0;
|
||||
g_fault_phase++;
|
||||
if (g_fault_phase > phases_total) {
|
||||
g_fault_phase = 0; // 循环
|
||||
}
|
||||
if (g_fault_phase > phases_total)
|
||||
g_fault_phase = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user