V1.5: 断电时序改为先发消息+屏幕显示掉电事件3秒后熄屏

This commit is contained in:
helei 2026-08-22 20:38:05 +08:00
parent 1c83dc7d0b
commit 1347b4324c
2 changed files with 13 additions and 4 deletions

View File

@ -66,9 +66,8 @@ void update_batter(void)
}
if (!confirm) return;
oled_off(); /* 先关屏:断电即黑屏,也给模组留更多发送电量 */
/* 分毫必争:发掉电消息并等模组回 OK最多 ~1.5s/次,最多试 3 次)。
* 3 /线 */
/* 1. 先发掉电消息(等模组回 OK最多 ~1.5s/次,最多试 3 次;
* 3 */
{
static uint8_t pub_try = 0;
if (NET_publish_power_wait(0) != 0 && ++pub_try < 3) return;
@ -76,9 +75,18 @@ void update_batter(void)
}
powoff = 1;
log_info("> 电量低: %d%%", (int)batter_valtage);
/* 2. 屏幕提示掉电事件,展示 3 秒(法拉电容续航足够) */
oled_clear();
oled_locate(1, 0);
oled_print("发生掉电事件!");
hlw8032_save(); /* 本地记录:电量、断电原因(都很快) */
reset_log_power_loss();
HAL_Delay(800); /* OK 后再留 800ms 让报文上空口 */
/* 3. 3 秒后熄屏(这段延时也顺便给了模组发报文的空口时间),随后复位 */
HAL_Delay(3000);
oled_off();
NVIC_SystemReset();
/* BootLoader 会检测主电源12V 未恢复前不跳 APP防止外设没上电时程序乱跑 */
}

View File

@ -205,3 +205,4 @@
- 蓝牙 AT 设置加固AT 窗口内静音日志UART1 与模块共用,日志字节会污染模块命令解析);
进 AT 模式+查询无应答时重新拉 PC5 重试,最多 3 轮
- 断电时序微调:确认断电后先关 OLED 屏再发掉电消息(黑屏更快+给模组留更多发送电量)
- 断电时序改为:先发掉电消息(等OK) → 屏幕显示"发生掉电事件!"亮 3 秒 → 熄屏复位