From cc27722417548531d13174d2aeea773da93ba942 Mon Sep 17 00:00:00 2001 From: Morton Jonuschat Date: Mon, 30 Dec 2024 14:46:35 -0800 Subject: [PATCH] Add filament max speed override --- src/libslic3r/GCode.cpp | 4 ++++ src/libslic3r/GCode/WipeTower.cpp | 11 ++++++++++- src/libslic3r/GCode/WipeTower.hpp | 2 ++ src/libslic3r/Preset.cpp | 4 +++- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 10 ++++++++++ src/libslic3r/PrintConfig.hpp | 1 + src/slic3r/GUI/Tab.cpp | 1 + 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 5277627aac7..b72847f19da 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -3332,6 +3332,10 @@ double cap_speed( if (filament_volumetric_cap > 0) { speed = std::min(speed, filament_volumetric_cap / path_attr.mm3_per_mm); } + const double filament_max_speed{config.filament_max_speed.get_at(extruder_id)}; + if (filament_max_speed > 0) { + speed = std::min(speed, filament_max_speed); + } if (path_attr.role == ExtrusionRole::InternalInfill) { const double infill_cap{ path_attr.maybe_self_crossing ? diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 4dc3e888d0d..a2d882e3d50 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -542,6 +542,7 @@ WipeTower::ToolChangeResult WipeTower::construct_tcr(WipeTowerWriter& writer, WipeTower::WipeTower(const Vec2f& pos, double rotation_deg, const PrintConfig& config, const PrintRegionConfig& default_region_config, const std::vector>& wiping_matrix, size_t initial_tool) : + m_config(&config), m_semm(config.single_extruder_multi_material.value), m_wipe_tower_pos(pos), m_wipe_tower_width(float(config.wipe_tower_width)), @@ -647,6 +648,10 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config) float nozzle_diameter = float(config.nozzle_diameter.get_at(idx)); m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM + float max_speed = float(config.filament_max_speed.get_at(idx)); + if (max_speed > 0.f) + m_filpar[idx].max_speed = max_speed; + float max_vol_speed = float(config.filament_max_volumetric_speed.get_at(idx)); if (max_vol_speed!= 0.f) m_filpar[idx].max_e_speed = (max_vol_speed / filament_area()); @@ -1173,7 +1178,11 @@ void WipeTower::toolchange_Wipe( x_to_wipe = std::max(x_to_wipe, x_to_fill_cleaning_box); } - const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f; + float max_speed = std::numeric_limits::max(); + if (m_config->filament_max_speed.get_at(m_current_tool) > 0) { + max_speed = float(m_config->filament_max_speed.get_at(m_current_tool)); + } + const float target_speed = std::min(max_speed, (is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f)); float wipe_speed = 0.33f * target_speed; // if there is less than 2.5*line_width to the edge, advance straightaway (there is likely a blob anyway) diff --git a/src/libslic3r/GCode/WipeTower.hpp b/src/libslic3r/GCode/WipeTower.hpp index e0d83de69fe..88d970f046d 100644 --- a/src/libslic3r/GCode/WipeTower.hpp +++ b/src/libslic3r/GCode/WipeTower.hpp @@ -252,6 +252,7 @@ class WipeTower float cooling_final_speed = 0.f; float ramming_line_width_multiplicator = 1.f; float ramming_step_multiplicator = 1.f; + float max_speed = std::numeric_limits::max(); float max_e_speed = std::numeric_limits::max(); std::vector ramming_speed; float nozzle_diameter; @@ -275,6 +276,7 @@ class WipeTower } + const PrintConfig* m_config; bool m_semm = true; // Are we using a single extruder multimaterial printer? bool m_is_mk4mmu3 = false; bool m_switch_filament_monitoring = false; diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 0998ece0693..22cae8529a8 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -535,7 +535,9 @@ static std::vector s_Preset_filament_options { // Shrinkage compensation "filament_shrinkage_compensation_xy", "filament_shrinkage_compensation_z", // Seams overrides - "filament_seam_gap_distance" + "filament_seam_gap_distance", + // BOSS + "filament_max_speed", }; static std::vector s_Preset_machine_limits_options { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 1e6ede373ae..8a320af4008 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -243,6 +243,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n || opt_key == "filament_multitool_ramming" || opt_key == "filament_multitool_ramming_volume" || opt_key == "filament_multitool_ramming_flow" + || opt_key == "filament_max_speed" || opt_key == "filament_max_volumetric_speed" || opt_key == "filament_infill_max_speed" || opt_key == "filament_infill_max_crossing_speed" diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 4f633db3ab3..601934a7f73 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1253,6 +1253,16 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionStrings { "" }); + def = this->add("filament_max_speed", coFloats); + def->label = L("Max speed"); + def->tooltip = L("Maximum speed allowed for this filament. Limits the maximum " + "speed of a print to the minimum of the print speed and the filament speed. " + "Set zero for no limit."); + def->sidetext = L("mm/s"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloats{ 0. }); + def = this->add("filament_max_volumetric_speed", coFloats); def->label = L("Max volumetric speed"); def->tooltip = L("Maximum volumetric speed allowed for this filament. Limits the maximum volumetric " diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 0b62925b907..c0945bd6d84 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -907,6 +907,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, color_change_gcode)) ((ConfigOptionString, pause_print_gcode)) ((ConfigOptionString, template_custom_gcode)) + ((ConfigOptionFloats, filament_max_speed)) ) static inline std::string get_extrusion_axis(const GCodeConfig &cfg) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 176aa3cf862..742cc38bd4c 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2293,6 +2293,7 @@ void TabFilament::build() optgroup->append_single_option_line("filament_abrasive"); optgroup = page->new_optgroup(L("Print speed override")); + optgroup->append_single_option_line("filament_max_speed", "max-speed_127176"); optgroup->append_single_option_line("filament_max_volumetric_speed", "max-volumetric-speed_127176"); line = { "", "" };