From 6595207a83326bd8f5daf4d37671c5994d29ccd2 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Thu, 31 Aug 2023 13:32:20 +0200 Subject: [PATCH] Bed temperature management refinement This actually fixes a case where the temperature was not set properly with one-at-a-time mode CURA-8889 --- src/gcodeExport.cpp | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index e8b421b94a..396f702508 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -111,19 +111,22 @@ void GCodeExport::preSetup(const size_t start_extruder) estimateCalculator.setFirmwareDefaults(mesh_group->settings); - if (mesh_group != scene.mesh_groups.begin()) + if (mesh_group == scene.mesh_groups.begin()) { - // Current bed temperature is the one of the previous group - bed_temperature = (scene.current_mesh_group - 1)->settings.get("material_bed_temperature"); - } - else if (! scene.current_mesh_group->settings.get("material_bed_temp_prepend")) - { - // Current bed temperature is the one of the first layer (has already been set in header) - bed_temperature = scene.current_mesh_group->settings.get("material_bed_temperature_layer_0"); + if (! scene.current_mesh_group->settings.get("material_bed_temp_prepend")) + { + // Current bed temperature is the one of the first layer (has already been set in header) + bed_temperature = scene.current_mesh_group->settings.get("material_bed_temperature_layer_0"); + } + else + { + // Bed temperature has not been set yet + } } else { - // Current bed temperature has not been set yet + // Current bed temperature is the one of the previous group + bed_temperature = (scene.current_mesh_group - 1)->settings.get("material_bed_temperature"); } } @@ -1517,10 +1520,10 @@ void GCodeExport::writeBedTemperatureCommand(const Temperature& temperature, con { // The UM2 family doesn't support temperature commands (they are fixed in the firmware) return; } - bool wrote_command = false; - if (wait) + + if (bed_temperature != temperature) // Not already at the desired temperature. { - if (bed_temperature != temperature) // Not already at the desired temperature. + if (wait) { if (flavor == EGCodeFlavor::MARLIN) { @@ -1528,20 +1531,17 @@ void GCodeExport::writeBedTemperatureCommand(const Temperature& temperature, con *output_stream << PrecisionedDouble{ 1, temperature } << new_line; *output_stream << "M105" << new_line; } + *output_stream << "M190 S"; } - *output_stream << "M190 S"; - wrote_command = true; - } - else if (bed_temperature != temperature) - { - *output_stream << "M140 S"; - wrote_command = true; - } - if (wrote_command) - { + else + { + *output_stream << "M140 S"; + } + *output_stream << PrecisionedDouble{ 1, temperature } << new_line; + + bed_temperature = temperature; } - bed_temperature = temperature; } void GCodeExport::writeBuildVolumeTemperatureCommand(const Temperature& temperature, const bool wait)