From d8a743d1779fbd7a5cd85abf2321eedf916c6614 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 24 Apr 2018 18:35:29 -0500 Subject: [PATCH 1/4] If M190, M109, M104, or M140 commands are not present in end gcode, append commands to shut off all hotends and the bed (same as start gcode). --- lib/Slic3r/Print/GCode.pm | 20 ++++++++++++++++++++ xs/src/libslic3r/PrintConfig.cpp | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index f3e423fba..39eeafa9f 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -153,6 +153,10 @@ sub export { foreach my $start_gcode (@{ $self->config->start_filament_gcode }) { # process filament gcode in order $include_start_extruder_temp = $include_start_extruder_temp && ($start_gcode !~ /M(?:109|104)/i); } + my $include_end_extruder_temp = $self->config->end_gcode !~ /M(?:109|104)/i; + foreach my $end_gcode (@{ $self->config->end_filament_gcode }) { # process filament gcode in order + $include_end_extruder_temp = $include_end_extruder_temp && ($end_gcode !~ /M(?:109|104)/i); + } $self->_print_first_layer_temperature(0) if $include_start_extruder_temp; printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->start_gcode)); @@ -301,6 +305,12 @@ sub export { printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($end_gcode)); } printf $fh "%s\n", Slic3r::ConditionalGCode::apply_math($gcodegen->placeholder_parser->process($self->config->end_gcode)); + + $self->_print_off_temperature(0) + if $include_end_extruder_temp; + print $fh $self->_gcodegen->writer->set_bed_temperature(0, 0) + if $include_end_extruder_temp; + print $fh $gcodegen->writer->update_progress($gcodegen->layer_count, $gcodegen->layer_count, 1); # 100% print $fh $gcodegen->writer->postamble; @@ -356,6 +366,16 @@ sub _print_first_layer_temperature { } } +sub _print_off_temperature { + my ($self, $wait) = @_; + + for my $t (@{$self->print->extruders}) { + printf {$self->fh} $self->_gcodegen->writer->set_temperature(0, $wait, $t) + } +} + + + # Called per object's layer. # First a $gcode string is collected, # then filtered and finally written to a file $fh. diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index aeb240792..0287c12bf 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -221,7 +221,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("end_gcode", coString); def->label = "End G-code"; - def->tooltip = "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings."; + def->tooltip = "This end procedure is inserted at the end of the output file. Note that you can use placeholder variables for all Slic3r settings. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions."; def->cli = "end-gcode=s"; def->multiline = true; def->full_width = true; @@ -230,7 +230,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("end_filament_gcode", coStrings); def->label = "End G-code"; - def->tooltip = "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order."; + def->tooltip = "This end procedure is inserted at the end of the output file, before the printer end gcode. Note that you can use placeholder variables for all Slic3r settings. If you have multiple extruders, the gcode is processed in extruder order. If Slic3r detects M104, M109, M140 or M190 in your custom codes, such commands will not be prepended automatically so you're free to customize the order of heating commands and other custom actions."; def->cli = "end-filament-gcode=s@"; def->multiline = true; def->full_width = true; From 0ea8853f6f91d791a724b0d9334d7685083d8e43 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 24 Apr 2018 18:49:14 -0500 Subject: [PATCH 2/4] Build Experiment - see if build completes without sudo: required. (#4051) --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 864d76b3c..f76e6822f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,6 @@ notifications: on_success: change on_failure: always use_notice: true -sudo: required dist: trusty env: matrix: From 44dc572bf70eb337f027c469fda01526bf8241e0 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 24 Apr 2018 19:00:25 -0500 Subject: [PATCH 3/4] Use heatbed config option to determine whether to auto-include M140 S0 at end. --- lib/Slic3r/Print/GCode.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 39eeafa9f..c98880496 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -308,8 +308,10 @@ sub export { $self->_print_off_temperature(0) if $include_end_extruder_temp; - print $fh $self->_gcodegen->writer->set_bed_temperature(0, 0) - if $include_end_extruder_temp; + # set bed temperature + if ($self->config->has_heatbed && $self->config->start_gcode !~ /M(?:190|140)/i) { + printf $fh $gcodegen->writer->set_bed_temperature(0, 0); + } print $fh $gcodegen->writer->update_progress($gcodegen->layer_count, $gcodegen->layer_count, 1); # 100% print $fh $gcodegen->writer->postamble; From bc145c5c732374d3c53bc7696c35a45fd0723f1e Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Tue, 24 Apr 2018 19:03:56 -0500 Subject: [PATCH 4/4] Use end_gcode, not start_code for determining to append bed cool command. --- lib/Slic3r/Print/GCode.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index c98880496..514d9f785 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -309,7 +309,7 @@ sub export { $self->_print_off_temperature(0) if $include_end_extruder_temp; # set bed temperature - if ($self->config->has_heatbed && $self->config->start_gcode !~ /M(?:190|140)/i) { + if (($self->config->has_heatbed) && $self->config->end_gcode !~ /M(?:190|140)/i) { printf $fh $gcodegen->writer->set_bed_temperature(0, 0); }