Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Only apply bed temperature if changed, similar to nozzle temperature
Browse files Browse the repository at this point in the history
Of course, it still needs to be applied if waiting for it.

Contributes to issue CURA-8590.
  • Loading branch information
Ghostkeeper committed Sep 24, 2021
1 parent 54f8867 commit e5aedd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/gcodeExport.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2020 Ultimaker B.V.
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#include <assert.h>
Expand Down Expand Up @@ -55,6 +55,7 @@ GCodeExport::GCodeExport()
is_z_hopped = 0;
setFlavor(EGCodeFlavor::MARLIN);
initial_bed_temp = 0;
bed_temperature = 0;
build_volume_temperature = 0;
machine_heated_build_volume = false;

Expand Down Expand Up @@ -1271,18 +1272,23 @@ void GCodeExport::writeBedTemperatureCommand(const Temperature& temperature, con

if (wait)
{
if(flavor == EGCodeFlavor::MARLIN)
if(bed_temperature != temperature) //Not already at the desired temperature.
{
*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;
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";
}
else
else if(bed_temperature != temperature)
{
*output_stream << "M140 S";
}
*output_stream << PrecisionedDouble{1, temperature} << new_line;
bed_temperature = temperature;
}

void GCodeExport::writeBuildVolumeTemperatureCommand(const Temperature& temperature, const bool wait)
Expand Down
3 changes: 2 additions & 1 deletion src/gcodeExport.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2019 Ultimaker B.V.
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef GCODEEXPORT_H
Expand Down Expand Up @@ -154,6 +154,7 @@ class GCodeExport : public NoCopy
bool always_write_active_tool; //!< whether to write the active tool after sending commands to inactive tool

Temperature initial_bed_temp; //!< bed temperature at the beginning of the print.
Temperature bed_temperature; //!< Current build plate temperature.
Temperature build_volume_temperature; //!< build volume temperature
bool machine_heated_build_volume; //!< does the machine have the ability to control/stabilize build-volume-temperature
protected:
Expand Down
4 changes: 3 additions & 1 deletion tests/GCodeExportTest.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright (c) 2019 Ultimaker B.V.
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#include <gtest/gtest.h>
Expand Down Expand Up @@ -56,6 +56,7 @@ class GCodeExportTest : public testing::Test
gcode.current_jerk = -1;
gcode.is_z_hopped = 0;
gcode.setFlavor(EGCodeFlavor::MARLIN);
gcode.bed_temperature = 0;
gcode.initial_bed_temp = 0;
gcode.fan_number = 0;
gcode.total_bounding_box = AABB3D();
Expand Down Expand Up @@ -209,6 +210,7 @@ class GriffinHeaderTest : public testing::TestWithParam<size_t>
gcode.is_z_hopped = 0;
gcode.setFlavor(EGCodeFlavor::MARLIN);
gcode.initial_bed_temp = 0;
gcode.bed_temperature = 0;
gcode.fan_number = 0;
gcode.total_bounding_box = AABB3D();

Expand Down

0 comments on commit e5aedd0

Please sign in to comment.