Message Ticker

Linux support for Soundgraph iMON USB IR/VFD modules used in Ahanix, Silverstone, Uneed, Accent and other cases.

Moderator: Venky

Post Reply
Scorpuk
Posts: 30
Joined: Fri Jul 07, 2006 3:24 am
Location: Scotland

Message Ticker

Post by Scorpuk » Mon Feb 05, 2007 3:28 am

Another perl program I am working on.

This will display a 16 character message which should scroll from the right to the left and dissapear off the end of the screen.

The only part I am not 100% about is the delay in showing each part of the message. This is because I am not infront of my box and can't see how fast / slow its moving, but you can tinker around with the value until you get what you like.


Code: Select all

#!/usr/bin/perl
use Time::HiRes qw( sleep ); 

# Please keep message to 16 characters or less (Only works with the top line)

$message="Good Morning";

@messages = ("                ","               ","              ","             ","            ","           ","          ","         ","        ","       ","      ","     ","    ","   ","  "," ","");
$loop = 1;
$messlen = length($message);
$mess = $messlen - 1;
$dimmesslen = $messlen - 1;

# Creating the text image as it dissapears off the left side
while ($loop <= $mess)
{
	$messout[$loop] = substr($message,$loop,$dimmesslen);
	$loop++;
	$dimmesslen--;
}

$loop = 1; # Reset loop counter

# Bring the text in
while ($loop <= $messlen)
{
	$messages[$loop] = $messages[$loop] . substr($message,0,$loop);
	$loop++;
}

# If message is less than 16 characters we need to bring the message all the way to the left
if ($messlen < 16)
{
	$loop = $messlen + 1;
	while ($loop <= 16)
	{
		$messages[$loop] = $messages[$loop] . $message;
		$loop++;
	}
}

# Add in the fade out message
$togo = $loop + $messlen - 2;
$position = 1;
while ($loop <= $togo)
{
	$messages[$loop] = $messout[$position];
	$loop++;
	$position++;
}



$arraycount = 16 + $messlen; # Total number of messages stored in the array


# Display message
while ()
{
	system "echo -n \"\" > /dev/lcd0"; # Clear the display
	sleep( 0.25 ); 
	for ($count = 1; $count < $arraycount; $count++)
	{
		sleep( 0.25 ); 
		system "echo -n \"$messages[$count]\" > /dev/lcd0"; 
	}
}

I'll update as I play with it the next time I'm at my box. :-)

Post Reply