Skip to content

Commit

Permalink
Bed temperature management refinement
Browse files Browse the repository at this point in the history
This actually fixes a case where the temperature was not set properly
with one-at-a-time mode

CURA-8889
  • Loading branch information
wawanbreton committed Aug 31, 2023
1 parent d48b5fa commit 6595207
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/gcodeExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Temperature>("material_bed_temperature");
}
else if (! scene.current_mesh_group->settings.get<bool>("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<Temperature>("material_bed_temperature_layer_0");
if (! scene.current_mesh_group->settings.get<bool>("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<Temperature>("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<Temperature>("material_bed_temperature");
}
}

Expand Down Expand Up @@ -1517,31 +1520,28 @@ 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)
{
*output_stream << "M140 S"; // set the temperature, it will be used as target temperature from M105
*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)
Expand Down

0 comments on commit 6595207

Please sign in to comment.