From d0b702ddd4f705d553793aee6a53c464d0a40f09 Mon Sep 17 00:00:00 2001 From: Zak Peirce Date: Mon, 12 Oct 2026 19:55:14 -0700 Subject: [PATCH 1/2] fix(tools): require original start g-code --- tests/start_gcode_helper.test.js | 10 +++--- tools/start-gcode-helper/README.md | 12 ++++--- tools/start-gcode-helper/index.html | 1 + tools/start-gcode-helper/processor.js | 51 ++++++--------------------- tools/start-gcode-helper/style.css | 2 ++ 5 files changed, 24 insertions(+), 52 deletions(-) diff --git a/tests/start_gcode_helper.test.js b/tests/start_gcode_helper.test.js index c8062fd..c9a370a 100644 --- a/tests/start_gcode_helper.test.js +++ b/tests/start_gcode_helper.test.js @@ -19,12 +19,10 @@ assert.equal((result.text.match(/^M191 /gm) || []).length, 1); assert.match(result.text, /M140 .*\nM141 S\{overall_chamber_temperature\}/); assert.match(result.text, /G0 Z5 F10000\nM106 P2 S178\nM191 S\{overall_chamber_temperature\}\nM107 P2\n; WAIT_CHAMBER_TEMP TIMEOUT=180\nG28 Z/); -const updated = processGcode(result.text, "55"); -assert.equal((updated.text.match(/^M141 /gm) || []).length, 1); -assert.equal((updated.text.match(/^M191 /gm) || []).length, 1); -assert.match(updated.text, /M141 S55/); -assert.match(updated.text, /M106 P2 S178\nM191 S55\nM107 P2/); -assert.equal((updated.text.match(/^; WAIT_CHAMBER_TEMP/gm) || []).length, 1); +assert.throws(() => processGcode(result.text, "55"), /original, unmodified slicer start G-code/); +assert.throws(() => processGcode(template.replace("M140", "M140\nM141 S50"), "55"), /already contains DragonBreath chamber commands/); +assert.throws(() => processGcode(template.replace("G0 Z5 F10000", "G0 Z5 F10000\nM191 S50"), "55"), /already contains DragonBreath chamber commands/); +assert.throws(() => processGcode(template.replace("G0 Z5 F10000", "G0 Z5 F10000\nM106 P2 S178"), "55"), /already contains DragonBreath chamber commands/); const outsideFan = template + "\nM106 P2 S255\n"; assert.match(processGcode(outsideFan, "55").text, /M107 P2\n; WAIT_CHAMBER_TEMP TIMEOUT=180\nG28 Z[\s\S]*M106 P2 S255/); diff --git a/tools/start-gcode-helper/README.md b/tools/start-gcode-helper/README.md index ae6ab3a..9a39e70 100644 --- a/tools/start-gcode-helper/README.md +++ b/tools/start-gcode-helper/README.md @@ -4,6 +4,10 @@ A dependency-free static page for adding DragonBreath chamber control to a printer's start G-code. It runs completely in the browser; files are never uploaded to a server. +Use only the original, unmodified slicer start G-code. Do not run the helper on +code that already has DragonBreath chamber commands. It stops if it finds +`M141`, `M191`, or the helper's `M106 P2 S178` fan command in the startup area. + The helper places `M141 S` after the first `M140`, then looks for the first `G0 Z5` after `M190` and adds this wait sequence beneath it: @@ -15,11 +19,9 @@ M107 P2 `S178` is 70% of the 0–255 fan scale. The target defaults to the Orca/Bambu template variable `{overall_chamber_temperature}`. For already-sliced G-code, -enter the numeric chamber target instead. If a chamber wait already exists in -the startup area, the helper updates it and its adjacent P2 fan commands rather -than adding a second wait. It also comments out an active `WAIT_CHAMBER_TEMP` -in that startup section because `M191` now performs the wait. Unrelated fan -commands later in the print are kept. +enter the numeric chamber target instead. It comments out an active +`WAIT_CHAMBER_TEMP` in that startup section because `M191` now performs the +wait. Unrelated fan commands later in the print are kept. The page expects start G-code containing `M140` and `M190`. Review the preview before downloading and using the updated file. diff --git a/tools/start-gcode-helper/index.html b/tools/start-gcode-helper/index.html index 153eae8..77a2fb0 100644 --- a/tools/start-gcode-helper/index.html +++ b/tools/start-gcode-helper/index.html @@ -17,6 +17,7 @@

Add chamber control to your start G-code

1. Add your start G-code

+

Use only original, unmodified slicer start G-code. Do not run this helper on code that already has DragonBreath chamber commands. The helper stops if it finds them.