From b4fa8504456700f2830b1c9d0326c1f6fc20e2e1 Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Thu, 19 Mar 2026 08:57:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(display):=20PIN=20=E6=94=B9=E4=B8=BA=204?= =?UTF-8?q?=20=E4=BD=8D=EF=BC=8CshowPinMiddle4=20=E2=86=92=20showPin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- lib/client.js | 2 +- lib/led.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/client.js b/lib/client.js index 93a4346..1fe1e64 100644 --- a/lib/client.js +++ b/lib/client.js @@ -242,7 +242,7 @@ class ClawClient { if (msg.status === 'inactive') { led.status.setSetup(); // 未激活 → SETUP 亮 - led.display.showPinMiddle4(msg.pin); // 未激活 + 连网 → 显示 PIN 中间4位 + led.display.showPin(msg.pin); // 未激活 + 连网 → 显示 4 位 PIN const id = String(msg.claw_id).padEnd(6); const pin = String(msg.pin); log.info('clawd', ''); diff --git a/lib/led.js b/lib/led.js index 9ba89cd..fed9f69 100644 --- a/lib/led.js +++ b/lib/led.js @@ -109,13 +109,12 @@ class Display { log.info('display', '显示屏 → 时间'); } - /** 未激活 + 连网 → 显示 PIN 码中间 4 位(6 位 PIN 取第 2~5 位) */ - showPinMiddle4(pin) { - const s = String(pin || ''); - const mid4 = s.length >= 6 ? s.slice(1, 5) : s.padStart(4, '0').slice(-4); + /** 未激活 + 连网 → 显示 PIN 码(4 位数字) */ + showPin(pin) { + const s = String(pin || '').padStart(4, '0').slice(-4); // #m2 模式支持数字,4字符直接跟在模式号后(无空格) - this._write('#m2' + mid4); - log.info('display', `显示屏 → PIN 中间4位: ${mid4}`); + this._write('#m2' + s); + log.info('display', `显示屏 → PIN: ${s}`); } _write(val) {