Skip to content

Commit

Permalink
Better handling of changing bed temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Aug 31, 2023
1 parent 14c3036 commit d48b5fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,8 +1886,7 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
mesh_group_settings.get<Ratio>("flow_rate_extrusion_offset_factor")); // Offset is in mm.

static LayerIndex layer_1{ 1 - static_cast<LayerIndex>(Raft::getTotalExtraLayers()) };
if (layer_nr == layer_1 && mesh_group_settings.get<bool>("machine_heated_bed")
&& mesh_group_settings.get<Temperature>("material_bed_temperature") != mesh_group_settings.get<Temperature>("material_bed_temperature_layer_0"))
if (layer_nr == layer_1 && mesh_group_settings.get<bool>("machine_heated_bed"))
{
constexpr bool wait = false;
gcode.writeBedTemperatureCommand(mesh_group_settings.get<Temperature>("material_bed_temperature"), wait);
Expand Down
34 changes: 20 additions & 14 deletions src/gcodeExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ void GCodeExport::preSetup(const size_t start_extruder)
}

estimateCalculator.setFirmwareDefaults(mesh_group->settings);

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");
}
else
{
// Current bed temperature has not been set yet
}
}

void GCodeExport::setInitialAndBuildVolumeTemps(const unsigned int start_extruder_nr)
Expand Down Expand Up @@ -708,21 +723,12 @@ bool GCodeExport::initializeExtruderTrains(const SliceDataStorage& storage, cons

void GCodeExport::processInitialLayerBedTemperature()
{
Scene& scene = Application::getInstance().current_slice->scene;

if (scene.current_mesh_group->settings.get<bool>("material_bed_temp_prepend") && scene.current_mesh_group->settings.get<bool>("machine_heated_bed"))
const Scene& scene = Application::getInstance().current_slice->scene;
const bool heated = scene.current_mesh_group->settings.get<bool>("machine_heated_bed");
const Temperature bed_temp = scene.current_mesh_group->settings.get<Temperature>("material_bed_temperature_layer_0");
if (heated && bed_temp != 0)
{
const Temperature bed_temp = scene.current_mesh_group->settings.get<Temperature>("material_bed_temperature_layer_0");
if (scene.current_mesh_group == scene.mesh_groups.begin() // Always write bed temperature for first mesh group.
|| bed_temp
!= (scene.current_mesh_group - 1)
->settings.get<Temperature>("material_bed_temperature")) // Don't write bed temperature if identical to temperature of previous group.
{
if (bed_temp != 0)
{
writeBedTemperatureCommand(bed_temp, scene.current_mesh_group->settings.get<bool>("material_bed_temp_wait"));
}
}
writeBedTemperatureCommand(bed_temp, scene.current_mesh_group->settings.get<bool>("material_bed_temp_wait"));
}
}

Expand Down

0 comments on commit d48b5fa

Please sign in to comment.