mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-30 17:22:02 +08:00
Long retract support in marlin and repetier for FW retract. (#4108)
* For reprap (really Marlin) or Repetier flavors and a toolchange retract, produce G10 S1 instead of G10. Also refactored comments (were getting eaten by fw retract) * Fixed tests to check for correct retract gcode output. * Better reference to scalar. * Added config checks for if fw tool retracts are in place and firmware is repetier/marlin, disable the advanced option. * Disable z lift if firmware retraction is enabled. * With gcode comments on, indicates which extruder Slic3r thinks it is retracting/unretracting.
This commit is contained in:
parent
86c3600684
commit
19ea7a596a
@ -1579,15 +1579,38 @@ sub _update {
|
||||
|
||||
# when using firmware retraction, firmware decides retraction length
|
||||
$self->get_field('retract_length', $i)->toggle(!$config->use_firmware_retraction);
|
||||
if ($config->use_firmware_retraction &&
|
||||
($config->gcode_flavor eq 'reprap' || $config->gcode_flavor eq 'repetier') &&
|
||||
($config->get_at('retract_length_toolchange', $i) > 0 || $config->get_at('retract_restart_extra_toolchange', $i) > 0)) {
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"Retract length for toolchange on extruder " . $i . " is not available when using the Firmware Retraction mode.\n"
|
||||
. "\nShall I disable it in order to enable Firmware Retraction?",
|
||||
'Firmware Retraction', wxICON_WARNING | wxYES | wxNO);
|
||||
|
||||
my $new_conf = Slic3r::Config->new;
|
||||
if ($dialog->ShowModal() == wxID_YES) {
|
||||
my $retract_length_toolchange = $config->retract_length_toolchange;
|
||||
$retract_length_toolchange->[$i] = 0;
|
||||
$new_conf->set("retract_length_toolchange", $retract_length_toolchange);
|
||||
$new_conf->set("retract_restart_extra_toolchange", $retract_length_toolchange);
|
||||
} else {
|
||||
$new_conf->set("use_firmware_retraction", 0);
|
||||
}
|
||||
$self->_load_config($new_conf);
|
||||
}
|
||||
|
||||
# user can customize travel length if we have retraction length or we're using
|
||||
# firmware retraction
|
||||
$self->get_field('retract_before_travel', $i)->toggle($have_retract_length || $config->use_firmware_retraction);
|
||||
|
||||
# user can customize other retraction options if retraction is enabled
|
||||
# Firmware retract has Z lift built in.
|
||||
my $retraction = ($have_retract_length || $config->use_firmware_retraction);
|
||||
$self->get_field($_, $i)->toggle($retraction && !$config->use_firmware_retraction)
|
||||
for qw(retract_lift);
|
||||
|
||||
$self->get_field($_, $i)->toggle($retraction)
|
||||
for qw(retract_lift retract_layer_change);
|
||||
for qw(retract_layer_change);
|
||||
|
||||
# retract lift above/below only applies if using retract lift
|
||||
$self->get_field($_, $i)->toggle($retraction && $config->get_at('retract_lift', $i) > 0)
|
||||
@ -1617,12 +1640,32 @@ sub _update {
|
||||
}
|
||||
$self->_load_config($new_conf);
|
||||
}
|
||||
|
||||
$self->get_field('retract_length_toolchange', $i)->toggle($have_multiple_extruders);
|
||||
|
||||
if ($config->use_firmware_retraction && $config->get_at('retract_lift', $i) > 0) {
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"The Z Lift option is not available when using the Firmware Retraction mode.\n"
|
||||
. "\nShall I disable it in order to enable Firmware Retraction?",
|
||||
'Firmware Retraction', wxICON_WARNING | wxYES | wxNO);
|
||||
|
||||
my $new_conf = Slic3r::Config->new;
|
||||
if ($dialog->ShowModal() == wxID_YES) {
|
||||
my $wipe = $config->retract_lift;
|
||||
$wipe->[$i] = 0;
|
||||
$new_conf->set("retract_lift", $wipe);
|
||||
} else {
|
||||
$new_conf->set("use_firmware_retraction", 0);
|
||||
}
|
||||
$self->_load_config($new_conf);
|
||||
}
|
||||
|
||||
$self->get_field('retract_length_toolchange', $i)->toggle
|
||||
($have_multiple_extruders &&
|
||||
!($config->use_firmware_retraction && ($config->gcode_flavor eq 'reprap' || $config->gcode_flavor eq 'repetier')));
|
||||
|
||||
my $toolchange_retraction = $config->get_at('retract_length_toolchange', $i) > 0;
|
||||
$self->get_field('retract_restart_extra_toolchange', $i)->toggle
|
||||
($have_multiple_extruders && $toolchange_retraction);
|
||||
($have_multiple_extruders && $toolchange_retraction &&
|
||||
!($config->use_firmware_retraction && ($config->gcode_flavor eq 'reprap' || $config->gcode_flavor eq 'repetier')));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,13 @@ mkdir -p ${WD}/${APP}.AppDir/usr/lib
|
||||
for i in $(ls $srcfolder/bin); do
|
||||
install -v $srcfolder/bin/$i ${WD}/${APP}.AppDir/usr/lib
|
||||
done
|
||||
|
||||
# copy other libraries needed to /usr/lib because this is an AppImage build.
|
||||
for i in $(cat $WD/libpaths.appimage.txt | grep -v "^#" | awk -F# '{print $1}'); do
|
||||
install -v $i ${WD}/${APP}.AppDir/usr/lib
|
||||
done
|
||||
|
||||
|
||||
cp -R $srcfolder/local-lib ${WD}/${APP}.AppDir/usr/lib/local-lib
|
||||
|
||||
cat > $WD/${APP}.AppDir/AppRun << 'EOF'
|
||||
|
1
package/linux/libpaths.appimage.txt
Normal file
1
package/linux/libpaths.appimage.txt
Normal file
@ -0,0 +1 @@
|
||||
/usr/lib/x86_64-linux-gnu/libstdc++.so.6 # needed because of ancient distros and slic3r (and perl for perl reasons) needs modern c++.
|
@ -461,14 +461,18 @@ GCodeWriter::retract_for_toolchange()
|
||||
return this->_retract(
|
||||
this->_extruder->retract_length_toolchange(),
|
||||
this->_extruder->retract_restart_extra_toolchange(),
|
||||
"retract for toolchange"
|
||||
"retract for toolchange",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
std::string
|
||||
GCodeWriter::_retract(double length, double restart_extra, const std::string &comment)
|
||||
GCodeWriter::_retract(double length, double restart_extra, const std::string &comment, bool long_retract)
|
||||
{
|
||||
std::ostringstream gcode;
|
||||
std::ostringstream outcomment;
|
||||
|
||||
outcomment << comment;
|
||||
|
||||
/* If firmware retraction is enabled, we use a fake value of 1
|
||||
since we ignore the actual configured retract_length which
|
||||
@ -485,17 +489,20 @@ GCodeWriter::_retract(double length, double restart_extra, const std::string &co
|
||||
|
||||
double dE = this->_extruder->retract(length, restart_extra);
|
||||
if (dE != 0) {
|
||||
outcomment << " extruder " << this->_extruder->id;
|
||||
if (this->config.use_firmware_retraction) {
|
||||
if (FLAVOR_IS(gcfMachinekit))
|
||||
gcode << "G22 ; retract\n";
|
||||
gcode << "G22";
|
||||
else if ((FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfRepetier)) && long_retract)
|
||||
gcode << "G10 S1";
|
||||
else
|
||||
gcode << "G10 ; retract\n";
|
||||
gcode << "G10";
|
||||
} else {
|
||||
gcode << "G1 " << this->_extrusion_axis << E_NUM(this->_extruder->E)
|
||||
<< " F" << this->_extruder->retract_speed_mm_min;
|
||||
COMMENT(comment);
|
||||
gcode << "\n";
|
||||
}
|
||||
COMMENT(outcomment.str());
|
||||
gcode << "\n";
|
||||
}
|
||||
|
||||
if (FLAVOR_IS(gcfMakerWare))
|
||||
@ -516,15 +523,17 @@ GCodeWriter::unretract()
|
||||
if (dE != 0) {
|
||||
if (this->config.use_firmware_retraction) {
|
||||
if (FLAVOR_IS(gcfMachinekit))
|
||||
gcode << "G23 ; unretract\n";
|
||||
gcode << "G23";
|
||||
else
|
||||
gcode << "G11 ; unretract\n";
|
||||
gcode << "G11";
|
||||
if (this->config.gcode_comments) gcode << " ; unretract extruder " << this->_extruder->id;
|
||||
gcode << "\n";
|
||||
gcode << this->reset_e();
|
||||
} else {
|
||||
// use G1 instead of G0 because G0 will blend the restart with the previous travel move
|
||||
gcode << "G1 " << this->_extrusion_axis << E_NUM(this->_extruder->E)
|
||||
<< " F" << this->_extruder->retract_speed_mm_min;
|
||||
if (this->config.gcode_comments) gcode << " ; unretract";
|
||||
if (this->config.gcode_comments) gcode << " ; unretract extruder " << this->_extruder->id;
|
||||
gcode << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
Pointf3 _pos;
|
||||
|
||||
std::string _travel_to_z(double z, const std::string &comment);
|
||||
std::string _retract(double length, double restart_extra, const std::string &comment);
|
||||
std::string _retract(double length, double restart_extra, const std::string &comment, bool long_retract = false);
|
||||
};
|
||||
|
||||
} /* namespace Slic3r */
|
||||
|
@ -4,7 +4,7 @@ use strict;
|
||||
use warnings;
|
||||
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 2;
|
||||
use Test::More tests => 5;
|
||||
|
||||
{
|
||||
my $gcodegen = Slic3r::GCode->new;
|
||||
@ -14,4 +14,47 @@ use Test::More tests => 2;
|
||||
is_deeply $gcodegen->origin->pp, [15,5], 'origin returns reference to point';
|
||||
}
|
||||
|
||||
{
|
||||
my $config = Slic3r::Config::Static::new_FullPrintConfig;
|
||||
my $gcodegen = Slic3r::GCode->new;
|
||||
$config->set('use_firmware_retraction', 1);
|
||||
$config->set('gcode_flavor', "reprap");
|
||||
$config->set('gcode_comments', 1);
|
||||
$gcodegen->apply_print_config($config);
|
||||
$gcodegen->writer->set_extruders([0]);
|
||||
$gcodegen->writer->set_extruder(0);
|
||||
my @output = split(/\n/, $gcodegen->retract(1));
|
||||
is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw marlin retract';
|
||||
}
|
||||
|
||||
{
|
||||
my $config = Slic3r::Config::Static::new_FullPrintConfig;
|
||||
$config->set('use_firmware_retraction', 1);
|
||||
$config->set('gcode_flavor', "repetier");
|
||||
$config->set('gcode_comments', 1);
|
||||
|
||||
my $gcodegen = Slic3r::GCode->new;
|
||||
$gcodegen->apply_print_config($config);
|
||||
$gcodegen->writer->set_extruders([0]);
|
||||
$gcodegen->writer->set_extruder(0);
|
||||
my @output = split(/\n/, $gcodegen->retract(1));
|
||||
is $output[0], "G10 S1 ; retract for toolchange extruder 0", 'Produces long retract for fw repetier retract';
|
||||
|
||||
}
|
||||
{
|
||||
my $config = Slic3r::Config::Static::new_FullPrintConfig;
|
||||
$config->set('gcode_flavor', "smoothie");
|
||||
$config->set('use_firmware_retraction', 1);
|
||||
$config->set('gcode_comments', 1);
|
||||
|
||||
my $gcodegen = Slic3r::GCode->new;
|
||||
$gcodegen->apply_print_config($config);
|
||||
|
||||
$gcodegen->writer->set_extruders([0]);
|
||||
$gcodegen->writer->set_extruder(0);
|
||||
my @output = split(/\n/, $gcodegen->retract(1));
|
||||
ok($output[0] eq "G10 ; retract for toolchange extruder 0", 'Produces regular retract for flavors that are not Marlin or Repetier');
|
||||
|
||||
}
|
||||
|
||||
__END__
|
||||
|
Loading…
x
Reference in New Issue
Block a user