Skip to content

Commit

Permalink
first_layer_min_speed added
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Aug 22, 2021
1 parent d10939e commit 498f49f
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 30 deletions.
1 change: 1 addition & 0 deletions resources/ui_layout/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ group:Speed for non-print moves
end_line
group:sidetext_width$7:Modifiers
line:First layer speed
setting:label_width$8:width$4:first_layer_min_speed
setting:label_width$8:width$4:first_layer_speed
setting:label_width$8:width$4:first_layer_infill_speed
end_line
Expand Down
22 changes: 13 additions & 9 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3861,32 +3861,36 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
vol_speed = m_config.max_print_speed.value;
// if using a % of an auto speed, use the % over the volumetric speed.
if (path.role() == erExternalPerimeter) {
speed = m_config.get_abs_value("external_perimeter_speed", vol_speed);
speed = m_config.external_perimeter_speed.get_abs_value(vol_speed);
} else if (path.role() == erInternalBridgeInfill) {
speed = m_config.get_abs_value("bridge_speed_internal", vol_speed);
speed = m_config.bridge_speed_internal.get_abs_value(vol_speed);
} else if (path.role() == erOverhangPerimeter) {
speed = m_config.get_abs_value("overhangs_speed", vol_speed);
speed = m_config.overhangs_speed.get_abs_value(vol_speed);
} else if (path.role() == erSolidInfill) {
speed = m_config.get_abs_value("solid_infill_speed", vol_speed);
speed = m_config.solid_infill_speed.get_abs_value(vol_speed);
} else if (path.role() == erTopSolidInfill) {
speed = m_config.get_abs_value("top_solid_infill_speed", vol_speed);
speed = m_config.top_solid_infill_speed.get_abs_value(vol_speed);
}
if(speed == 0){
speed = vol_speed;
}
}
if (speed == 0) // this code shouldn't trigger as if it's 0, you have to get a m_volumetric_speed
speed = m_config.max_print_speed.value;
if (this->on_first_layer())
if (this->on_first_layer()) {
const double base_speed = speed;
if (path.role() == erInternalInfill || path.role() == erSolidInfill) {
double first_layer_infill_speed = m_config.get_abs_value("first_layer_infill_speed", speed);
if(first_layer_infill_speed > 0)
double first_layer_infill_speed = m_config.first_layer_infill_speed.get_abs_value(base_speed);
if (first_layer_infill_speed > 0)
speed = std::min(first_layer_infill_speed, speed);
} else {
double first_layer_speed = m_config.get_abs_value("first_layer_speed", speed);
double first_layer_speed = m_config.first_layer_speed.get_abs_value(base_speed);
if (first_layer_speed > 0)
speed = std::min(first_layer_speed, speed);
}
double first_layer_min_speed = m_config.first_layer_min_speed.get_abs_value(base_speed);
speed = std::max(first_layer_min_speed, speed);
}
// cap speed with max_volumetric_speed anyway (even if user is not using autospeed)
if (m_config.max_volumetric_speed.value > 0 && path.mm3_per_mm > 0) {
speed = std::min(m_config.max_volumetric_speed.value / path.mm3_per_mm, speed);
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ const std::vector<std::string>& Preset::print_options()
// speeds
"external_perimeter_speed",
"first_layer_speed",
"first_layer_min_speed",
"infill_speed",
"perimeter_speed",
"small_perimeter_speed",
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
"first_layer_flow_ratio",
"first_layer_speed",
"first_layer_infill_speed",
"first_layer_min_speed",
"full_fan_speed_layer",
"gap_fill_speed",
"gcode_comments",
Expand Down
43 changes: 29 additions & 14 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ void PrintConfigDef::init_fff_params()
"If the extruder is not centered, choose the largest value for safety. "
"This setting is used to check for collisions and to display the graphical preview "
"in the plater."
"\nSet to 0 to disable clearance checking.");
"\nSet zero to disable clearance checking.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comExpert;
Expand Down Expand Up @@ -1235,7 +1235,7 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::cooling;
def->tooltip = L("If layer print time is estimated below this number of seconds, fan will be enabled "
"and its speed will be calculated by interpolating the default and maximum speeds."
"\nSet to 0 to disable.");
"\nSet zero to disable.");
def->sidetext = L("approximate seconds");
def->min = 0;
def->max = 1000;
Expand Down Expand Up @@ -1838,14 +1838,14 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloatOrPercent(75, true));

def = this->add("first_layer_speed", coFloatOrPercent);
def->label = L("Default");
def->label = L("Max");
def->full_label = L("Default first layer speed");
def->category = OptionCategory::speed;
def->tooltip = L("If expressed as absolute value in mm/s, this speed will be applied to all the print moves "
"but infill of the first layer, it can be overwritten by the 'default' (default depends of the type of the path) "
"speed if it's lower than that. If expressed as a percentage "
"it will scale the current speed."
"\nSet it at 100% to remove any first layer speed modification (with first_layer_infill_speed).");
"but infill of the first layer, it can be overwritten by the 'default' (default depends of the type of the path) "
"speed if it's lower than that. If expressed as a percentage "
"it will scale the current speed."
"\nSet it at 100% to remove any first layer speed modification (with first_layer_infill_speed and first_layer_speed_min).");
def->sidetext = L("mm/s or %");
def->ratio_over = "depends";
def->min = 0;
Expand All @@ -1865,6 +1865,20 @@ void PrintConfigDef::init_fff_params()
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloatOrPercent(30, false));

def = this->add("first_layer_min_speed", coFloatOrPercent);
def->label = L("Min");
def->full_label = L("Min first layer speed");
def->category = OptionCategory::speed;
def->tooltip = L("If expressed as absolute value in mm/s, this speed will be applied to all the print moves"
", it can be overwritten by the 'default' (default depends of the type of the path) speed if it's higher than that."
" If expressed as a percentage it will scale the current speed."
"\nSet zero to disable.");
def->sidetext = L("mm/s or %");
def->ratio_over = "depends";
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));

def = this->add("first_layer_temperature", coInts);
def->label = L("First layer");
Expand Down Expand Up @@ -2687,7 +2701,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("Minimum extrusion length");
def->category = OptionCategory::speed;
def->tooltip = L("Too many too small commands may overload the firmware / connection. Put a higher value here if you see strange slowdown."
"\n0 to disable.");
"\nSet zero to disable.");
def->sidetext = L("mm");
def->min = 0;
def->precision = 8;
Expand Down Expand Up @@ -3080,7 +3094,7 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::slicing;
def->tooltip = L("Minimum detail resolution, used to simplify the input file for speeding up "
"the slicing job and reducing memory usage. High-resolution models often carry "
"more details than printers can render. Set to zero to disable any simplification "
"more details than printers can render. Set zero to disable any simplification "
"and use full resolution from input. "
"\nNote: Slic3r has an internal working resolution of 0.0001mm."
"\nInfill & Thin areas are simplified up to 0.0125mm.");
Expand Down Expand Up @@ -3359,7 +3373,7 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::cooling;
def->tooltip = L("If layer print time is estimated below this number of seconds, print moves "
"speed will be scaled down to extend duration to this value, if possible."
"\nSet to 0 to disable.");
"\nSet zero to disable.");
def->sidetext = L("approximate seconds");
def->min = 0;
def->max = 1000;
Expand Down Expand Up @@ -3454,7 +3468,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("cutoff");
def->full_label = L("Curve smoothing cutoff dist");
def->category = OptionCategory::slicing;
def->tooltip = L("Maximum distance between two points to allow adding new ones. Allow to avoid distorting long strait areas. 0 to disable.");
def->tooltip = L("Maximum distance between two points to allow adding new ones. Allow to avoid distorting long strait areas.\nSet zero to disable.");
def->sidetext = L("mm");
def->min = 0;
def->cli = "curve-smoothing-cutoff-dist=f";
Expand Down Expand Up @@ -3621,7 +3635,7 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::slicing;
def->tooltip = L("This is the rounding error of the input object."
" It's used to align points that should be in the same line."
" Put 0 to disable.");
"\nSet zero to disable.");
def->sidetext = L("mm");
def->min = 0;
def->precision = 8;
Expand Down Expand Up @@ -3687,7 +3701,7 @@ void PrintConfigDef::init_fff_params()
" This number allow to keep some if there is a low number of perimeter over the void."
"\nIf this setting is equal or higher than the top/bottom solid layer count, it won't evict anything."
"\nIf this setting is set to 1, it will evict all solid fill are are only over perimeters."
"\nSet it to 0 to disable.");
"\nSet zero to disable.");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInt(2));
Expand Down Expand Up @@ -4471,7 +4485,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Set this to the height moved when your Z motor (or equivalent) turns one step."
"If your motor needs 200 steps to move your head/plater by 1mm, this field should be 1/200 = 0.005."
"\nNote that the gcode will write the z values with 6 digits after the dot if z_step is set (it's 3 digits if it's disabled)."
"\nPut 0 to disable.");
"\nSet zero to disable.");
def->cli = "z-step=f";
def->sidetext = L("mm");
def->min = 0;
Expand Down Expand Up @@ -5538,6 +5552,7 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
"fill_smooth_width",
"fill_smooth_distribution",
"first_layer_infill_speed",
"first_layer_min_speed",
"gap_fill",
"gap_fill_min_area",
"gap_fill_overlap",
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,7 @@ class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig
ConfigOptionPercent first_layer_flow_ratio;
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionFloatOrPercent first_layer_infill_speed;
ConfigOptionFloatOrPercent first_layer_min_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionInts full_fan_speed_layer;
ConfigOptionFloatOrPercent infill_acceleration;
Expand Down Expand Up @@ -1404,6 +1405,7 @@ class PrintConfig : public MachineEnvelopeConfig, public GCodeConfig
OPT_PTR(first_layer_flow_ratio);
OPT_PTR(first_layer_speed);
OPT_PTR(first_layer_infill_speed);
OPT_PTR(first_layer_min_speed);
OPT_PTR(first_layer_temperature);
OPT_PTR(full_fan_speed_layer);
OPT_PTR(infill_acceleration);
Expand Down
23 changes: 16 additions & 7 deletions src/slic3r/GUI/PresetHints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
const auto &support_material_extrusion_width = *print_config.option<ConfigOptionFloatOrPercent>("support_material_extrusion_width");
const auto &top_infill_extrusion_width = *print_config.option<ConfigOptionFloatOrPercent>("top_infill_extrusion_width");
const auto &first_layer_speed = *print_config.option<ConfigOptionFloatOrPercent>("first_layer_speed");
const auto &first_layer_infill_speed = *print_config.option<ConfigOptionFloatOrPercent>("first_layer_infill_speed");
const auto& first_layer_infill_speed = *print_config.option<ConfigOptionFloatOrPercent>("first_layer_infill_speed");
const auto& first_layer_min_speed = *print_config.option<ConfigOptionFloatOrPercent>("first_layer_infill_speed");

// Index of an extruder assigned to a feature. If set to 0, an active extruder will be used for a multi-material print.
// If different from idx_extruder, it will not be taken into account for this hint.
Expand Down Expand Up @@ -228,16 +229,24 @@ std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle
const float bfr = bridging ? bridge_flow_ratio : 0.f;
double max_flow = 0.;
std::string max_flow_extrusion_type;
auto limit_by_first_layer_speed = [&first_layer_speed, first_layer](double speed_normal, double speed_max) {
if (first_layer && first_layer_speed.value > 0)
auto limit_by_first_layer_speed = [&first_layer_min_speed , &first_layer_speed, first_layer](double speed_normal, double speed_max) {
if (first_layer) {
const double base_speed = speed_normal;
// Apply the first layer limit.
speed_normal = first_layer_speed.get_abs_value(speed_normal);
if (first_layer_speed.value > 0)
speed_normal = std::min(first_layer_speed.get_abs_value(base_speed), speed_normal);
speed_normal = std::max(first_layer_min_speed.get_abs_value(base_speed), speed_normal);
}
return (speed_normal > 0.) ? speed_normal : speed_max;
};
auto limit_infill_by_first_layer_speed = [&first_layer_infill_speed, first_layer](double speed_normal, double speed_max) {
if (first_layer && first_layer_infill_speed.value > 0)
auto limit_infill_by_first_layer_speed = [&first_layer_min_speed, &first_layer_infill_speed, first_layer](double speed_normal, double speed_max) {
if (first_layer) {
const double base_speed = speed_normal;
// Apply the first layer limit.
speed_normal = first_layer_infill_speed.get_abs_value(speed_normal);
if(first_layer_infill_speed.value > 0)
speed_normal = std::min(first_layer_infill_speed.get_abs_value(base_speed), speed_normal);
speed_normal = std::max(first_layer_min_speed.get_abs_value(base_speed), speed_normal);
}
return (speed_normal > 0.) ? speed_normal : speed_max;
};
if (perimeter_extruder_active) {
Expand Down

0 comments on commit 498f49f

Please sign in to comment.