|
sub new {
my ( $class ) = @_ ;
my $self = {};
$self ->{STARTX} = 50;
$self ->{STARTY} = 50;
$self ->{STARTZ} = 15.0;
bless $self , $class ;
return $self ;
}
sub start_gcode {
my ( $self ) = @_ ;
my $x = $self ->{STARTX};
my $y = $self ->{STARTY};
my $z = $self ->{STARTZ};
my @gcode = (
'T0' ,
'G21' ,
'G90' ,
'G28 X0 Y0' ,
'G28 Z' ,
"G1 Z$z F9000" ,
"G1 X$x Y$y" ,
"G92 X0 Y0 Z0 E0" ,
"G91" ,
);
return \ @gcode ;
}
sub waggle {
my ( $self , $directions , $distance , $iterations ) = @_ ;
my @gcode = ();
for ( my $i = 0; $i < $iterations ; $i ++) {
foreach my $direction (1, -1) {
my $moves = {
'X' => 0,
'Y' => 0,
'Z' => 0,
};
foreach my $dir ( @$directions ) {
$moves ->{ $dir } = $direction * $distance ;
}
my $line = 'G1' ;
foreach my $temp ( sort keys %$moves ) {
$line .= sprintf ( " %s%.2f" , $temp , $moves ->{ $temp });
}
push @gcode , $line ;
}
}
return \ @gcode ;
}
1;
|