Restore the pre-IMEX pressure advance output for non-IMEX printers

Closes review comment 6.

The per-tool pressure advance work changed set_pressure_advance() for users who
are not using the feature. RepRapFirmware lost its D qualifier when no tool index
was supplied: upstream emits M572 D0 S<pa> unconditionally, and a bare M572
applies to whatever tool is currently selected and errors when there is none, so
PA started depending on tool-selection state for every RRF user. The D is back,
defaulting to 0, and D<tool> is reached only from the IMEX paths.

The same rewrite had also changed the comment separator from "<value>; Override"
to "<value> ; Override" on the Klipper, RRF, Marlin 2.x and Marlin Legacy
branches, so every non-IMEX print of those flavors carried a one-byte diff.
Restored. Upstream is internally inconsistent here -- BBL and Repetier do use the
spaced form -- and the point is to match it exactly rather than to tidy it.

Emitted output for all six flavors with no tool index is now byte-identical to
upstream. Verified on a real slice: a Klipper profile emits
"SET_PRESSURE_ADVANCE ADVANCE=0.02; Override pressure advance value", an exact
string match, with no EXTRUDER= qualifier. The tests were pinning the regressed
form and are inverted.

Also records at the imex key registrations why they are kept out of the g-code
config block, matching the house convention at the other banned keys.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clifford Garwood
2026-09-03 00:55:35 -04:00
co-authored by Claude Opus 5
parent 612e0e3932
commit 5629dd29e9
3 changed files with 22 additions and 18 deletions
+9 -9
View File
@@ -522,14 +522,14 @@ std::string GCodeWriter::set_pressure_advance(double pa, int tool) const
gcode << " EXTRUDER=extruder" << tool;
else if (tool == 0)
gcode << " EXTRUDER=extruder";
gcode << " ; Override pressure advance value\n";
gcode << "; Override pressure advance value\n";
} else if (FLAVOR_IS(gcfRepRapFirmware)) {
// RRF: M572 without D applies to the current tool; with D targets a specific extruder.
// Use D only when an explicit tool index is provided (IMEX parallel modes).
gcode << "M572";
if (tool >= 0)
gcode << " D" << tool;
gcode << " S" << std::setprecision(4) << pa << " ; Override pressure advance value\n";
// RRF: M572 D<n> targets a specific extruder; a bare M572 applies to whatever tool is
// currently selected and errors when there isn't one. Callers with no tool index keep
// the historical D0 rather than the bare form: PA would otherwise depend on
// tool-selection state for every RRF user, none of whom are asking for IMEX.
gcode << "M572 D" << (tool >= 0 ? tool : 0)
<< " S" << std::setprecision(4) << pa << "; Override pressure advance value\n";
} else if (FLAVOR_IS(gcfRepetier)) {
// Repetier M233: X is quadratic (K), Y is linear (L).
// Applying the value to both parameters simultaneously.
@@ -539,10 +539,10 @@ std::string GCodeWriter::set_pressure_advance(double pa, int tool) const
gcode << "M900 K" << std::setprecision(4) << pa;
if (tool >= 0)
gcode << " T" << tool;
gcode << " ; Override pressure advance value\n";
gcode << "; Override pressure advance value\n";
} else {
// Marlin Legacy and everything else: single-extruder M900, no tool parameter
gcode << "M900 K" << std::setprecision(4) << pa << " ; Override pressure advance value\n";
gcode << "M900 K" << std::setprecision(4) << pa << "; Override pressure advance value\n";
}
return gcode.str();
}