Refactoring: make 'retracted' an attribute of the Extruder object
This commit is contained in:
parent
97c3756034
commit
075213c731
3 changed files with 12 additions and 8 deletions
|
@ -10,6 +10,7 @@ use constant OPTIONS => [qw(
|
|||
)];
|
||||
has $_ => (is => 'ro', required => 1) for @{&OPTIONS};
|
||||
|
||||
has 'retracted' => (is => 'rw', default => sub {0} );
|
||||
has 'e_per_mm3' => (is => 'lazy');
|
||||
has 'retract_speed_mm_min' => (is => 'lazy');
|
||||
has '_mm3_per_mm_cache' => (is => 'ro', default => sub {{}});
|
||||
|
|
|
@ -14,7 +14,6 @@ has 'extruder_idx' => (is => 'rw', default => sub {0});
|
|||
has 'extrusion_distance' => (is => 'rw', default => sub {0} );
|
||||
has 'elapsed_time' => (is => 'rw', default => sub {0} ); # seconds
|
||||
has 'total_extrusion_length' => (is => 'rw', default => sub {0} );
|
||||
has 'retracted' => (is => 'rw', default => sub {1} ); # this spits out some plastic at start
|
||||
has 'lifted' => (is => 'rw', default => sub {0} );
|
||||
has 'last_pos' => (is => 'rw', default => sub { Slic3r::Point->new(0,0) } );
|
||||
has 'last_speed' => (is => 'rw', default => sub {""});
|
||||
|
@ -150,7 +149,7 @@ sub extrude_path {
|
|||
if !points_coincide($self->last_pos, $path->points->[0]);
|
||||
|
||||
# compensate retraction
|
||||
$gcode .= $self->unretract if $self->retracted;
|
||||
$gcode .= $self->unretract if $self->extruder->retracted;
|
||||
|
||||
my $area; # mm^3 of extrudate per mm of tool movement
|
||||
if ($path->role == EXTR_ROLE_BRIDGE) {
|
||||
|
@ -198,7 +197,7 @@ sub retract {
|
|||
my %params = @_;
|
||||
|
||||
return "" unless $self->extruder->retract_length > 0
|
||||
&& !$self->retracted;
|
||||
&& !$self->extruder->retracted;
|
||||
|
||||
# prepare moves
|
||||
$self->speed('retract');
|
||||
|
@ -232,7 +231,7 @@ sub retract {
|
|||
$gcode .= $self->G1(@$lift);
|
||||
}
|
||||
}
|
||||
$self->retracted(1);
|
||||
$self->extruder->retracted($self->extruder->retract_length + $self->extruder->retract_restart_extra);
|
||||
$self->lifted($self->extruder->retract_lift) if $lift;
|
||||
|
||||
# reset extrusion distance during retracts
|
||||
|
@ -244,7 +243,7 @@ sub retract {
|
|||
|
||||
sub unretract {
|
||||
my $self = shift;
|
||||
$self->retracted(0);
|
||||
|
||||
my $gcode = "";
|
||||
|
||||
if ($self->lifted) {
|
||||
|
@ -253,8 +252,8 @@ sub unretract {
|
|||
}
|
||||
|
||||
$self->speed('retract');
|
||||
$gcode .= $self->G0(undef, undef, ($self->extruder->retract_length + $self->extruder->retract_restart_extra),
|
||||
"compensate retraction");
|
||||
$gcode .= $self->G0(undef, undef, $self->extruder->retracted, "compensate retraction");
|
||||
$self->extruder->retracted(0);
|
||||
|
||||
return $gcode;
|
||||
}
|
||||
|
@ -348,7 +347,7 @@ sub _Gx {
|
|||
my $speed_f = $speed eq 'retract'
|
||||
? ($self->extruder->retract_speed_mm_min)
|
||||
: $self->speeds->{$speed};
|
||||
if ($e && $self->layer->id == 0 && $comment !~ /retract/) {
|
||||
if ($e && $self->layer && $self->layer->id == 0 && $comment !~ /retract/) {
|
||||
$speed_f = $Slic3r::Config->first_layer_speed =~ /^(\d+(?:\.\d+)?)%$/
|
||||
? ($speed_f * $1/100)
|
||||
: $Slic3r::Config->first_layer_speed * 60;
|
||||
|
|
|
@ -569,6 +569,10 @@ sub write_gcode {
|
|||
print $fh $gcodegen->set_tool(0) if @$Slic3r::extruders > 1;
|
||||
print $fh $gcodegen->set_fan(0, 1) if $Slic3r::Config->cooling && $Slic3r::Config->disable_fan_first_layers;
|
||||
|
||||
# this spits out some platic at start from the first extruder
|
||||
# (TODO: make this consistent in multi-head setups)
|
||||
$gcodegen->retract;
|
||||
|
||||
# write start commands to file
|
||||
printf $fh $gcodegen->set_bed_temperature($Slic3r::Config->first_layer_bed_temperature, 1),
|
||||
if $Slic3r::Config->first_layer_bed_temperature && $Slic3r::Config->start_gcode !~ /M190/i;
|
||||
|
|
Loading…
Reference in a new issue