#614 allow acceleration to be a % of default accel

also default accel can be a % of the max extruding accel
This commit is contained in:
supermerill 2020-10-30 01:30:05 +01:00
parent 151ea0a39f
commit df3f2113b5
4 changed files with 55 additions and 43 deletions

View File

@ -90,6 +90,13 @@ NEXT: ;
return ok;
}
double get_default_acceleration(PrintConfig & config) {
double max = 0;
// on 2.3, check for enable/disable if(config.print_machine_envelope)
max = config.machine_max_acceleration_extruding.values.front();
return config.default_acceleration.get_abs_value(max);
}
void AvoidCrossingPerimeters::init_external_mp(const Print &print)
{
m_external_mp = Slic3r::make_unique<MotionPlanner>(union_ex(this->collect_contours_all_layers(print.objects())));
@ -2790,6 +2797,8 @@ std::string GCode::preamble()
before the first layer change will raise the extruder from the correct
initial Z instead of 0. */
m_writer.travel_to_z(m_config.z_offset.value);
//as this phony thing skip the acceleration writing, they have to be reset after that for real initialisation at the next move/extrusion
m_writer.set_acceleration(0);
return gcode;
}
@ -3181,7 +3190,7 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
}
// reset acceleration
m_writer.set_acceleration((unsigned int)(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
//don't wipe here
//if (m_wipe.enable)
@ -3579,7 +3588,7 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
}
// reset acceleration
m_writer.set_acceleration((unsigned int)(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
if (m_wipe.enable)
m_wipe.path = paths.front().polyline; // TODO: don't limit wipe to last path
@ -3677,7 +3686,7 @@ std::string GCode::extrude_multi_path(const ExtrusionMultiPath &multipath, const
m_wipe.path.reverse();
}
// reset acceleration
m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
return gcode;
}
@ -3714,7 +3723,7 @@ std::string GCode::extrude_multi_path3D(const ExtrusionMultiPath3D &multipath3D,
m_wipe.path.reverse();
}
// reset acceleration
m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
return gcode;
}
@ -3799,7 +3808,7 @@ std::string GCode::extrude_path(const ExtrusionPath &path, const std::string &de
m_wipe.path.reverse();
}
// reset acceleration
m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
return gcode;
}
@ -3833,7 +3842,7 @@ std::string GCode::extrude_path_3D(const ExtrusionPath3D &path, const std::strin
m_wipe.path.reverse();
}
// reset acceleration
m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
m_writer.set_acceleration((unsigned int)floor(get_default_acceleration(m_config) + 0.5));
return gcode;
}
@ -4129,17 +4138,15 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
// adjust acceleration
{
double acceleration;
double acceleration = get_default_acceleration(m_config);
if (this->on_first_layer() && m_config.first_layer_acceleration.value > 0) {
acceleration = m_config.first_layer_acceleration.value;
acceleration = m_config.first_layer_acceleration.get_abs_value(acceleration);
} else if (m_config.perimeter_acceleration.value > 0 && is_perimeter(path.role())) {
acceleration = m_config.perimeter_acceleration.value;
acceleration = m_config.perimeter_acceleration.get_abs_value(acceleration);
} else if (m_config.bridge_acceleration.value > 0 && is_bridge(path.role())) {
acceleration = m_config.bridge_acceleration.value;
acceleration = m_config.bridge_acceleration.get_abs_value(acceleration);
} else if (m_config.infill_acceleration.value > 0 && is_infill(path.role())) {
acceleration = m_config.infill_acceleration.value;
} else {
acceleration = m_config.default_acceleration.value;
acceleration = m_config.infill_acceleration.get_abs_value(acceleration);
}//TODO: add travel accel?
m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5));
}

View File

@ -250,16 +250,17 @@ void PrintConfigDef::init_fff_params()
def->min = 0;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("bridge_acceleration", coFloat);
def = this->add("bridge_acceleration", coFloatOrPercent);
def->label = L("Bridge");
def->full_label = L("Bridge acceleration");
def->category = OptionCategory::speed;
def->tooltip = L("This is the acceleration your printer will use for bridges."
"Set zero to disable acceleration control for bridges.");
def->sidetext = L("mm/s²");
"\nCan be a % of the default acceleration"
"\nSet zero to disable acceleration control for bridges.");
def->sidetext = L("mm/s² or %");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0,false));
def = this->add("bridge_angle", coFloat);
def->label = L("Bridging");
@ -541,17 +542,18 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(5.f));
def = this->add("default_acceleration", coFloat);
def = this->add("default_acceleration", coFloatOrPercent);
def->label = L("Default");
def->category = OptionCategory::speed;
def->full_label = L("Default acceleration");
def->tooltip = L("This is the acceleration your printer will be reset to after "
"the role-specific acceleration values are used (perimeter/infill). "
"Set zero to prevent resetting acceleration at all.");
def->sidetext = L("mm/s²");
"\nYou can set it as a % of the max of the X/Y machine acceleration limit."
"\nSet zero to prevent resetting acceleration at all.");
def->sidetext = L("mm/s² or %");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0,false));
def = this->add("default_filament_profile", coStrings);
def->label = L("Default filament profile");
@ -1585,16 +1587,17 @@ void PrintConfigDef::init_fff_params()
def->sidetext = L("%");
def->set_default_value(new ConfigOptionPercent(10));
def = this->add("first_layer_acceleration", coFloat);
def = this->add("first_layer_acceleration", coFloatOrPercent);
def->label = L("First layer");
def->full_label = L("First layer acceleration");
def->category = OptionCategory::speed;
def->tooltip = L("This is the acceleration your printer will use for first layer. Set zero "
"to disable acceleration control for first layer.");
def->sidetext = L("mm/s²");
def->tooltip = L("This is the acceleration your printer will use for first layer."
"\nCan be a % of the default acceleration"
"\nSet zero to disable acceleration control for first layer.");
def->sidetext = L("mm/s² or %");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0, false));
def = this->add("first_layer_bed_temperature", coInts);
def->label = L("First layer");
@ -1782,16 +1785,17 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(0));
def = this->add("infill_acceleration", coFloat);
def = this->add("infill_acceleration", coFloatOrPercent);
def->label = L("Infill");
def->full_label = L("Infill acceleration");
def->category = OptionCategory::speed;
def->tooltip = L("This is the acceleration your printer will use for infill. Set zero to disable "
"acceleration control for infill.");
def->sidetext = L("mm/s²");
def->tooltip = L("This is the acceleration your printer will use for infill."
"\nCan be a % of the default acceleration"
"\nSet zero to disable acceleration control for infill.");
def->sidetext = L("mm/s² or %");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0,false));
def = this->add("infill_every_layers", coInt);
def->label = L("Combine infill every");
@ -2439,16 +2443,17 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(-2.f));
def = this->add("perimeter_acceleration", coFloat);
def = this->add("perimeter_acceleration", coFloatOrPercent);
def->label = L("Perimeters");
def->full_label = ("Perimeter acceleration");
def->category = OptionCategory::speed;
def->tooltip = L("This is the acceleration your printer will use for perimeters. "
"A high value like 9000 usually gives good results if your hardware is up to the job."
"Set zero to disable acceleration control for perimeters.");
def->sidetext = L("mm/s²");
"\nCan be a % of the default acceleration"
"\nSet zero to disable acceleration control for perimeters.");
def->sidetext = L("mm/s² or %");
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def->set_default_value(new ConfigOptionFloatOrPercent(0,false));
def = this->add("perimeter_extruder", coInt);
def->label = L("Perimeter extruder");

View File

@ -1094,7 +1094,7 @@ public:
ConfigOptionBool avoid_crossing_not_first_layer;
ConfigOptionPoints bed_shape;
ConfigOptionInts bed_temperature;
ConfigOptionFloat bridge_acceleration;
ConfigOptionFloatOrPercent bridge_acceleration;
ConfigOptionInts bridge_fan_speed;
ConfigOptionInts chamber_temperature;
ConfigOptionBool complete_objects;
@ -1102,7 +1102,7 @@ public:
ConfigOptionEnum<CompleteObjectSort> complete_objects_sort;
ConfigOptionFloats colorprint_heights;
ConfigOptionBools cooling;
ConfigOptionFloat default_acceleration;
ConfigOptionFloatOrPercent default_acceleration;
ConfigOptionInts disable_fan_first_layers;
ConfigOptionFloat duplicate_distance;
ConfigOptionInts external_perimeter_fan_speed;
@ -1115,14 +1115,14 @@ public:
ConfigOptionStrings filament_colour;
ConfigOptionStrings filament_notes;
ConfigOptionPercents filament_shrink;
ConfigOptionFloat first_layer_acceleration;
ConfigOptionFloatOrPercent first_layer_acceleration;
ConfigOptionInts first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width;
ConfigOptionPercent first_layer_flow_ratio;
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionFloatOrPercent first_layer_infill_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionFloat infill_acceleration;
ConfigOptionFloatOrPercent infill_acceleration;
ConfigOptionInts max_fan_speed;
ConfigOptionFloats max_layer_height;
ConfigOptionFloat max_print_height;
@ -1141,7 +1141,7 @@ public:
ConfigOptionBool only_retract_when_crossing_perimeters;
ConfigOptionBool ooze_prevention;
ConfigOptionString output_filename_format;
ConfigOptionFloat perimeter_acceleration;
ConfigOptionFloatOrPercent perimeter_acceleration;
ConfigOptionStrings post_process;
ConfigOptionBool print_machine_envelope;
ConfigOptionString printer_model;

View File

@ -419,7 +419,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
for (auto el : { "top_infill_extrusion_width", "top_solid_infill_speed" })
toggle_field(el, has_top_solid_infill);
bool have_default_acceleration = config->opt_float("default_acceleration") > 0;
bool have_default_acceleration = config->option<ConfigOptionFloatOrPercent>("default_acceleration")->value > 0;
for (auto el : { "perimeter_acceleration", "infill_acceleration",
"bridge_acceleration", "first_layer_acceleration" })
toggle_field(el, have_default_acceleration);