diff --git a/lib/printerLive.js b/lib/printerLive.js index b27fe01..645409e 100644 --- a/lib/printerLive.js +++ b/lib/printerLive.js @@ -34,6 +34,7 @@ function requestFullReport(c) { async function flushTrays(c) { clearTimeout(c.traysTimer); c.traysTimer = null; + c.pendingKey = null; const trays = allTrays(c); if (!c.ams && !c.external) return null; c.syncedKey = traysKey(trays); @@ -60,7 +61,11 @@ function handleMessage(c, payload) { if (Array.isArray(units) && units.every((u) => Array.isArray(u.tray))) c.ams = describeAms(units); if (p.vt_tray) c.external = describeTray(p.vt_tray, null); - if ((c.ams || c.external) && traysKey(allTrays(c)) !== c.syncedKey) { + // A printer mid-print reports every second or so, so only a change in what's + // loaded restarts the wait — otherwise the sync would never come round. + const key = (c.ams || c.external) ? traysKey(allTrays(c)) : null; + if (key && key !== c.syncedKey && key !== c.pendingKey) { + c.pendingKey = key; clearTimeout(c.traysTimer); c.traysTimer = setTimeout(() => flushTrays(c), TRAYS_SETTLE_MS); } @@ -82,6 +87,7 @@ function open(p) { ams: null, external: null, syncedKey: null, + pendingKey: null, lastSync: null, traysTimer: null, waiters: [], diff --git a/public/app.js b/public/app.js index fc35f86..1660e51 100644 --- a/public/app.js +++ b/public/app.js @@ -2630,8 +2630,11 @@ function drawnSlots(p) { // What's in each slot, as last reported, under the drawing. function loadedHtml(p) { if (!p.loaded) return p.id ? '
Nothing reported yet — “Test & sync” to read it.
' : ''; - // The tracked spool in that slot names the colour; otherwise the nearest Bambu colour. + // A tagged spool is Bambu's, so its colour has a name: from the tracked spool, + // or the Bambu colour it matches. An untagged one could be any brand, so it + // gets the colour the printer reports and nothing more. const colourName = (t) => { + if (!t.tagged) return t.colour || ''; const s = spools.find((x) => x.ams_slot === `${p.serial}/${t.unit == null ? 'ext' : t.unit}/${t.slot == null ? 0 : t.slot}`); return (s && s.colour) || (t.colour ? paletteName(t.colour, t.material) : '') || ''; }; @@ -2747,7 +2750,10 @@ const temp = (now, target) => { return target ? `${t} / ${Math.round(target)} °C` : `${t} °C`; }; -function printerStatusHtml(snap) { +// These report a placeholder chamber temperature (5 °C) rather than a reading. +const NO_CHAMBER_SENSOR = ['A1 mini', 'A1', 'A2L', 'P1P', 'P1S']; + +function printerStatusHtml(snap, model) { if (!snap || !snap.live) { return '