
Device::USB::MissileLauncher::RocketBaby - interface to toy missile launchers from Dream Cheeky

use Device::USB::MissileLauncher::RocketBaby;
my $ml = Device::USB::MissileLauncher::RocketBaby->new;
while (<>) {
/j/ && $ml->do("down");
/k/ && $ml->do("up");
/h/ && $ml->do("left");
/l/ && $ml->do("right");
/f/ && $ml->do("fire");
/s/ && $ml->do("stop");
}

This provides a basic interface to the toy USB missile launchers produced by Dream Cheeky. The device name of USB protocol is "Rocket Baby Rocket Baby".

Creates an instance.
send command string to the launcher. commands are following:
left right up down fire stop
returns whether the command is executable.

cando("fire") returns false at only moment of launching. You can launch rockets one by one like this:
use Time::Hires qw( sleep );
sub fire1
{
my $ml = shift;
if ($ml->cando("fire")) {
$ml->do('fire');
eval {
local $SIG{ALRM} = sub { die "alarm" };
alarm 5;
while ($ml->cando("fire")) {
sleep 0.15;
}
sleep 0.5;
alarm 0;
}
$ml->do("stop");
}
}
You might have to adjust sleep figures.

http://www.dreamcheeky.com/product/missile-launcher.php

Abe Masahiro, <pen@thcomp.org>

Copyright (C) 2007 by Abe Masahiro
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.