feat(vfd): showConn blink on WS connecting, showErr0 on VPS unreachable

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-19 23:17:08 +08:00
parent 53b9804c72
commit 9b4287db1d
2 changed files with 20 additions and 10 deletions

View File

@@ -108,16 +108,25 @@ class Display {
log.info('display', '显示屏 → AP');
}
/**
* 网络错误 → 显示错误码ERR + 单字母代码)
* code='a' → ERRa网络正常但 VPS 不可达)
* code='b' → ERRb预留
*/
showErr(code = 'a') {
/** WS 连接中(失败次数 < 3→ 显示 "Conn" 闪烁 */
showConn() {
this._stopBlink();
const s = ('ERR' + code).slice(0, 4);
this._write('#m3' + s);
log.info('display', `显示屏 → ${s}`);
this._write('#m3Conn');
log.info('display', '显示屏 → Conn闪烁');
let visible = true;
const blink = () => {
visible = !visible;
this._write(visible ? '#m3Conn' : '#c1');
this._blinkTimer = setTimeout(blink, visible ? 1000 : 500);
};
this._blinkTimer = setTimeout(blink, 1000);
}
/** 网络正常但 VPS 不可达 → 显示 "Err0" */
showErr0() {
this._stopBlink();
this._write('#m3Err0');
log.info('display', '显示屏 → Err0');
}
/** 网络已连接 → 显示时间 */