diff --git a/examples/netz/index.html b/examples/netz/index.html index 431a561..fabaebe 100644 --- a/examples/netz/index.html +++ b/examples/netz/index.html @@ -42,7 +42,7 @@ } - + diff --git a/examples/netz/sketch.js b/examples/netz/sketch.js index 2c98882..be3ffff 100644 --- a/examples/netz/sketch.js +++ b/examples/netz/sketch.js @@ -1,6 +1,6 @@ let wp; -let area = 320; +let area = 100; function setup() { const canvas = createCanvas(windowWidth, windowHeight); diff --git a/examples/zickzack/index.html b/examples/zickzack/index.html index 431a561..fabaebe 100644 --- a/examples/zickzack/index.html +++ b/examples/zickzack/index.html @@ -42,7 +42,7 @@ } - + diff --git a/lib/README.md b/lib/README.md index 9b2e309..db95de1 100644 --- a/lib/README.md +++ b/lib/README.md @@ -29,7 +29,7 @@ All options are optional. | `machineXMin` / `machineXMax` | `-830` / `830` | Overlay X extents, mm (idler spacing 1660) | | `machineYMin` / `machineYMax` | `-1200` / `800` | Overlay Y; idlers at Y=800 (80 cm above work centre) | | `jogIntervalMs` | `150` | Repeat delay while holding arrows, ms | -| `maxLogLines` | `8` | Serial lines shown on the HUD | +| `maxLogLines` | `40` | Serial lines in the selectable log (bottom-right) | | `previewMinDelayMs` | `30` | Floor for preview segment wait, ms | | `previewFrameMs` | `16` | Preview animation frame time, ms | | `timingMultiplier` | `1` | Scale **Test** preview waits (`2` = twice as slow) | diff --git a/lib/WallPlotter.js b/lib/WallPlotter.js index c36af08..482954a 100644 --- a/lib/WallPlotter.js +++ b/lib/WallPlotter.js @@ -18,7 +18,7 @@ class WallPlotter { // Static constants // --------------------------------------------------------------------------- - static VERSION = '2.3.5'; + static VERSION = '2.3.13'; static MIN_FEED_MM_MIN = 1; static MAX_FEED_MM_MIN = 10000; /** Offline overlay size when not connected (mm) — 150×150 cm centred on origin */ @@ -55,7 +55,7 @@ class WallPlotter { * @param {number} [options.machineYMax] * @param {number} [options.previewSizeMm] Offline square size (mm) * @param {number} [options.jogIntervalMs=150] - * @param {number} [options.maxLogLines=8] + * @param {number} [options.maxLogLines=40] * @param {number} [options.previewMinDelayMs=30] Floor for preview segment wait * @param {number} [options.previewFrameMs=16] Preview animation frame time * @param {number} [options.timingMultiplier=1] Scales Test preview waits @@ -83,7 +83,7 @@ class WallPlotter { // --- Jog / UI --- this.stepSize = options.stepSize ?? 10; this.jogIntervalMs = options.jogIntervalMs ?? 150; - this.maxLogLines = options.maxLogLines ?? 8; + this.maxLogLines = options.maxLogLines ?? 40; this.previewMinDelayMs = options.previewMinDelayMs ?? 30; this.previewFrameMs = options.previewFrameMs ?? 16; @@ -147,6 +147,7 @@ class WallPlotter { this.onLog = (line) => { this.logLines.push(line); if (this.logLines.length > this.maxLogLines) this.logLines.shift(); + this._syncLogOverlay(); userOnLog(line); }; @@ -267,6 +268,7 @@ class WallPlotter { textFont('monospace', 14); this._drawPlotArea(); this._drawHud(); + this._syncLogOverlay(); if (this._keysEnabled && !this.isPlotting) this._handleContinuousJog(); } @@ -1742,6 +1744,29 @@ class WallPlotter { border-color: #444; color: #888; } + #wallplotter-log { + position: absolute; + right: 0.75rem; + bottom: 0.75rem; + z-index: 20; + max-width: min(52rem, calc(100vw - 1.5rem)); + max-height: 42vh; + overflow: auto; + user-select: text; + -webkit-user-select: text; + pointer-events: auto; + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 12px; + line-height: 1.4; + color: #c8c8d0; + background: rgba(18, 18, 22, 0.88); + border: 1px solid #3a3a42; + border-radius: 6px; + padding: 0.45rem 0.6rem; + white-space: pre-wrap; + word-break: break-word; + margin: 0; + } `; document.head.appendChild(style); } @@ -1985,13 +2010,27 @@ class WallPlotter { text(help[i], 16, height - 16 - i * 18); } } + } - textAlign(RIGHT, BOTTOM); - fill(140); - const n = this.logLines.length; - for (let i = 0; i < n; i++) { - text(this.logLines[i], width - 16, height - 16 - (n - 1 - i) * 16); + _ensureLogOverlay() { + this._injectPlotButtonStyles(); + let el = document.getElementById('wallplotter-log'); + if (el) return el; + el = document.createElement('pre'); + el.id = 'wallplotter-log'; + el.setAttribute('aria-label', 'Serial log'); + document.body.appendChild(el); + return el; + } + + _syncLogOverlay() { + const el = this._ensureLogOverlay(); + const text = this.logLines.join('\n'); + if (el.textContent !== text) { + el.textContent = text; + el.scrollTop = el.scrollHeight; } + el.style.display = this.logLines.length ? 'block' : 'none'; } // ===========================================================================