diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 1135220df1..fcfd83da03 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1706,17 +1706,18 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print) // M190 - Set Extruder Temperature and Wait void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait) { + bool autoemit = print.config().autoemit_temperature_commands; // Initial bed temperature based on the first extruder. int temp = print.config().first_layer_bed_temperature.get_at(first_printing_extruder_id); // Is the bed temperature set by the provided custom G-code? int temp_by_gcode = -1; bool temp_set_by_gcode = custom_gcode_sets_temperature(gcode, 140, 190, false, temp_by_gcode); - if (temp_set_by_gcode && temp_by_gcode >= 0 && temp_by_gcode < 1000) + if (autoemit && temp_set_by_gcode && temp_by_gcode >= 0 && temp_by_gcode < 1000) temp = temp_by_gcode; // Always call m_writer.set_bed_temperature() so it will set the internal "current" state of the bed temp as if // the custom start G-code emited these. std::string set_temp_gcode = m_writer.set_bed_temperature(temp, wait); - if (! temp_set_by_gcode) + if (autoemit && ! temp_set_by_gcode) file.write(set_temp_gcode); } @@ -1727,13 +1728,14 @@ void GCode::_print_first_layer_bed_temperature(GCodeOutputStream &file, Print &p // RepRapFirmware: G10 Sxx void GCode::_print_first_layer_extruder_temperatures(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait) { + bool autoemit = print.config().autoemit_temperature_commands; // Is the bed temperature set by the provided custom G-code? int temp_by_gcode = -1; bool include_g10 = print.config().gcode_flavor == gcfRepRapFirmware; - if (custom_gcode_sets_temperature(gcode, 104, 109, include_g10, temp_by_gcode)) { + if (! autoemit || custom_gcode_sets_temperature(gcode, 104, 109, include_g10, temp_by_gcode)) { // Set the extruder temperature at m_writer, but throw away the generated G-code as it will be written with the custom G-code. int temp = print.config().first_layer_temperature.get_at(first_printing_extruder_id); - if (temp_by_gcode >= 0 && temp_by_gcode < 1000) + if (autoemit && temp_by_gcode >= 0 && temp_by_gcode < 1000) temp = temp_by_gcode; m_writer.set_temperature(temp, wait, first_printing_extruder_id); } else { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 21b712217d..a584920622 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -482,7 +482,7 @@ static std::vector s_Preset_machine_limits_options { }; static std::vector s_Preset_printer_options { - "printer_technology", + "printer_technology", "autoemit_temperature_commands", "bed_shape", "bed_custom_texture", "bed_custom_model", "z_offset", "gcode_flavor", "use_relative_e_distances", "use_firmware_retraction", "use_volumetric_e", "variable_layer_height", //FIXME the print host keys are left here just for conversion from the Printer preset to Physical Printer preset. diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 2afe025175..67407e5914 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -58,6 +58,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n // Cache the plenty of parameters, which influence the G-code generator only, // or they are only notes not influencing the generated G-code. static std::unordered_set steps_gcode = { + "autoemit_temperature_commands", "avoid_crossing_perimeters", "avoid_crossing_perimeters_max_detour", "bed_shape", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 62f9a9a2f3..8a8b705018 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2490,15 +2490,25 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionInt(-5)); + def = this->add("autoemit_temperature_commands", coBool); + def->label = L("Emit temperature commands automatically"); + def->tooltip = L("When enabled, PrusaSlicer will check whether your Custom Start G-Code contains M104 or M190. " + "If so, the temperatures will not be emitted automatically so you're free to customize " + "the order of heating commands and other custom actions. Note that you can use " + "placeholder variables for all PrusaSlicer settings, so you can put " + "a \"M109 S[first_layer_temperature]\" command wherever you want.\n" + "If your Custom Start G-Code does NOT contain M104 or M190, " + "PrusaSlicer will execute the Start G-Code after bed reached its target temperature " + "and extruder just started heating.\n\n" + "When disabled, PrusaSlicer will NOT emit commands to heat up extruder and bed, " + "leaving both to Custom Start G-Code."); + def->mode = comExpert; + def->set_default_value(new ConfigOptionBool(true)); + def = this->add("start_gcode", coString); def->label = L("Start G-code"); - def->tooltip = L("This start procedure is inserted at the beginning, after bed has reached " - "the target temperature and extruder just started heating, and before extruder " - "has finished heating. If PrusaSlicer detects M104 or M190 in your custom codes, " - "such commands will not be prepended automatically so you're free to customize " - "the order of heating commands and other custom actions. Note that you can use " - "placeholder variables for all PrusaSlicer settings, so you can put " - "a \"M109 S[first_layer_temperature]\" command wherever you want."); + def->tooltip = L("This start procedure is inserted at the beginning, possibly prepended by " + "temperature-changing commands. See 'autoemit_temperature_commands'."); def->multiline = true; def->full_width = true; def->height = 12; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 265628d782..d29afe5e71 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -661,6 +661,7 @@ PRINT_CONFIG_CLASS_DEFINE( PRINT_CONFIG_CLASS_DEFINE( GCodeConfig, + ((ConfigOptionBool, autoemit_temperature_commands)) ((ConfigOptionString, before_layer_gcode)) ((ConfigOptionString, between_objects_gcode)) ((ConfigOptionFloats, deretract_speed)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6227fc5373..22e23d84e6 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2411,6 +2411,9 @@ void TabPrinter::build_fff() option.opt.height = 3 * gcode_field_height;//150; optgroup->append_single_option_line(option); + optgroup = page->new_optgroup(L("Start G-Code options")); + optgroup->append_single_option_line("autoemit_temperature_commands"); + optgroup = page->new_optgroup(L("End G-code"), 0); optgroup->m_on_change = [this, &optgroup_title = optgroup->title](const t_config_option_key& opt_key, const boost::any& value) { validate_custom_gcode_cb(this, optgroup_title, opt_key, value);