From c5c1cab4f90e3326aac68c3acd888578c49970a8 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 12 Jul 2016 19:26:17 -0500 Subject: [PATCH 1/2] Adds new has_heatbed option to capabilities to disable autogeneration of bed temp settings. --- lib/Slic3r/GUI/Tab.pm | 3 ++- lib/Slic3r/Print/GCode.pm | 6 +++--- xs/src/libslic3r/PrintConfig.cpp | 5 +++++ xs/src/libslic3r/PrintConfig.hpp | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index fe4c7e452..bbdf5c2f9 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -990,7 +990,7 @@ sub build { my (%params) = @_; $self->init_config_options(qw( - bed_shape z_offset + bed_shape z_offset has_heatbed gcode_flavor use_relative_e_distances serial_port serial_speed octoprint_host octoprint_apikey @@ -1057,6 +1057,7 @@ sub build { ); $optgroup->append_single_option_line($option); } + $optgroup->append_single_option_line('has_heatbed'); $optgroup->on_change(sub { my ($opt_id) = @_; if ($opt_id eq 'extruders_count') { diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 3c32875ed..798395ba3 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -162,7 +162,7 @@ sub export { if $self->config->cooling && $self->config->disable_fan_first_layers; # set bed temperature - if ((my $temp = $self->config->first_layer_bed_temperature) && $self->config->start_gcode !~ /M(?:190|140)/i) { + if ($self->config->has_heatbed && (my $temp = $self->config->first_layer_bed_temperature) && $self->config->start_gcode !~ /M(?:190|140)/i) { printf $fh $gcodegen->writer->set_bed_temperature($temp, 1); } @@ -264,7 +264,7 @@ sub export { # is triggered, so machine has more time to reach such temperatures if ($layer->id == 0 && $finished_objects > 0) { printf $fh $gcodegen->writer->set_bed_temperature($self->config->first_layer_bed_temperature), - if $self->config->first_layer_bed_temperature; + if $self->config->first_layer_bed_temperature && $self->config->has_heatbed; $self->_print_first_layer_temperature(0); } $self->process_layer($layer, [$copy]); @@ -375,7 +375,7 @@ sub process_layer { if $temperature && $temperature != $self->config->get_at('first_layer_temperature', $extruder->id); } $gcode .= $self->_gcodegen->writer->set_bed_temperature($self->print->config->bed_temperature) - if $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature; + if $self->config->has_heatbed && $self->print->config->bed_temperature && $self->print->config->bed_temperature != $self->print->config->first_layer_bed_temperature; $self->_second_layer_things_done(1); } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 90af82fbd..3fed57549 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -24,6 +24,11 @@ PrintConfigDef::PrintConfigDef() opt->values.push_back(Pointf(0,200)); def->default_value = opt; } + def = this->add("has_heatbed", coBool); + def->label = "Has heated bed"; + def->tooltip = "Unselecting this will suppress automatic generation of bed heating gcode."; + def->cli = "has_heatbed!"; + def->default_value = new ConfigOptionBool(true); def = this->add("bed_temperature", coInt); def->label = "Other layers"; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 442af51c2..5e62bf278 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -318,6 +318,7 @@ class PrintConfig : public GCodeConfig public: ConfigOptionBool avoid_crossing_perimeters; ConfigOptionPoints bed_shape; + ConfigOptionBool has_heatbed; ConfigOptionInt bed_temperature; ConfigOptionFloat bridge_acceleration; ConfigOptionInt bridge_fan_speed; @@ -374,6 +375,7 @@ class PrintConfig : public GCodeConfig virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(avoid_crossing_perimeters); OPT_PTR(bed_shape); + OPT_PTR(has_heatbed); OPT_PTR(bed_temperature); OPT_PTR(bridge_acceleration); OPT_PTR(bridge_fan_speed); From 7f2c1478eb0ddbdf16f6909c8bbc83ef3a4ffc56 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Wed, 20 Jul 2016 18:33:16 -0500 Subject: [PATCH 2/2] Added tests to check the functionality of has_heatbed option. --- t/gcode.t | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/t/gcode.t b/t/gcode.t index ef2209a80..243acb24b 100644 --- a/t/gcode.t +++ b/t/gcode.t @@ -1,4 +1,4 @@ -use Test::More tests => 23; +use Test::More tests => 25; use strict; use warnings; @@ -215,4 +215,47 @@ use Slic3r::Test; ok !$spiral, 'spiral vase is correctly disabled on layers with multiple loops'; } +{ + # Test verifies that if has_heatbed is false, M190/M140 gcodes are not + # generated by default even if a bed temperature is set. + my $config = Slic3r::Config->new_from_defaults; + $config->set('has_heatbed', 0); + $config->set('first_layer_bed_temperature', 100); + $config->set('bed_temperature', 60); + + my $had_gcode = 0; + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if (($cmd eq 'M140' && exists $args->{S}) || + ($cmd eq 'M190' && exists $args->{S})) { + $had_gcode = 1; + } + }); + + ok !$had_gcode, 'M190/M140 codes are not generated if has_heatbed = 0'; +} + +{ + # Test verifies that if has_heatbed is true, M190/M140 gcodes are + # generated by default if a bed temperature is set. + my $config = Slic3r::Config->new_from_defaults; + $config->set('has_heatbed', 1); + $config->set('first_layer_bed_temperature', 100); + $config->set('bed_temperature', 60); + + my $had_gcode = 0; + my $print = Slic3r::Test::init_print('cube_with_hole', config => $config); + Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { + my ($self, $cmd, $args, $info) = @_; + + if (($cmd eq 'M140' && exists $args->{S}) || + ($cmd eq 'M190' && exists $args->{S})) { + $had_gcode = 1; + } + }); + + ok $had_gcode, 'M190/M140 codes are generated if has_heatbed = 1'; +} __END__