use strict;
-our @array = <DATA>;
+our @array;
+sub readdata () {
+ my $l = '';
+ while (<DATA>) {
+ chomp or die;
+ $l .= $_;
+ next if $l =~ s/\\\s*$//;
+ push @array, $l;
+ $l = '';
+ }
+}
+readdata();
our %c;
$c{$cv} = $v;
}
-defvar('extruderate',0.97200);
+defvar('extruderate',0.097200);
defvar('feedrate',540);
defvar('jerkfeedrate',7800);
defvar('retract',4.5);
foreach my $lno ($start..$end) {
$_ = $array[$lno];
if (!m/^\!/) {
- p($_);
+ pl($_);
next;
}
- p(";$_");
+ pl(";$_");
if (s/^\!draw\s+//) {
my @undefs = grep { !defined $c{$_} } qw(zprint zmove);
die "@undefs ?" if @undefs;
m/\,/ or die $!;
[ $`, $', !!$jerk ]; # '];
} @coords;
+ my $extrudepos=$c{restart};
pl("G92 E0");
pl("G1 F$c{movefeedrate} Z$c{zmove}");
pl("G1 ".coords_g($coords[0]));
pl("G1 Z$c{zprint}");
- pl("G1 F$c{restartfeedrate} E$c{restart}");
+ pl("G1 F$c{restartfeedrate} E".float_g($extrudepos));
my $lastfeedrate=-1;
- my $extrudepos=0;
foreach (my $ci=1; $ci<@coords; $ci++) {
my $g = "G1 ".coords_g($coords[$ci]);
my $wantfeedrate;
- if (!$coords[$ci][3]) {
+ if (!$coords[$ci][2]) {
$wantfeedrate=$c{feedrate};
my $dist = 0;
foreach my $xy (qw(0 1)) {
my $dxy = $coords[$ci][$xy] - $coords[$ci-1][$xy];
- $dist += $dxy + $dxy;
+ $dist += $dxy * $dxy;
}
$dist = sqrt($dist);
$extrudepos += $dist * $c{extruderate};
pl($g);
}
$extrudepos -= $c{retract};
- pl("G1 F$c{retractfeedrate} E$extrudepos");
+ pl("G1 F$c{retractfeedrate} E".float_g($extrudepos));
pl("G1 F$c{movefeedrate} Z$c{zmove}");
next;
} elsif (m/^\!(\w+)\=(\S+)$/) {
!draw 10,10 100,10
+!draw 68.498,79.498 \
+71.502,79.498 \
+71.502,82.502 \
+68.498,82.502 \
+68.498,79.588 \
+*67.899,78.899 \
+72.101,78.899 \
+72.101,83.101 \
+67.899,83.101 \
+67.899,78.989 \
+*67.300,78.300 \
+72.700,78.300 \
+72.700,83.700 \
+67.300,83.700 \
+67.300,78.390 \
G1 X10 Y10