Alternative clock

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

Alternative clock

Post by Scorpuk » Thu Dec 28, 2006 1:38 pm

Thought you might like this. Ensure you have perl installed. :wink:


Create a file, called time.pl:

Code: Select all

#!/usr/bin/perl
while ()
{
	system "date >> /dev/lcd0";
}
Now at the terminal type this:

Code: Select all

perl time.pl
press ctrl+c to exit.

You could add it as a cron job to run when the computer starts. It should only use approx 0.8% cpu resources. 8)

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

Post by Scorpuk » Sun Dec 31, 2006 7:39 am

Starting to learn perl and have updated the clock a little...

Code: Select all

!/usr/bin/perl


while ()
{

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$mon=$mon+1;
$year=$year+1900;

use Switch;

#
#   To set the name of the day
#
switch ($wday)
{
	case 0	{ $nod="Sun" }	
	case 1	{ $nod="Mon" }
	case 2	{ $nod="Tue" }
	case 3	{ $nod="Wed" }
	case 4	{ $nod="Thu" }
	case 5	{ $nod="Fri" }
	case 6	{ $nod="Sat" }
}

#
#   To set the name of the month
#
switch ($mon)
{
	case 1	{ $nom="Jan" }	
	case 2	{ $nom="Feb" }
	case 3	{ $nom="Mar" }
	case 4	{ $nom="Apr" }
	case 5	{ $nom="May" }
	case 6	{ $nom="Jun" }
	case 7	{ $nom="Jul" }
	case 8	{ $nom="Aug" }
	case 9	{ $nom="Sep" }
	case 10	{ $nom="Oct" }
	case 11	{ $nom="Nov" }
	case 12	{ $nom="Dec" }
}

#
#   Add a leading 0 to seconds. 
#
switch ($sec)
{
	case [0..9]	{ $secs="0" . $sec }
	else		{ $secs=$sec }
}
#
#   Add a leading 0 to minutes. 
#
switch ($min)
{
	case [0..9]	{ $mins="0" . $min }
	else		{ $mins=$min }
}
#
#   Add a leading 0 to hours. 
#
switch ($hour)
{
	case [0..9]	{ $hours="0" . $hour }
	else		{ $hours=$hour }
}

#
#   Add a space when month is 1 to 9. 
#
switch ($mday)
{
	case [0..9]	{ system "echo -n \"Date: $nod $mday $nom Time: $hours:$mins:$secs\" > /dev/lcd0"; }
	else		{ system "echo -n \"Date: $nod $mday $nom\Time: $hours:$mins:$secs\" > /dev/lcd0"; }
}

}

Edit: typo on variable name (mins)
Edit: again typos. This time on echo. $mon instead of $mday. lol
Edit: add a space when month is 1 to 9.
Edit: This clock will take up more cpu resources than the 1st. My system is currently running at 2% for it. :shock:
Edit: Added the option -n to echo to remove the cursor from the end of the text. Huzzah 8)

Post Reply