diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 20d85082e5..13ca4ced67 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -581,6 +581,10 @@ static std::vector get_path_of_change_filament(const Print& print) gcode += tcr_gcode; check_add_eol(toolchange_gcode_str); + //SoftFever: set new PA for new filament. BBS: never use for Bambu Printer + if (!gcodegen.is_BBL_Printer() && gcodegen.config().enable_pressure_advance.get_at(new_extruder_id)) + gcode += gcodegen.writer().set_pressure_advance(gcodegen.config().pressure_advance.get_at(new_extruder_id)); + // A phony move to the end position at the wipe tower. gcodegen.writer().travel_to_xy(end_pos.cast()); gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, end_pos + plate_origin_2d)); @@ -1037,6 +1041,13 @@ namespace DoExport { } } // namespace DoExport +bool GCode::is_BBL_Printer() +{ + if (m_curr_print) + return m_curr_print->is_BBL_Printer(); + return false; +} + void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb) { PROFILE_CLEAR(); @@ -4295,6 +4306,10 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z) gcode += this->placeholder_parser_process("filament_start_gcode", filament_start_gcode, extruder_id); check_add_eol(gcode); } + //BBS: never use for Bambu Printer + if (!this->is_BBL_Printer() && m_config.enable_pressure_advance.get_at(extruder_id)) + gcode += m_writer.set_pressure_advance(m_config.pressure_advance.get_at(extruder_id)); + gcode += m_writer.toolchange(extruder_id); return gcode; } @@ -4473,6 +4488,9 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z) // Set the new extruder to the operating temperature. if (m_ooze_prevention.enable) gcode += m_ooze_prevention.post_toolchange(*this); + //BBS: never use for Bambu Printer + if (!this->is_BBL_Printer() && m_config.enable_pressure_advance.get_at(extruder_id)) + gcode += m_writer.set_pressure_advance(m_config.pressure_advance.get_at(extruder_id)); return gcode; } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 4988699639..ab469f24ef 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -202,6 +202,8 @@ public: bool needs_retraction(const Polyline &travel, ExtrusionRole role, LiftType &lift_type); std::string retract(bool toolchange = false, bool is_last_retraction = false, LiftType lift_type = LiftType::SpiralLift); std::string unretract() { return m_writer.unlift() + m_writer.unretract(); } + //BBS + bool is_BBL_Printer(); // Object and support extrusions of the same PrintObject at the same print_z. // public, so that it could be accessed by free helper functions from GCode.cpp diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 0c3ca21d04..7b88ccf748 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -784,7 +784,7 @@ static std::vector s_Preset_filament_options { "filament_wipe_distance", "additional_cooling_fan_speed", "bed_temperature_difference", "nozzle_temperature_range_low", "nozzle_temperature_range_high", //softfever - "chamber_temperature" + "enable_pressure_advance", "pressure_advance", "chamber_temperature" }; static std::vector s_Preset_machine_limits_options { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index fb25b3fed0..87657f249f 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -77,6 +77,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n //BBS: add bed_exclude_area "bed_exclude_area", "before_layer_change_gcode", + "enable_pressure_advance", + "pressure_advance", "enable_overhang_bridge_fan" "overhang_fan_speed", "overhang_fan_threshold", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c2b7ed552d..f0cdd8e052 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1136,6 +1136,18 @@ void PrintConfigDef::init_fff_params() def->min = 0.01; def->set_default_value(new ConfigOptionFloat(1)); + def = this->add("enable_pressure_advance", coBools); + def->label = L("Enable pressure advance"); + def->tooltip = L("Enable pressure advance, auto calibration result will be overwriten once enabled. Useless for Bambu Printer"); + def->set_default_value(new ConfigOptionBools{ false }); + + def = this->add("pressure_advance", coFloats); + def->label = L("Pressure advance"); + def->tooltip = L("Pressure advance(Klipper) AKA Linear advance factor(Marlin). Useless for Bambu Printer"); + def->max = 2; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloats{ 0.02 }); + def = this->add("line_width", coFloat); def->label = L("Default"); def->category = L("Quality"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 557aff9223..9c975bfc21 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -807,6 +807,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, machine_end_gcode)) ((ConfigOptionStrings, filament_end_gcode)) ((ConfigOptionFloats, filament_flow_ratio)) + ((ConfigOptionBools, enable_pressure_advance)) + ((ConfigOptionFloats, pressure_advance)) ((ConfigOptionFloats, filament_diameter)) ((ConfigOptionFloats, filament_density)) ((ConfigOptionStrings, filament_type)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 0121cecde0..265fa16587 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2606,6 +2606,8 @@ void TabFilament::build() optgroup->append_single_option_line("default_filament_colour"); optgroup->append_single_option_line("filament_diameter"); optgroup->append_single_option_line("filament_flow_ratio"); + optgroup->append_single_option_line("enable_pressure_advance"); + optgroup->append_single_option_line("pressure_advance"); optgroup->append_single_option_line("filament_density"); optgroup->append_single_option_line("filament_cost"); //BBS @@ -2828,6 +2830,13 @@ void TabFilament::toggle_options() } if (m_active_page->title() == "Filament") { + //BBS: hide these useless option for bambu printer + toggle_line("enable_pressure_advance", !is_BBL_printer); + if (is_BBL_printer) + toggle_line("pressure_advance", false); + else + toggle_option("pressure_advance", m_config->opt_bool("enable_pressure_advance", 0)); + toggle_line("chamber_temperature", !is_BBL_printer); }