mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:05:57 +08:00
Chamber temperature G-code emission
This commit is contained in:
parent
32dc167277
commit
126de4d648
@ -1211,9 +1211,9 @@ void GCodeGenerator::_do_export(Print& print, GCodeOutputStream &file, Thumbnail
|
||||
DoExport::init_ooze_prevention(print, m_ooze_prevention);
|
||||
|
||||
std::string start_gcode = this->placeholder_parser_process("start_gcode", print.config().start_gcode.value, initial_extruder_id);
|
||||
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
|
||||
|
||||
this->_print_first_layer_chamber_temperature(file, print, start_gcode, initial_extruder_id, false);
|
||||
this->_print_first_layer_bed_temperature(file, print, start_gcode, initial_extruder_id, true);
|
||||
// Set extruder(s) temperature before and after start G-code.
|
||||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
|
||||
|
||||
// adds tag for processor
|
||||
@ -1223,6 +1223,7 @@ 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);
|
||||
print.throw_if_canceled();
|
||||
|
||||
// Set other general things.
|
||||
@ -1889,6 +1890,31 @@ void GCodeGenerator::_print_first_layer_bed_temperature(GCodeOutputStream &file,
|
||||
file.write(set_temp_gcode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write chamber temperatures into the G-code.
|
||||
// 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)
|
||||
{
|
||||
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);
|
||||
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_chamber_temperature(temp, wait);
|
||||
if (autoemit && ! temp_set_by_gcode)
|
||||
file.write(set_temp_gcode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write 1st layer extruder temperatures into the G-code.
|
||||
// Only do that if the start G-code does not already contain any M-code controlling an extruder temperature.
|
||||
// M104 - Set Extruder Temperature
|
||||
|
@ -468,6 +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_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.
|
||||
|
@ -181,6 +181,27 @@ std::string GCodeWriter::set_bed_temperature(unsigned int temperature, bool wait
|
||||
return gcode.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string GCodeWriter::set_chamber_temperature(unsigned int temperature, bool wait) const
|
||||
{
|
||||
std::string_view code, comment;
|
||||
if (wait) {
|
||||
code = "M191"sv;
|
||||
comment = "set chamber temperature and wait for it to be reached"sv;
|
||||
} else {
|
||||
code = "M141"sv;
|
||||
comment = "set chamber temperature"sv;
|
||||
}
|
||||
|
||||
std::ostringstream gcode;
|
||||
gcode << code << " S" << temperature << " ; " << comment << "\n";
|
||||
|
||||
return gcode.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string GCodeWriter::set_acceleration_internal(Acceleration type, unsigned int acceleration)
|
||||
{
|
||||
// Clamp the acceleration to the allowed maximum.
|
||||
|
@ -52,6 +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_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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user