ENH: add firmware retract for 3rd printers

1. Add firmware retract for 3rd printers. Use G10,G11

Github: #2319,#969

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: If3a3d591c249a4323a08045f3cc86ffb3e477d0e
This commit is contained in:
xun.zhang 2023-10-08 15:42:52 +08:00 committed by Lane.Wei
parent 7e0c831358
commit ae40f0fc4d
7 changed files with 87 additions and 21 deletions

View file

@ -625,14 +625,22 @@ std::string GCodeWriter::retract_for_toolchange(bool before_wipe)
std::string GCodeWriter::_retract(double length, double restart_extra, const std::string &comment)
{
std::string gcode;
if (config.use_firmware_retraction)
length = 1;
if (double dE = m_extruder->retract(length, restart_extra); dE != 0) {
//BBS
GCodeG1Formatter w;
w.emit_e(m_extruder->E());
w.emit_f(m_extruder->retract_speed() * 60.);
//BBS
w.emit_comment(GCodeWriter::full_gcode_comment, comment);
gcode = w.string();
//add firmware retraction
if (config.use_firmware_retraction) {
gcode = FLAVOR_IS(gcfMachinekit) ? "G22 ;retract" : "G10 ;retract \n";
}
else {
//BBS
GCodeG1Formatter w;
w.emit_e(m_extruder->E());
w.emit_f(m_extruder->retract_speed() * 60.);
//BBS
w.emit_comment(GCodeWriter::full_gcode_comment, comment);
gcode = w.string();
}
}
if (FLAVOR_IS(gcfMakerWare))
@ -649,14 +657,20 @@ std::string GCodeWriter::unretract()
gcode = "M101 ; extruder on\n";
if (double dE = m_extruder->unretract(); dE != 0) {
//BBS
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
GCodeG1Formatter w;
w.emit_e(m_extruder->E());
w.emit_f(m_extruder->deretract_speed() * 60.);
//BBS
w.emit_comment(GCodeWriter::full_gcode_comment, " ; unretract");
gcode += w.string();
if (config.use_firmware_retraction) {
gcode += FLAVOR_IS(gcfMachinekit) ? "G23 ;unretract \n" : "G11 ;unretract \n";
gcode += reset_e();
}
else {
//BBS
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
GCodeG1Formatter w;
w.emit_e(m_extruder->E());
w.emit_f(m_extruder->deretract_speed() * 60.);
//BBS
w.emit_comment(GCodeWriter::full_gcode_comment, " ; unretract");
gcode += w.string();
}
}
return gcode;