feat: VFD display shows AP when disconnected, time when connected
Made-with: Cursor
This commit is contained in:
36
lib/led.js
36
lib/led.js
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user