mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-22 02:12:13 +00:00
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:
@@ -4671,7 +4671,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
|
||||
|
||||
gcode += m_writer.reset_e();
|
||||
//BBS
|
||||
if (m_writer.extruder()->retraction_length() > 0) {
|
||||
if (m_writer.extruder()->retraction_length() > 0||m_config.use_firmware_retraction) {
|
||||
// BBS: force to use normal lift for spiral vase mode
|
||||
gcode += m_writer.lift(lift_type, m_spiral_vase != nullptr);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -882,7 +882,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
||||
"print_host_webui",
|
||||
"printhost_cafile","printhost_port","printhost_authorization_type",
|
||||
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
|
||||
"use_relative_e_distances", "extruder_type"
|
||||
"use_relative_e_distances", "extruder_type","use_firmware_retraction"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_sla_print_options {
|
||||
|
||||
@@ -171,7 +171,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||
"use_relative_e_distances",
|
||||
"activate_air_filtration",
|
||||
"during_print_exhaust_fan_speed",
|
||||
"complete_print_exhaust_fan_speed"
|
||||
"complete_print_exhaust_fan_speed",
|
||||
"use_firmware_retraction"
|
||||
};
|
||||
|
||||
static std::unordered_set<std::string> steps_ignore;
|
||||
|
||||
@@ -3378,6 +3378,12 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(true));
|
||||
|
||||
def = this->add("use_firmware_retraction",coBool);
|
||||
def->label = L("Use firmware retraction");
|
||||
def->tooltip = L("Convert the retraction moves to G10 and G11 gcode");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("wipe", coBools);
|
||||
def->label = L("Wipe while retracting");
|
||||
def->tooltip = L("Move nozzle along the last extrusion path when retracting to clean leaked material on nozzle. "
|
||||
@@ -4881,6 +4887,24 @@ std::map<std::string, std::string> validate(const FullPrintConfig &cfg, bool und
|
||||
error_message.emplace("bottom_shell_layers", L("invalid value ") + std::to_string(cfg.bottom_shell_layers));
|
||||
}
|
||||
|
||||
std::set<GCodeFlavor>with_firmware_retraction_flavor = {
|
||||
gcfSmoothie,
|
||||
gcfRepRapSprinter,
|
||||
gcfRepRapFirmware,
|
||||
gcfMarlinLegacy,
|
||||
gcfMarlinFirmware,
|
||||
gcfMachinekit,
|
||||
gcfRepetier,
|
||||
gcfKlipper
|
||||
};
|
||||
if (cfg.use_firmware_retraction.value && with_firmware_retraction_flavor.count(cfg.gcode_flavor.value)==0)
|
||||
error_message.emplace("gcode_flavor",L("--use-firmware-retraction is only supported by Marlin, Klipper, Smoothie, RepRapFirmware, Repetier and Machinekit firmware"));
|
||||
|
||||
if (cfg.use_firmware_retraction.value)
|
||||
for (unsigned char wipe : cfg.wipe.values)
|
||||
if (wipe)
|
||||
error_message.emplace("wipe",L("--use-firmware-retraction is not compatible with --wipe"));
|
||||
|
||||
// --gcode-flavor
|
||||
if (! print_config_def.get("gcode_flavor")->has_enum_value(cfg.gcode_flavor.serialize())) {
|
||||
error_message.emplace("gcode_flavor", L("invalid value ") + cfg.gcode_flavor.serialize());
|
||||
|
||||
@@ -908,6 +908,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||
((ConfigOptionFloat, travel_speed))
|
||||
((ConfigOptionFloat, travel_speed_z))
|
||||
((ConfigOptionBool, use_relative_e_distances))
|
||||
((ConfigOptionBool, use_firmware_retraction))
|
||||
((ConfigOptionBool, silent_mode))
|
||||
((ConfigOptionString, machine_pause_gcode))
|
||||
((ConfigOptionString, template_custom_gcode))
|
||||
|
||||
Reference in New Issue
Block a user