mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 18:42:24 +00:00
New --start-gcode and --end-gcode options. #12
This commit is contained in:
@@ -38,6 +38,7 @@ our $z_offset = 0;
|
||||
# filament options
|
||||
our $filament_diameter = 3; # mm
|
||||
our $filament_packing_density = 1;
|
||||
our $temperature = 200;
|
||||
|
||||
# speed options
|
||||
our $print_feed_rate = 60; # mm/sec
|
||||
@@ -59,7 +60,12 @@ our $bridge_overlap = 3; # mm
|
||||
our $fill_type = 'rectilinear';
|
||||
our $fill_density = 0.4; # 1 = 100%
|
||||
our $fill_angle = 0;
|
||||
our $temperature = 200;
|
||||
our $start_gcode = "G28 ; home all axes";
|
||||
our $end_gcode = <<"END";
|
||||
M104 S0 ; turn off temperature
|
||||
G28 X0 ; home X axis
|
||||
M84 ; disable motors
|
||||
END
|
||||
|
||||
# retraction options
|
||||
our $retract_length = 1; # mm
|
||||
|
||||
@@ -86,6 +86,18 @@ our $Options = {
|
||||
label => 'Fill angle (°)',
|
||||
type => 'i',
|
||||
},
|
||||
'start_gcode' => {
|
||||
label => 'Start GCODE',
|
||||
type => 's',
|
||||
serialize => sub { join '\n', split /\R+/, $_[0] },
|
||||
deserialize => sub { join "\n", split /\\n/, $_[0] },
|
||||
},
|
||||
'end_gcode' => {
|
||||
label => 'End GCODE',
|
||||
type => 's',
|
||||
serialize => sub { join '\n', split /\R+/, $_[0] },
|
||||
deserialize => sub { join "\n", split /\\n/, $_[0] },
|
||||
},
|
||||
|
||||
# retraction options
|
||||
'retract_length' => {
|
||||
@@ -179,6 +191,25 @@ sub load {
|
||||
close $fh;
|
||||
}
|
||||
|
||||
sub validate_cli {
|
||||
my $class = shift;
|
||||
my ($opt) = @_;
|
||||
|
||||
for (qw(start end)) {
|
||||
if (defined $opt->{$_."_gcode"}) {
|
||||
if ($opt->{$_."_gcode"} eq "") {
|
||||
set($_."_gcode", "");
|
||||
} else {
|
||||
die "Invalid value for --${_}-gcode: file does not exist"
|
||||
if !-e $opt->{$_."_gcode"};
|
||||
open my $fh, "<", $opt->{$_."_gcode"};
|
||||
set($_."_gcode", do { local $/; <$fh> });
|
||||
close $fh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub validate {
|
||||
my $class = shift;
|
||||
|
||||
|
||||
@@ -325,9 +325,8 @@ sub export_gcode {
|
||||
or die "Failed to open $file for writing\n";
|
||||
|
||||
# write start commands to file
|
||||
# TODO: this must be customizable by user
|
||||
print $fh "G28 ; home all axes\n";
|
||||
printf $fh "M104 S%d ; wait for temperature to be reached\n", $Slic3r::temperature;
|
||||
print $fh "$Slic3r::start_gcode\n";
|
||||
print $fh "G90 ; use absolute coordinates\n";
|
||||
print $fh "G21 ; set units to millimeters\n";
|
||||
if ($Slic3r::use_relative_e_distances) {
|
||||
@@ -375,10 +374,7 @@ sub export_gcode {
|
||||
}
|
||||
|
||||
# write end commands to file
|
||||
# TODO: this must be customizable by user
|
||||
print $fh "M104 S0 ; turn off temperature\n";
|
||||
print $fh "G28 X0 ; home X axis\n";
|
||||
print $fh "M84 ; disable motors\n";
|
||||
print $fh "$Slic3r::end_gcode\n";
|
||||
|
||||
# close our gcode file
|
||||
close $fh;
|
||||
|
||||
Reference in New Issue
Block a user