[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-developers] Solution for Scrolling text on the LCD...
- Subject: [cobalt-developers] Solution for Scrolling text on the LCD...
- From: "Josh McAllister" <josh.mcallister@xxxxxxx>
- Date: Sun Mar 3 08:47:14 2002
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
I've seen the question a few times, but have missed any answers that might
be floating around. So I put together the following little script... could
be a little smoother, but it works. If someone has a better solution, PLEASE
share!
If this is the wrong place to share, or look for nuggets like this, please
let me know where they should be directed.
Thanks,
Josh McAllister
PS. Any programming examples for manipulating the LCD or buttons would be
much appreciated.
#!/usr/bin/perl
use Getopt::Std;
#Options are set on the command line. ie. -a"....." -d.25
#Set default options.
#String to prepend
$Options{p} = '';
#String to append
$Options{a} = ' ';
#Delay in seconds
$Options{d} = .33;
#Line(s) to exclude from scrolling
$Options{x} = '';
#Iterations before quiting (0 = continuous)
$Options{i} = '0';
getopt('padxi',\%Options);
#Eliminating " " list seperator make our life easier
$"="";
@line1 = MakeArray($Options{p}.$ARGV[0].$Options{a});
@line2 = MakeArray($Options{p}.$ARGV[1].$Options{a});
while (1) {
$i++;
if ($Options{x} !~ "1") {
push (@line1,shift (@line1));
}
if ($Options{x} !~ "2") {
push (@line2,shift (@line2));
}
`/sbin/lcd-write "@line1" "@line2"`;
select(undef, undef, undef, $Options{d});
if ($i == int($Options{i})) { exit }
}
sub MakeArray {
my $line = "@_";
my @array;
for ( 1 ; $line =~ /(.)/g; push (@array,$1)) {}
return @array
}