From ba515ffb628d193484c860d8f142fce66be1b985 Mon Sep 17 00:00:00 2001 From: igiannakas <59056762+igiannakas@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:54:24 +0000 Subject: [PATCH] Wipe Improvements: Removed debug code, removed retract before wipe and made the respect retract speed an option. --- src/libslic3r/GCode.cpp | 32 +++++++++++++++----------------- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 8 +++++++- src/libslic3r/PrintConfig.hpp | 1 + src/slic3r/GUI/Tab.cpp | 2 ++ 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 7de3d9291f..ad7433f169 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -351,24 +351,22 @@ static std::vector get_path_of_change_filament(const Print& print) scale_(gcodegen.config().retraction_speed.get_at(gcodegen.writer().extruder()->id())); - // Ioannis Giannakas: - // Calculate the maximum retraction length possible in the available wipe distance, in order to maintain the same effective - // retraction speed as a stationary retraction. - double maxRetractionLength = gcodegen.config().retraction_speed.get_at(gcodegen.writer().extruder()->id()) - * (wipe_path.length() / 1000000) - / _wipe_speed; - if (maxRetractionLength < (length - EPSILON)){ + if(gcodegen.config().respect_retraction_speed_when_wiping){ // Ioannis Giannakas: - // the maximum retraction length possible in the available wipe path with the current wipe speed is less than the - // requested retraction length while wiping. As such, perform an immediate retraction for the difference and proceed to - // wipe with the rest. - gcode +=";Wipe retraction adjusted: \n;Desired retraction amount: "+std::to_string(length) + - "\n;Maximum retraction amount: "+std::to_string(maxRetractionLength)+ - "\n;Retract before wipe: "+std::to_string(length - maxRetractionLength)+ - "\n"; - gcode += gcodegen.writer().retract(length - maxRetractionLength + dE_retracted, toolchange); - length = maxRetractionLength; - length = length < EPSILON ? EPSILON : length; + // Calculate the maximum retraction length possible in the available wipe distance, in order to maintain the same effective + // retraction speed as a stationary retraction. + double maxRetractionLength = gcodegen.config().retraction_speed.get_at(gcodegen.writer().extruder()->id()) + * (wipe_path.length() / 1000000) + / _wipe_speed; + if (maxRetractionLength < (length - EPSILON)){ + // Ioannis Giannakas: + // the maximum retraction length possible in the available wipe path with the current wipe speed is less than the + // requested retraction length while wiping. As such, perform an immediate retraction for the difference and proceed to + // wipe with the rest. + //gcode += gcodegen.writer().retract(length - maxRetractionLength + dE_retracted, toolchange); + length = maxRetractionLength; + length = length < EPSILON ? EPSILON : length; + } } // add tag for processor diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 25c4619480..340a996d22 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -161,6 +161,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "filename_format", "retraction_minimum_travel", "retract_before_wipe", + "respect_retraction_speed_when_wiping", "retract_when_changing_layer", "retraction_length", "retract_length_toolchange", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b9e2707522..3c14961f96 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3111,6 +3111,12 @@ def = this->add("filament_loading_speed", coFloats); def->mode = comAdvanced; def->set_default_value(new ConfigOptionPercents { 100 }); + def = this->add("respect_retraction_speed_when_wiping", coBool); + def->label = L("Respect retraction speed when wiping"); + def->tooltip = L("Adjust the retraction amount when wiping to ensure the retraction speed is respected. This setting can protect the extruder from stalling in the scenario of too high a retraction amount over too small a wipe distance. However, it may result in a stationary retraction at the end of the wipe move if the retraction speed it too slow, the retraction distance being too high or the wipe distance being too small. \n\nIt is generaly recomended to have this setting on, especially for fast bowden printers or when using high retraction lengths when changing materials."); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionBool { true }); + def = this->add("retract_when_changing_layer", coBools); def->label = L("Retract when change layer"); def->tooltip = L("Force a retraction when changes layer"); @@ -4558,7 +4564,7 @@ void PrintConfigDef::init_extruder_option_keys() "retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", - "default_filament_profile" + "default_filament_profile", "respect_retraction_speed_when_wiping" }; m_extruder_retract_keys = { diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 662b323b9b..21158f6ff8 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1084,6 +1084,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloat, extruder_clearance_radius)) ((ConfigOptionStrings, extruder_colour)) ((ConfigOptionPoints, extruder_offset)) + ((ConfigOptionBool, respect_retraction_speed_when_wiping)) ((ConfigOptionBools, reduce_fan_stop_start_freq)) ((ConfigOptionFloats, fan_cooling_layer_time)) ((ConfigOptionStrings, filament_colour)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 30568b78fc..7ce91cda38 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3864,6 +3864,7 @@ if (is_marlin_flavor) optgroup->append_single_option_line("wipe", "", 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("respect_retraction_speed_when_wiping", "", extruder_idx); optgroup = page->new_optgroup(L("Lift Z Enforcement"), L"param_retraction", -1, true); optgroup->append_single_option_line("retract_lift_above", "", extruder_idx); @@ -4109,6 +4110,7 @@ void TabPrinter::toggle_options() } // BBS toggle_option("wipe_distance", wipe, i); + toggle_option("respect_retraction_speed_when_wiping", wipe, i); toggle_option("retract_length_toolchange", have_multiple_extruders, i);