Flush the wipe tower planner queue with M400 on Klipper

The wipe tower emitted G4 S0 to make the firmware finish its queued moves
before commands that must not take effect early. Klipper's G4 reads only the
P parameter, so that flush never happened there and a temperature change could
land seconds ahead of the moves it was meant to follow. Klipper now gets M400
instead, through one helper shared by both wipe tower implementations.

No change to any other firmware flavor's output, so no shipped profile or saved
project is affected.
This commit is contained in:
SoftFever
2026-08-05 17:15:35 +08:00
parent 6312caaf13
commit 4e1caa39eb
5 changed files with 47 additions and 5 deletions
+5 -4
View File
@@ -386,7 +386,8 @@ public:
}
WipeTowerWriter2& switch_filament_monitoring(bool enable) {
m_gcode += std::string("G4 S0\n") + "M591 " + (enable ? "R" : "S0") + "\n";
m_gcode += flush_planner_queue_command(m_gcode_flavor);
m_gcode += std::string("M591 ") + (enable ? "R" : "S0") + "\n";
return *this;
}
@@ -625,7 +626,7 @@ public:
// Set extruder temperature, don't wait by default.
WipeTowerWriter2& set_extruder_temp(int temperature, bool wait = false)
{
m_gcode += "G4 S0\n"; // to flush planner queue
m_gcode += flush_planner_queue_command(m_gcode_flavor);
m_gcode += "M" + std::to_string(wait ? 109 : 104) + " S" + std::to_string(temperature) + "\n";
return *this;
}
@@ -677,8 +678,8 @@ public:
}
WipeTowerWriter2& flush_planner_queue()
{
m_gcode += "G4 S0\n";
{
m_gcode += flush_planner_queue_command(m_gcode_flavor);
return *this;
}