mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 15:07:31 -06:00
ENH: add jerk parameter
thanks SoftFever Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I6aadbffebc069167a460c991aa8fb711b754ff37
This commit is contained in:
parent
208f7c32da
commit
aa62c6e870
12 changed files with 189 additions and 14 deletions
|
@ -1873,11 +1873,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
gcode += m_writer.set_acceleration((unsigned int) floor(m_config.outer_wall_acceleration.value + 0.5));
|
||||
}
|
||||
|
||||
// todo: 3rd party printer need
|
||||
//if (m_config.default_jerk.value > 0) {
|
||||
// double jerk = m_config.outer_wall_jerk.value;
|
||||
// gcode += m_writer.set_jerk_xy(jerk);
|
||||
//}
|
||||
if (m_config.default_jerk.value > 0 && !this->is_BBL_Printer()) {
|
||||
double jerk = m_config.outer_wall_jerk.value;
|
||||
gcode += m_writer.set_jerk_xy(jerk);
|
||||
}
|
||||
|
||||
calib_pressure_advance pa_test(this);
|
||||
double filament_max_volumetric_speed = m_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(initial_extruder_id);
|
||||
|
@ -2807,6 +2806,9 @@ GCode::LayerResult GCode::process_layer(
|
|||
double acceleration = m_config.initial_layer_acceleration.value;
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5));
|
||||
}
|
||||
|
||||
if (m_config.default_jerk.value > 0 && m_config.initial_layer_jerk.value > 0 && !this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.initial_layer_jerk.value);
|
||||
}
|
||||
|
||||
if (! first_layer && ! m_second_layer_things_done) {
|
||||
|
@ -2831,6 +2833,10 @@ GCode::LayerResult GCode::process_layer(
|
|||
double acceleration = m_config.default_acceleration.value;
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5));
|
||||
}
|
||||
|
||||
if (m_config.default_jerk.value > 0 && m_config.initial_layer_jerk.value > 0 && !this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.default_jerk.value);
|
||||
|
||||
// Transition from 1st to 2nd layer. Adjust nozzle temperatures as prescribed by the nozzle dependent
|
||||
// nozzle_temperature_initial_layer vs. temperature settings.
|
||||
for (const Extruder &extruder : m_writer.extruders()) {
|
||||
|
@ -3472,9 +3478,13 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
|
|||
}
|
||||
|
||||
//BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value.
|
||||
if (!this->on_first_layer())
|
||||
if (!this->on_first_layer()) {
|
||||
// reset acceleration
|
||||
gcode += m_writer.set_acceleration((unsigned int)(m_config.default_acceleration.value + 0.5));
|
||||
gcode += m_writer.set_acceleration((unsigned int) (m_config.default_acceleration.value + 0.5));
|
||||
if (!this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.default_jerk.value);
|
||||
}
|
||||
|
||||
|
||||
// BBS
|
||||
if (m_wipe.enable) {
|
||||
|
@ -3553,9 +3563,12 @@ std::string GCode::extrude_multi_path(ExtrusionMultiPath multipath, std::string
|
|||
m_wipe.path.reverse();
|
||||
}
|
||||
//BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value.
|
||||
if (!this->on_first_layer())
|
||||
if (!this->on_first_layer()) {
|
||||
// reset acceleration
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
|
||||
gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.value + 0.5));
|
||||
if (!this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.default_jerk.value);
|
||||
}
|
||||
return gcode;
|
||||
}
|
||||
|
||||
|
@ -3581,9 +3594,12 @@ std::string GCode::extrude_path(ExtrusionPath path, std::string description, dou
|
|||
m_wipe.path.reverse();
|
||||
}
|
||||
//BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value.
|
||||
if (!this->on_first_layer())
|
||||
if (!this->on_first_layer()) {
|
||||
// reset acceleration
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(m_config.default_acceleration.value + 0.5));
|
||||
gcode += m_writer.set_acceleration((unsigned int) floor(m_config.default_acceleration.value + 0.5));
|
||||
if (!this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.default_jerk.value);
|
||||
}
|
||||
return gcode;
|
||||
}
|
||||
|
||||
|
@ -3798,6 +3814,21 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5));
|
||||
}
|
||||
|
||||
if (m_config.default_jerk.value > 0 && !this->is_BBL_Printer()) {
|
||||
double jerk = m_config.default_jerk.value;
|
||||
if (this->on_first_layer() && m_config.initial_layer_jerk.value > 0)
|
||||
jerk = m_config.initial_layer_jerk.value;
|
||||
else if (m_config.outer_wall_jerk.value > 0 && path.role() == erExternalPerimeter)
|
||||
jerk = m_config.outer_wall_jerk.value;
|
||||
else if (m_config.inner_wall_jerk.value > 0 && path.role() == erPerimeter)
|
||||
jerk = m_config.inner_wall_jerk.value;
|
||||
else if (m_config.infill_jerk.value > 0 && is_infill(path.role()))
|
||||
jerk = m_config.infill_jerk.value;
|
||||
else if (m_config.top_surface_jerk.value > 0 && is_top_surface(path.role()))
|
||||
jerk = m_config.top_surface_jerk.value;
|
||||
|
||||
gcode += m_writer.set_jerk_xy(jerk);
|
||||
}
|
||||
// calculate extrusion length per distance unit
|
||||
auto _mm3_per_mm = path.mm3_per_mm * double(m_curr_print->calib_mode() == CalibMode::Calib_Flow_Rate ? this->config().print_flow_ratio.value : 1);
|
||||
|
||||
|
@ -4129,6 +4160,13 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
|
|||
|
||||
// use G1 because we rely on paths being straight (G0 may make round paths)
|
||||
if (travel.size() >= 2) {
|
||||
// SoftFever
|
||||
if (this->on_first_layer()) {
|
||||
if (m_config.default_jerk.value > 0 && m_config.initial_layer_jerk.value > 0 && !this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.initial_layer_jerk.value);
|
||||
} else if (m_config.default_jerk.value > 0 && m_config.travel_jerk.value > 0 && !this->is_BBL_Printer())
|
||||
gcode += m_writer.set_jerk_xy(m_config.travel_jerk.value);
|
||||
|
||||
for (size_t i = 1; i < travel.size(); ++ i) {
|
||||
// BBS. Process lazy layer change, but don't do lazy layer change when enable spiral vase
|
||||
Vec3d curr_pos = m_writer.get_position();
|
||||
|
|
|
@ -26,6 +26,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
|||
|| print_config.gcode_flavor.value == gcfMarlinFirmware
|
||||
|| print_config.gcode_flavor.value == gcfKlipper;
|
||||
m_max_acceleration = std::lrint(is_marlin ? print_config.machine_max_acceleration_extruding.values.front() : 0);
|
||||
m_max_jerk = std::lrint(is_marlin ? std::min(print_config.machine_max_jerk_x.values.front(), print_config.machine_max_jerk_y.values.front()) : 0);
|
||||
}
|
||||
|
||||
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
||||
|
@ -203,6 +204,27 @@ std::string GCodeWriter::set_pressure_advance(double pa) const
|
|||
return gcode.str();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::set_jerk_xy(double jerk)
|
||||
{
|
||||
// Clamp the jerk to the allowed maximum.
|
||||
if (m_max_jerk > 0 && jerk > m_max_jerk) jerk = m_max_jerk;
|
||||
|
||||
if (jerk < 0.01 || is_approx(jerk, m_last_jerk)) return std::string();
|
||||
|
||||
m_last_jerk = jerk;
|
||||
|
||||
std::ostringstream gcode;
|
||||
if (FLAVOR_IS(gcfKlipper))
|
||||
gcode << "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=" << jerk;
|
||||
else
|
||||
gcode << "M205 X" << jerk << " Y" << jerk;
|
||||
|
||||
if (GCodeWriter::full_gcode_comment) gcode << " ; adjust jerk";
|
||||
gcode << "\n";
|
||||
|
||||
return gcode.str();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::reset_e(bool force)
|
||||
{
|
||||
if (FLAVOR_IS(gcfMach3)
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
multiple_extruders(false), m_extruder(nullptr),
|
||||
m_single_extruder_multi_material(false),
|
||||
m_last_acceleration(0), m_max_acceleration(0),
|
||||
m_last_jerk(0), m_max_jerk(0),
|
||||
/*m_last_bed_temperature(0), */m_last_bed_temperature_reached(true),
|
||||
m_lifted(0),
|
||||
m_to_lift(0),
|
||||
|
@ -51,6 +52,7 @@ public:
|
|||
std::string set_bed_temperature(int temperature, bool wait = false);
|
||||
std::string set_acceleration(unsigned int acceleration);
|
||||
std::string set_pressure_advance(double pa) const;
|
||||
std::string set_jerk_xy(double jerk);
|
||||
std::string reset_e(bool force = false);
|
||||
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
|
||||
// return false if this extruder was already selected
|
||||
|
@ -115,6 +117,8 @@ private:
|
|||
// Limit for setting the acceleration, to respect the machine limits set for the Marlin firmware.
|
||||
// If set to zero, the limit is not in action.
|
||||
unsigned int m_max_acceleration;
|
||||
double m_last_jerk;
|
||||
double m_max_jerk;
|
||||
//BBS
|
||||
unsigned int m_last_additional_fan_speed;
|
||||
int m_last_bed_temperature;
|
||||
|
|
|
@ -759,6 +759,7 @@ static std::vector<std::string> s_Preset_print_options {
|
|||
"wall_generator", "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle",
|
||||
"wall_distribution_count", "min_feature_size", "min_bead_width", "post_process",
|
||||
"seam_gap", "wipe_speed", "top_solid_infill_flow_ratio", "bottom_solid_infill_flow_ratio",
|
||||
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk", "travel_jerk",
|
||||
// calib
|
||||
"print_flow_ratio"
|
||||
};
|
||||
|
|
|
@ -150,6 +150,13 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
|||
//SoftFever
|
||||
"seam_gap",
|
||||
"wipe_speed"
|
||||
"default_jerk",
|
||||
"outer_wall_jerk",
|
||||
"inner_wall_jerk",
|
||||
"infill_jerk",
|
||||
"top_surface_jerk",
|
||||
"initial_layer_jerk",
|
||||
"travel_jerk"
|
||||
};
|
||||
|
||||
static std::unordered_set<std::string> steps_ignore;
|
||||
|
|
|
@ -1411,6 +1411,62 @@ void PrintConfigDef::init_fff_params()
|
|||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(300));
|
||||
|
||||
def = this->add("default_jerk", coFloat);
|
||||
def->label = L("Default");
|
||||
def->tooltip = L("Default jerk");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
def = this->add("outer_wall_jerk", coFloat);
|
||||
def->label = L("Outer wall");
|
||||
def->tooltip = L("Jerk of outer walls");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("inner_wall_jerk", coFloat);
|
||||
def->label = L("Inner wall");
|
||||
def->tooltip = L("Jerk of inner walls");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("infill_jerk", coFloat);
|
||||
def->label = L("Infill");
|
||||
def->tooltip = L("Jerk of infill");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("top_surface_jerk", coFloat);
|
||||
def->label = L("Top surface");
|
||||
def->tooltip = L("Jerk of top surface");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("initial_layer_jerk", coFloat);
|
||||
def->label = L("First layer");
|
||||
def->tooltip = L("Jerk of first layer");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("travel_jerk", coFloat);
|
||||
def->label = L("Travel");
|
||||
def->tooltip = L("Jerk of travel");
|
||||
def->sidetext = L("mm/s");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloat(9));
|
||||
|
||||
def = this->add("initial_layer_line_width", coFloat);
|
||||
def->label = L("Initial layer");
|
||||
def->category = L("Quality");
|
||||
|
|
|
@ -962,6 +962,14 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
|||
((ConfigOptionFloat, nozzle_volume))
|
||||
((ConfigOptionPoints, start_end_points))
|
||||
((ConfigOptionEnum<TimelapseType>, timelapse_type))
|
||||
((ConfigOptionFloat, default_jerk))
|
||||
((ConfigOptionFloat, outer_wall_jerk))
|
||||
((ConfigOptionFloat, inner_wall_jerk))
|
||||
((ConfigOptionFloat, infill_jerk))
|
||||
((ConfigOptionFloat, top_surface_jerk))
|
||||
((ConfigOptionFloat, initial_layer_jerk))
|
||||
((ConfigOptionFloat, travel_jerk))
|
||||
|
||||
// BBS: move from PrintObjectConfig
|
||||
((ConfigOptionBool, independent_support_layer_height))
|
||||
)
|
||||
|
|
|
@ -571,6 +571,17 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
|
|||
//BBS
|
||||
for (auto el : { "initial_layer_acceleration", "outer_wall_acceleration", "top_surface_acceleration" })
|
||||
toggle_field(el, have_default_acceleration);
|
||||
if (is_BBL_Printer) {
|
||||
for (auto el : {"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk", "travel_jerk"})
|
||||
toggle_line(el, false);
|
||||
} else {
|
||||
for (auto el : {"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk", "travel_jerk"})
|
||||
toggle_line(el, true);
|
||||
|
||||
bool quality_default_jerk = config->opt_float("default_jerk") > 0;
|
||||
for (auto el : {"outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk", "travel_jerk"})
|
||||
toggle_field(el, quality_default_jerk);
|
||||
}
|
||||
|
||||
bool have_skirt = config->opt_int("skirt_loops") > 0;
|
||||
toggle_field("skirt_height", have_skirt && config->opt_enum<DraftShield>("draft_shield") != dsEnabled);
|
||||
|
|
|
@ -23,6 +23,7 @@ class ConfigManipulation
|
|||
bool is_msg_dlg_already_exist{ false };
|
||||
bool m_is_initialized_support_material_overhangs_queried{ false };
|
||||
bool m_support_material_overhangs_queried{ false };
|
||||
bool is_BBL_Printer{false};
|
||||
|
||||
// function to loading of changed configuration
|
||||
std::function<void()> load_config = nullptr;
|
||||
|
@ -77,7 +78,7 @@ public:
|
|||
void check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config);
|
||||
void check_bed_temperature_difference(int bed_type, DynamicPrintConfig* config);
|
||||
void check_filament_max_volumetric_speed(DynamicPrintConfig *config);
|
||||
|
||||
void set_is_BBL_Printer(bool is_bbl_printer) { is_BBL_Printer = is_bbl_printer; };
|
||||
// SLA print
|
||||
void update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config = false);
|
||||
void toggle_print_sla_options(DynamicPrintConfig* config);
|
||||
|
|
|
@ -356,6 +356,10 @@ void ObjectSettings::update_config_values(ModelConfig* config)
|
|||
|
||||
//BBS: change local config to DynamicPrintConfig
|
||||
ConfigManipulation config_manipulation(load_config, toggle_field, nullptr, nullptr, &(config->get()));
|
||||
// BBS: whether the preset is Bambu Lab printer
|
||||
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||
bool is_BBL_printer = preset_bundle.printers.get_edited_preset().is_bbl_vendor_preset(&preset_bundle);
|
||||
config_manipulation.set_is_BBL_Printer(is_BBL_printer);
|
||||
|
||||
if (!is_object_settings)
|
||||
{
|
||||
|
|
|
@ -296,6 +296,10 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
|
|||
if (line) line->toggle_visible = toggle;
|
||||
};
|
||||
ConfigManipulation config_manipulation(nullptr, toggle_field, toggle_line, nullptr, &m_current_config);
|
||||
// BBS: whether the preset is Bambu Lab printer
|
||||
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||
bool is_BBL_printer = preset_bundle.printers.get_edited_preset().is_bbl_vendor_preset(&preset_bundle);
|
||||
config_manipulation.set_is_BBL_Printer(is_BBL_printer);
|
||||
|
||||
printer_technology == ptFFF ? config_manipulation.toggle_print_fff_options(&m_current_config) :
|
||||
config_manipulation.toggle_print_sla_options(&m_current_config) ;
|
||||
|
@ -397,6 +401,10 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje
|
|||
};
|
||||
|
||||
ConfigManipulation config_manipulation(nullptr, toggle_field, toggle_line, nullptr, &m_current_config);
|
||||
// BBS: whether the preset is Bambu Lab printer
|
||||
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||
bool is_BBL_printer = preset_bundle.printers.get_edited_preset().is_bbl_vendor_preset(&preset_bundle);
|
||||
config_manipulation.set_is_BBL_Printer(is_BBL_printer);
|
||||
|
||||
printer_technology == ptFFF ? config_manipulation.update_print_fff_config(&main_config) :
|
||||
config_manipulation.update_print_sla_config(&main_config) ;
|
||||
|
|
|
@ -1948,6 +1948,15 @@ void TabPrint::build()
|
|||
optgroup->append_single_option_line("top_surface_acceleration");
|
||||
optgroup->append_single_option_line("default_acceleration");
|
||||
|
||||
optgroup = page->new_optgroup(L("Jerk(XY)"), L"param_acceleration", 15);
|
||||
optgroup->append_single_option_line("default_jerk");
|
||||
optgroup->append_single_option_line("outer_wall_jerk");
|
||||
optgroup->append_single_option_line("inner_wall_jerk");
|
||||
optgroup->append_single_option_line("infill_jerk");
|
||||
optgroup->append_single_option_line("top_surface_jerk");
|
||||
optgroup->append_single_option_line("initial_layer_jerk");
|
||||
optgroup->append_single_option_line("travel_jerk");
|
||||
|
||||
#ifdef HAS_PRESSURE_EQUALIZER
|
||||
optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_positive");
|
||||
optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative");
|
||||
|
@ -2091,6 +2100,11 @@ void TabPrint::update_description_lines()
|
|||
void TabPrint::toggle_options()
|
||||
{
|
||||
if (!m_active_page) return;
|
||||
// BBS: whether the preset is Bambu Lab printer
|
||||
if (m_preset_bundle) {
|
||||
bool is_BBL_printer = m_preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(m_preset_bundle);
|
||||
m_config_manipulation.set_is_BBL_Printer(is_BBL_printer);
|
||||
}
|
||||
|
||||
m_config_manipulation.toggle_print_fff_options(m_config, m_type < Preset::TYPE_COUNT);
|
||||
|
||||
|
@ -2836,9 +2850,10 @@ void TabFilament::toggle_options()
|
|||
toggle_line("enable_pressure_advance", !is_BBL_printer);
|
||||
if (is_BBL_printer)
|
||||
toggle_line("pressure_advance", false);
|
||||
else
|
||||
else {
|
||||
toggle_line("pressure_advance", true);
|
||||
toggle_option("pressure_advance", m_config->opt_bool("enable_pressure_advance", 0));
|
||||
|
||||
}
|
||||
toggle_line("chamber_temperature", !is_BBL_printer);
|
||||
for (auto el :
|
||||
{"cool_plate_temp", "cool_plate_temp_initial_layer", "eng_plate_temp", "eng_plate_temp_initial_layer", "textured_plate_temp", "textured_plate_temp_initial_layer"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue