Device-Firmata

 view release on metacpan or  search on metacpan

examples/example_stepper.pl  view on Meta::CPAN

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
                my $lastStep = $context->{progStep};
                $nextStep = ($lastStep == scalar(@stepperProgram) - 1) ? 0 : $lastStep + 1;
        }
         
        my @nextProg = @{$stepperProgram[$nextStep]};
 
        $context->{progStep} = $nextStep;
        $device->stepper_step(0,$nextProg[0],$nextProg[1],$nextProg[2]);
}
 
sub updatePosition {
        my ($context) = @_;
 
        my @stepperProgram = @{$context->{program}};
        my $lastStep = $context->{progStep};
        my @lastProg = @{$stepperProgram[$lastStep]};
 
        if ($lastProg[0] > 0) {
                $context->{position} -= $lastProg[1];
        } else {
                $context->{position} += $lastProg[1];



( run in 1.110 second using v1.01-cache-2.11-cpan-49f99fa48dc )