diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index db9e35b9e..92590b71d 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -860,7 +860,7 @@ END }, 'bridge_fan_speed' => { label => 'Bridges fan speed', - tooltip => 'This fan speed is enforced during all bridges.', + tooltip => 'This fan speed is enforced during all bridges and overhangs.', sidetext => '%', cli => 'bridge-fan-speed=i', type => 'i', diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 4dd4587d6..14e6521f7 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -590,7 +590,7 @@ sub _Gx { $gcode .= sprintf " ; %s", $comment if $comment && $self->config->gcode_comments; if ($append_bridge_off) { - $gcode .= "\n;_BRIDGE_FAN_END"; + $gcode = ";_BRIDGE_FAN_END\n$gcode"; } return "$gcode\n"; } diff --git a/t/perimeters.t b/t/perimeters.t index 9f3457cc2..51c1aad10 100644 --- a/t/perimeters.t +++ b/t/perimeters.t @@ -17,8 +17,8 @@ use Slic3r::Test; $config->set('perimeters', 3); $config->set('top_solid_layers', 0); $config->set('bottom_solid_layers', 0); - $config->set('cooling', 0); # to prevent speeds to be altered - $config->set('first_layer_speed', '100%'); # to prevent speeds to be altered + $config->set('cooling', 0); # to prevent speeds from being altered + $config->set('first_layer_speed', '100%'); # to prevent speeds from being altered { my $print = Slic3r::Test::init_print('overhang', config => $config); @@ -45,18 +45,34 @@ use Slic3r::Test; $config->set('perimeter_speed', 77); $config->set('external_perimeter_speed', 66); $config->set('bridge_speed', 99); + $config->set('cooling', 1); + $config->set('fan_below_layer_time', 0); + $config->set('slowdown_below_layer_time', 0); + $config->set('bridge_fan_speed', 100); my $print = Slic3r::Test::init_print('overhang', config => $config); my %layer_speeds = (); # print Z => [ speeds ] + my $fan_speed = 0; Slic3r::GCode::Reader->new(gcode => Slic3r::Test::gcode($print))->parse(sub { my ($self, $cmd, $args, $info) = @_; + $fan_speed = 0 if $cmd eq 'M107'; + $fan_speed = $args->{S} if $cmd eq 'M106'; if ($info->{extruding} && $info->{dist_XY} > 0) { $layer_speeds{$self->Z} ||= {}; $layer_speeds{$self->Z}{my $feedrate = $args->{F} // $self->F} = 1; + fail 'wrong speed found' if $feedrate != $config->perimeter_speed*60 && $feedrate != $config->external_perimeter_speed*60 && $feedrate != $config->bridge_speed*60; + + if ($feedrate == $config->bridge_speed*60) { + fail 'printing overhang but fan is not enabled or running at wrong speed' + if $fan_speed != 255; + } else { + fail 'fan is running when not supposed to' + if $fan_speed > 0; + } } }); is scalar(grep { keys %$_ > 1 } values %layer_speeds), 1,