From 8d26de63f3b00184b0627417ef409576e25b6a82 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 26 Mar 2024 11:16:31 +0100 Subject: [PATCH] The new chamber_minimal_temperature parameter is taken into account --- src/libslic3r/GCode.cpp | 11 +++++------ src/libslic3r/GCode.hpp | 2 +- src/libslic3r/GCode/GCodeWriter.cpp | 4 ++-- src/libslic3r/GCode/GCodeWriter.hpp | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ed7bd86c64..e2254aeedd 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1212,7 +1212,7 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id); - this->_print_first_layer_chamber_temperature(file, print, start_gcode, initial_extruder_id, false); + this->_print_first_layer_chamber_temperature(file, print, start_gcode, config().chamber_temperature.get_at(initial_extruder_id), false, false); this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true); this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false); @@ -1223,7 +1223,8 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail file.writeln(start_gcode); this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, true); - this->_print_first_layer_chamber_temperature(file, print, start_gcode, initial_extruder_id, true); + this->_print_first_layer_chamber_temperature(file, print, start_gcode, config().chamber_minimal_temperature.get_at(initial_extruder_id), true, false); + this->_print_first_layer_chamber_temperature(file, print, start_gcode, config().chamber_temperature.get_at(initial_extruder_id), false, false); print.throw_if_canceled(); // Set other general things. @@ -1896,11 +1897,9 @@ void GCodeGenerator::_print_first_layer_bed_temperature(GCodeOutputStream &file, // Only do that if the start G-code does not already contain any M-code controlling chamber temperature. // M141 - Set chamber Temperature // M191 - Set chamber Temperature and Wait -void GCodeGenerator::_print_first_layer_chamber_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait) +void GCodeGenerator::_print_first_layer_chamber_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, int temp, bool wait, bool accurate) { bool autoemit = print.config().autoemit_temperature_commands; - // Initial bed temperature based on the first extruder. - int temp = print.config().chamber_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, 141, 191, false, temp_by_gcode); @@ -1908,7 +1907,7 @@ void GCodeGenerator::_print_first_layer_chamber_temperature(GCodeOutputStream &f 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_chamber_temperature(temp, wait); + std::string set_temp_gcode = m_writer.set_chamber_temperature(temp, wait, accurate); if (autoemit && ! temp_set_by_gcode) file.write(set_temp_gcode); } diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 7f5020af1e..e25a2421e6 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -468,7 +468,7 @@ private: std::string _extrude( const ExtrusionAttributes &attribs, const Geometry::ArcWelder::Path &path, const std::string_view description, double speed = -1); void print_machine_envelope(GCodeOutputStream &file, const Print &print); - void _print_first_layer_chamber_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait); + void _print_first_layer_chamber_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, int temp, bool wait, bool accurate); void _print_first_layer_bed_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait); void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait); // On the first printing layer. This flag triggers first layer speeds. diff --git a/src/libslic3r/GCode/GCodeWriter.cpp b/src/libslic3r/GCode/GCodeWriter.cpp index 95166c143a..270b576454 100644 --- a/src/libslic3r/GCode/GCodeWriter.cpp +++ b/src/libslic3r/GCode/GCodeWriter.cpp @@ -183,7 +183,7 @@ std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait -std::string GCodeWriter::set_chamber_temperature(unsigned int temperature, bool wait) const +std::string GCodeWriter::set_chamber_temperature(unsigned int temperature, bool wait, bool accurate) const { std::string_view code, comment; if (wait) { @@ -195,7 +195,7 @@ std::string GCodeWriter::set_chamber_temperature(unsigned int temperature, bool } std::ostringstream gcode; - gcode << code << " S" << temperature << " ; " << comment << "\n"; + gcode << code << (accurate ? " R" : " S") << temperature << " ; " << comment << "\n"; return gcode.str(); } diff --git a/src/libslic3r/GCode/GCodeWriter.hpp b/src/libslic3r/GCode/GCodeWriter.hpp index dcb2e00ea9..42b0da4537 100644 --- a/src/libslic3r/GCode/GCodeWriter.hpp +++ b/src/libslic3r/GCode/GCodeWriter.hpp @@ -52,7 +52,7 @@ public: std::string postamble() const; std::string set_temperature(unsigned int temperature, bool wait = false, int tool = -1) const; std::string set_bed_temperature(unsigned int temperature, bool wait = false); - std::string set_chamber_temperature(unsigned int temperature, bool wait) const; + std::string set_chamber_temperature(unsigned int temperature, bool wait, bool accurate) const; std::string set_print_acceleration(unsigned int acceleration) { return set_acceleration_internal(Acceleration::Print, acceleration); } std::string set_travel_acceleration(unsigned int acceleration) { return set_acceleration_internal(Acceleration::Travel, acceleration); } std::string reset_e(bool force = false);