feat: VFD display shows AP when disconnected, time when connected

Made-with: Cursor
This commit is contained in:
stswangzhiping
2026-03-18 21:10:14 +08:00
parent a0f767f267
commit 9da4cd0aa1
2 changed files with 46 additions and 8 deletions

View File

@@ -86,6 +86,37 @@ class WifiLed {
}
}
// ── VFD 显示屏 ────────────────────────────────────────────────────────────────
const DISPLAY_PATH = '/sys/devices/platform/openvfd/attr/led';
/**
* VFD 显示屏控制。
* #m3 <text> 手动模式,显示指定文字
* #s1 系统时钟模式,显示当前时间
*/
class Display {
/** 网络断开 / AP 模式 → 显示 "AP " */
showAP() {
this._write('#m3 AP ');
log.info('display', '显示屏 → AP');
}
/** 网络已连接 → 显示时间 */
showTime() {
this._write('#s1');
log.info('display', '显示屏 → 时间');
}
_write(val) {
try {
fs.writeFileSync(DISPLAY_PATH, val);
} catch (e) {
log.warn('display', `写入失败 (${DISPLAY_PATH}): ${e.message}`);
}
}
}
// ── SETUP / APPS 状态灯 ───────────────────────────────────────────────────────
/**
@@ -123,5 +154,6 @@ class StatusLed {
}
// 全局单例,整个进程共用
module.exports = new WifiLed();
module.exports.status = new StatusLed();
module.exports = new WifiLed();
module.exports.status = new StatusLed();
module.exports.display = new Display();