mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Support firmware retration and retract_restart_extra
This commit is contained in:
parent
13cd930bb4
commit
0f04df2699
9 changed files with 101 additions and 24 deletions
|
@ -58,6 +58,7 @@ double Extruder::retract(double length, double restart_extra)
|
||||||
m_share_E -= to_retract;
|
m_share_E -= to_retract;
|
||||||
m_absolute_E -= to_retract;
|
m_absolute_E -= to_retract;
|
||||||
m_share_retracted += to_retract;
|
m_share_retracted += to_retract;
|
||||||
|
m_restart_extra = restart_extra;
|
||||||
}
|
}
|
||||||
return to_retract;
|
return to_retract;
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,9 +80,10 @@ double Extruder::unretract()
|
||||||
{
|
{
|
||||||
// BBS
|
// BBS
|
||||||
if (m_share_extruder) {
|
if (m_share_extruder) {
|
||||||
double dE = m_share_retracted;
|
double dE = m_share_retracted + m_restart_extra;
|
||||||
this->extrude(dE);
|
this->extrude(dE);
|
||||||
m_share_retracted = 0.;
|
m_share_retracted = 0.;
|
||||||
|
m_restart_extra = 0.;
|
||||||
return dE;
|
return dE;
|
||||||
} else {
|
} else {
|
||||||
double dE = m_retracted + m_restart_extra;
|
double dE = m_retracted + m_restart_extra;
|
||||||
|
@ -157,6 +159,11 @@ int Extruder::retract_speed() const
|
||||||
return int(floor(m_config->retraction_speed.get_at(m_id)+0.5));
|
return int(floor(m_config->retraction_speed.get_at(m_id)+0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Extruder::use_firmware_retraction() const
|
||||||
|
{
|
||||||
|
return m_config->use_firmware_retraction;
|
||||||
|
}
|
||||||
|
|
||||||
int Extruder::deretract_speed() const
|
int Extruder::deretract_speed() const
|
||||||
{
|
{
|
||||||
int speed = int(floor(m_config->deretraction_speed.get_at(m_id)+0.5));
|
int speed = int(floor(m_config->deretraction_speed.get_at(m_id)+0.5));
|
||||||
|
|
|
@ -56,6 +56,8 @@ public:
|
||||||
double retract_length_toolchange() const;
|
double retract_length_toolchange() const;
|
||||||
double retract_restart_extra_toolchange() const;
|
double retract_restart_extra_toolchange() const;
|
||||||
|
|
||||||
|
bool use_firmware_retraction() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private constructor to create a key for a search in std::set.
|
// Private constructor to create a key for a search in std::set.
|
||||||
Extruder(unsigned int id) : m_id(id) {}
|
Extruder(unsigned int id) : m_id(id) {}
|
||||||
|
|
|
@ -4085,7 +4085,7 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction)
|
||||||
|
|
||||||
gcode += m_writer.reset_e();
|
gcode += m_writer.reset_e();
|
||||||
//BBS
|
//BBS
|
||||||
if (m_writer.extruder()->retraction_length() > 0) {
|
if (m_writer.extruder()->retraction_length() > 0 || m_config.use_firmware_retraction) {
|
||||||
// BBS: don't do lazy_lift when enable spiral vase
|
// BBS: don't do lazy_lift when enable spiral vase
|
||||||
size_t extruder_id = m_writer.extruder()->id();
|
size_t extruder_id = m_writer.extruder()->id();
|
||||||
auto _lift = m_config.z_lift_type.value;
|
auto _lift = m_config.z_lift_type.value;
|
||||||
|
|
|
@ -583,15 +583,26 @@ std::string GCodeWriter::retract_for_toolchange(bool before_wipe)
|
||||||
|
|
||||||
std::string GCodeWriter::_retract(double length, double restart_extra, const std::string &comment)
|
std::string GCodeWriter::_retract(double length, double restart_extra, const std::string &comment)
|
||||||
{
|
{
|
||||||
|
/* If firmware retraction is enabled, we use a fake value of 1
|
||||||
|
since we ignore the actual configured retract_length which
|
||||||
|
might be 0, in which case the retraction logic gets skipped. */
|
||||||
|
if (this->config.use_firmware_retraction)
|
||||||
|
length = 1;
|
||||||
|
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
if (double dE = m_extruder->retract(length, restart_extra); dE != 0) {
|
if (double dE = m_extruder->retract(length, restart_extra); dE != 0) {
|
||||||
//BBS
|
if (this->config.use_firmware_retraction) {
|
||||||
GCodeG1Formatter w;
|
gcode = FLAVOR_IS(gcfMachinekit) ? "G22 ; retract\n" : "G10 ; retract\n";
|
||||||
w.emit_e(m_extruder->E());
|
}
|
||||||
w.emit_f(m_extruder->retract_speed() * 60.);
|
else {
|
||||||
//BBS
|
// BBS
|
||||||
w.emit_comment(GCodeWriter::full_gcode_comment, comment);
|
GCodeG1Formatter w;
|
||||||
gcode = w.string();
|
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))
|
if (FLAVOR_IS(gcfMakerWare))
|
||||||
|
@ -608,14 +619,20 @@ std::string GCodeWriter::unretract()
|
||||||
gcode = "M101 ; extruder on\n";
|
gcode = "M101 ; extruder on\n";
|
||||||
|
|
||||||
if (double dE = m_extruder->unretract(); dE != 0) {
|
if (double dE = m_extruder->unretract(); dE != 0) {
|
||||||
//BBS
|
if (this->config.use_firmware_retraction) {
|
||||||
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
|
gcode += FLAVOR_IS(gcfMachinekit) ? "G23 ; unretract\n" : "G11 ; unretract\n";
|
||||||
GCodeG1Formatter w;
|
gcode += this->reset_e();
|
||||||
w.emit_e(m_extruder->E());
|
}
|
||||||
w.emit_f(m_extruder->deretract_speed() * 60.);
|
else {
|
||||||
//BBS
|
//BBS
|
||||||
w.emit_comment(GCodeWriter::full_gcode_comment, " ; unretract");
|
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
|
||||||
gcode += w.string();
|
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;
|
return gcode;
|
||||||
|
|
|
@ -802,7 +802,8 @@ static std::vector<std::string> s_Preset_printer_options {
|
||||||
"host_type", "print_host", "printhost_apikey",
|
"host_type", "print_host", "printhost_apikey",
|
||||||
"printhost_cafile","printhost_port","printhost_authorization_type",
|
"printhost_cafile","printhost_port","printhost_authorization_type",
|
||||||
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
|
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
|
||||||
"z_lift_type", "thumbnails"
|
"z_lift_type", "thumbnails",
|
||||||
|
"use_firmware_retraction"
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<std::string> s_Preset_sla_print_options {
|
static std::vector<std::string> s_Preset_sla_print_options {
|
||||||
|
|
|
@ -131,6 +131,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||||
"retract_restart_extra",
|
"retract_restart_extra",
|
||||||
"retract_restart_extra_toolchange",
|
"retract_restart_extra_toolchange",
|
||||||
"retraction_speed",
|
"retraction_speed",
|
||||||
|
"use_firmware_retraction",
|
||||||
"slow_down_layer_time",
|
"slow_down_layer_time",
|
||||||
"standby_temperature_delta",
|
"standby_temperature_delta",
|
||||||
"machine_start_gcode",
|
"machine_start_gcode",
|
||||||
|
|
|
@ -2335,6 +2335,13 @@ void PrintConfigDef::init_fff_params()
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionFloats { 0. });
|
def->set_default_value(new ConfigOptionFloats { 0. });
|
||||||
|
|
||||||
|
def = this->add("use_firmware_retraction", coBool);
|
||||||
|
def->label = L("Use firmware retraction");
|
||||||
|
def->tooltip = L("This experimental setting uses G10 and G11 commands to have the firmware "
|
||||||
|
"handle the retraction. This is only supported in recent Marlin.");
|
||||||
|
def->mode = comAdvanced;
|
||||||
|
def->set_default_value(new ConfigOptionBool(false));
|
||||||
|
|
||||||
def = this->add("seam_position", coEnum);
|
def = this->add("seam_position", coEnum);
|
||||||
def->label = L("Seam position");
|
def->label = L("Seam position");
|
||||||
def->category = L("Quality");
|
def->category = L("Quality");
|
||||||
|
@ -4468,6 +4475,22 @@ std::string validate(const FullPrintConfig &cfg)
|
||||||
if (cfg.bottom_shell_layers < 0)
|
if (cfg.bottom_shell_layers < 0)
|
||||||
return "Invalid value for --bottom-solid-layers";
|
return "Invalid value for --bottom-solid-layers";
|
||||||
|
|
||||||
|
if (cfg.use_firmware_retraction.value &&
|
||||||
|
cfg.gcode_flavor.value != gcfKlipper &&
|
||||||
|
cfg.gcode_flavor.value != gcfSmoothie &&
|
||||||
|
cfg.gcode_flavor.value != gcfRepRapSprinter &&
|
||||||
|
cfg.gcode_flavor.value != gcfRepRapFirmware &&
|
||||||
|
cfg.gcode_flavor.value != gcfMarlinLegacy &&
|
||||||
|
cfg.gcode_flavor.value != gcfMarlinFirmware &&
|
||||||
|
cfg.gcode_flavor.value != gcfMachinekit &&
|
||||||
|
cfg.gcode_flavor.value != gcfRepetier)
|
||||||
|
return "--use-firmware-retraction is only supported by Klipper, Marlin, Smoothie, RepRapFirmware, Repetier and Machinekit firmware";
|
||||||
|
|
||||||
|
if (cfg.use_firmware_retraction.value)
|
||||||
|
for (unsigned char wipe : cfg.wipe.values)
|
||||||
|
if (wipe)
|
||||||
|
return "--use-firmware-retraction is not compatible with --wipe";
|
||||||
|
|
||||||
// --gcode-flavor
|
// --gcode-flavor
|
||||||
if (! print_config_def.get("gcode_flavor")->has_enum_value(cfg.gcode_flavor.serialize()))
|
if (! print_config_def.get("gcode_flavor")->has_enum_value(cfg.gcode_flavor.serialize()))
|
||||||
return "Invalid value for --gcode-flavor";
|
return "Invalid value for --gcode-flavor";
|
||||||
|
|
|
@ -847,6 +847,8 @@ PRINT_CONFIG_CLASS_DEFINE(
|
||||||
((ConfigOptionEnum<NozzleType>, nozzle_type))
|
((ConfigOptionEnum<NozzleType>, nozzle_type))
|
||||||
((ConfigOptionInt, nozzle_hrc))
|
((ConfigOptionInt, nozzle_hrc))
|
||||||
((ConfigOptionBool, auxiliary_fan))
|
((ConfigOptionBool, auxiliary_fan))
|
||||||
|
// SoftFever
|
||||||
|
((ConfigOptionBool, use_firmware_retraction))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2455,7 +2455,7 @@ void TabFilament::add_filament_overrides_page()
|
||||||
"filament_z_hop",
|
"filament_z_hop",
|
||||||
"filament_retraction_speed",
|
"filament_retraction_speed",
|
||||||
"filament_deretraction_speed",
|
"filament_deretraction_speed",
|
||||||
//"filament_retract_restart_extra",
|
"filament_retract_restart_extra",
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
"filament_retract_when_changing_layer",
|
"filament_retract_when_changing_layer",
|
||||||
"filament_wipe",
|
"filament_wipe",
|
||||||
|
@ -2486,7 +2486,7 @@ void TabFilament::update_filament_overrides_page()
|
||||||
"filament_z_hop",
|
"filament_z_hop",
|
||||||
"filament_retraction_speed",
|
"filament_retraction_speed",
|
||||||
"filament_deretraction_speed",
|
"filament_deretraction_speed",
|
||||||
//"filament_retract_restart_extra",
|
"filament_retract_restart_extra",
|
||||||
"filament_retraction_minimum_travel",
|
"filament_retraction_minimum_travel",
|
||||||
"filament_retract_when_changing_layer",
|
"filament_retract_when_changing_layer",
|
||||||
"filament_wipe",
|
"filament_wipe",
|
||||||
|
@ -3367,16 +3367,17 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
|
||||||
//BBS: don't show retract related config menu in machine page
|
//BBS: don't show retract related config menu in machine page
|
||||||
optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
||||||
optgroup->append_single_option_line("retraction_length", "", extruder_idx);
|
optgroup->append_single_option_line("retraction_length", "", extruder_idx);
|
||||||
|
optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("z_hop", "", extruder_idx);
|
optgroup->append_single_option_line("z_hop", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("z_lift_type", "", extruder_idx);
|
optgroup->append_single_option_line("z_lift_type", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("retraction_speed", "", extruder_idx);
|
optgroup->append_single_option_line("retraction_speed", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("deretraction_speed", "", extruder_idx);
|
optgroup->append_single_option_line("deretraction_speed", "", extruder_idx);
|
||||||
//optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
|
|
||||||
optgroup->append_single_option_line("retraction_minimum_travel", "", extruder_idx);
|
optgroup->append_single_option_line("retraction_minimum_travel", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("retract_when_changing_layer", "", extruder_idx);
|
optgroup->append_single_option_line("retract_when_changing_layer", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("wipe", "", extruder_idx);
|
optgroup->append_single_option_line("wipe", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("wipe_distance", "", extruder_idx);
|
optgroup->append_single_option_line("wipe_distance", "", extruder_idx);
|
||||||
optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx);
|
optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx);
|
||||||
|
optgroup->append_single_option_line("use_firmware_retraction");
|
||||||
|
|
||||||
optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction", -1, true);
|
optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction", -1, true);
|
||||||
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
|
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
|
||||||
|
@ -3559,13 +3560,17 @@ void TabPrinter::toggle_options()
|
||||||
size_t i = size_t(val - 1);
|
size_t i = size_t(val - 1);
|
||||||
bool have_retract_length = m_config->opt_float("retraction_length", i) > 0;
|
bool have_retract_length = m_config->opt_float("retraction_length", i) > 0;
|
||||||
|
|
||||||
|
// when using firmware retraction, firmware decides retraction length
|
||||||
|
bool use_firmware_retraction = m_config->opt_bool("use_firmware_retraction");
|
||||||
|
toggle_option("retract_length", !use_firmware_retraction, i);
|
||||||
|
|
||||||
// user can customize travel length if we have retraction length or we"re using
|
// user can customize travel length if we have retraction length or we"re using
|
||||||
// firmware retraction
|
// firmware retraction
|
||||||
toggle_option("retraction_minimum_travel", have_retract_length, i);
|
toggle_option("retraction_minimum_travel", have_retract_length || use_firmware_retraction, i);
|
||||||
|
|
||||||
// user can customize other retraction options if retraction is enabled
|
// user can customize other retraction options if retraction is enabled
|
||||||
//BBS
|
//BBS
|
||||||
bool retraction = have_retract_length;
|
bool retraction = have_retract_length || use_firmware_retraction;
|
||||||
std::vector<std::string> vec = { "z_hop", "retract_when_changing_layer" };
|
std::vector<std::string> vec = { "z_hop", "retract_when_changing_layer" };
|
||||||
for (auto el : vec)
|
for (auto el : vec)
|
||||||
toggle_option(el, retraction, i);
|
toggle_option(el, retraction, i);
|
||||||
|
@ -3578,10 +3583,29 @@ void TabPrinter::toggle_options()
|
||||||
vec = { "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "wipe", "wipe_distance" };
|
vec = { "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "wipe", "wipe_distance" };
|
||||||
for (auto el : vec)
|
for (auto el : vec)
|
||||||
//BBS
|
//BBS
|
||||||
toggle_option(el, retraction, i);
|
toggle_option(el, retraction && !use_firmware_retraction, i);
|
||||||
|
|
||||||
bool wipe = retraction && m_config->opt_bool("wipe", i);
|
bool wipe = retraction && m_config->opt_bool("wipe", i);
|
||||||
toggle_option("retract_before_wipe", wipe, i);
|
toggle_option("retract_before_wipe", wipe, i);
|
||||||
|
if (use_firmware_retraction && wipe) {
|
||||||
|
//wxMessageDialog dialog(parent(),
|
||||||
|
MessageDialog dialog(parent(),
|
||||||
|
_(L("The Wipe option is not available when using the Firmware Retraction mode.\n"
|
||||||
|
"\nShall I disable it in order to enable Firmware Retraction?")),
|
||||||
|
_(L("Firmware Retraction")), wxICON_WARNING | wxYES | wxNO);
|
||||||
|
|
||||||
|
DynamicPrintConfig new_conf = *m_config;
|
||||||
|
if (dialog.ShowModal() == wxID_YES) {
|
||||||
|
auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")->clone());
|
||||||
|
for (size_t w = 0; w < wipe->values.size(); w++)
|
||||||
|
wipe->values[w] = false;
|
||||||
|
new_conf.set_key_value("wipe", wipe);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_conf.set_key_value("use_firmware_retraction", new ConfigOptionBool(false));
|
||||||
|
}
|
||||||
|
load_config(new_conf);
|
||||||
|
}
|
||||||
// BBS
|
// BBS
|
||||||
toggle_option("wipe_distance", wipe, i);
|
toggle_option("wipe_distance", wipe, i);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue