mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 05:50:37 +08:00
Added a new config option to disable automatic temperature commands around start gcode (autoemit_temperature_commands)
This commit is contained in:
parent
da714c7210
commit
09122fb0d0
@ -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 {
|
||||
|
@ -482,7 +482,7 @@ static std::vector<std::string> s_Preset_machine_limits_options {
|
||||
};
|
||||
|
||||
static std::vector<std::string> 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.
|
||||
|
@ -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<std::string> steps_gcode = {
|
||||
"autoemit_temperature_commands",
|
||||
"avoid_crossing_perimeters",
|
||||
"avoid_crossing_perimeters_max_detour",
|
||||
"bed_shape",
|
||||
|
@ -2490,15 +2490,25 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comExpert;
|
||||
def->set_default_value(new ConfigOptionInt(-5));
|
||||
|
||||
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 "
|
||||
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.");
|
||||
"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, possibly prepended by "
|
||||
"temperature-changing commands. See 'autoemit_temperature_commands'.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 12;
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user