[Asterisk-Users] FW: Matrix Orbital (usbl LCD or VFD) (oops,
wrong list I think)
TC
trclark at shaw.ca
Tue Jan 6 09:02:19 MST 2004
> > From: Kris Edwards [mailto:edwardskris at qwest.net]
> > Sent: Tuesday, January 06, 2004 3:38 AM
> > To: 'asterisk-dev at lists.digium.com'
> > Subject: Matrix Orbital (usbl LCD or VFD)
> >
> > This probably isn't practical for anyone other than home users, but I
> > would like to use a USB LCD display in my case to display things such
> > as:
if you grab the perl modules from citats site http://asterisk.gnuinter.net/
These scripts are used with MO VFD, to display call counts in the q usng the
manager interface
you can set another callback events & grab the caller id from a stateup
event on the device of interest
then write that to the LCD ...
then save this & include
---------------------------cut along dotted line
astq.pl------------------------------------------
#!/usr/bin/perl
#
# Example script to show how to use Asterisk::Manager
#
# Written by: James Golovich <james at gnuinter.net>
#
#
use lib './lib', '../lib';
use Asterisk::Manager;
use mo;
$|++;
my $astman = new Asterisk::Manager;
$astman->user('lcd');
$astman->secret('test');
$astman->host('localhost');
$astman->connect || die $astman->error . "\n";
$astman->setcallback('Leave', \&queue_callback);
$astman->setcallback('Join', \&queue_callback);
display_init ( );
display_clear ( );
display_write ( "User Count: " );
$astman->eventloop;
$astman->disconnect;
sub hangup_callback {
print STDERR "hangup callback\n";
}
sub default_callback {
my (%stuff) = @_;
foreach (keys %stuff) {
print STDERR "$_: ". $stuff{$_} . "\n";
}
print STDERR "\n";
}
sub queue_callback {
my (%stuff) = @_;
$cnt = 0;
foreach (keys %stuff) {
print STDERR "$_: ". $stuff{$_} . "\n";
if ($_ eq "Count") {
$cnt = $stuff{$_};
}
elsif ($_ eq "xCount") { #
$i=1;
}
}
print STDERR "I got $cnt \n";
display_clear ( );
display_write ( "User Count: $cnt" );
display_init_large_digit ( );
display_large_digit ( 16,3 );
}
---------------------------cut along dotted line
mo.pm------------------------------------------
#
# mo.pm
# you should set the $serial_port to the correct tty below.
# all cmds start with 254 decimal 0xFE
package mo;
use Exporter;
use POSIX;
use IO;
########################################################################
# editable section
#
$serial_port = "/dev/ttyS0"; # usually "/dev/ttyS0" or "/dev/ttyS1"
#
# end editable section
########################################################################
@ISA = qw ( Exporter );
@EXPORT = qw ( moInit moWrite moClear moClose
moPosition moBlinkOn moBlinkOff
moInitLargeDigit moLargeDigit
);
#
# moInit ( );
# opens the serial port in bi-directional mode and sends the commands to
# turn the ( display on for a vfd | backlight on for an lcd ) and clears
# the screen.
#
sub moInit
{
open ( DISPLAY, "+> $serial_port" ) || die "Couldn't open $_: $!";
$fd_disp = fileno ( DISPLAY );
$termios = POSIX::Termios->new ( );
$termios->getattr ( $fd_disp );
$termios->setispeed ( B19200 );
$termios->setospeed ( B19200 );
$cflag = $termios->getcflag ( );
$lflag = $termios->getlflag ( );
$oflag = $termios->getoflag ( );
$iflag = $termios->getiflag ( );
$iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
$oflag &= ~OPOST;
$lflag &= ~(ECHO|ECHONL|ICANON|ISIG);
$cflag &= ~(CSIZE|PARENB|HUPCL);
$cflag |= CS8|CLOCAL;
$termios->setcflag ( $cflag );
$termios->setlflag ( $lflag );
$termios->setoflag ( $oflag );
$termios->setiflag ( $iflag );
$termios->setattr ( $fd_disp, TCSANOW );
$clear = sprintf ( "%cX", 0xfe );
$noblink = sprintf ( "%cT", 0xfe );
$dim = sprintf ( "%cY%c", 0xfe, 0x03 );
$on = sprintf ( "%cB%c", 0xfe, 0x00 );
$repeat = sprintf ( "%c~%c", 0xfe, 0x00 );
print DISPLAY "$on$repeat$noblink$dim$clear";
}
#
# moWrite ( "hi there!" );
# prints the selected text to the display at the current cursor position.
#
sub moWrite
{
my ( $text ) = @_;
print DISPLAY "$text\n";
}
#
# moClear ( );
# clears the display
#
sub moClear
{
$clear = sprintf ( "%cX", 0xfe );
print DISPLAY "$clear\n";
}
#
# moClose ( );
# clears the display and turns ( it off for a vfd | the backlight off for
# an lcd )
#
sub moClose
{
$clear = sprintf ( "%cX", 0xfe );
$off = sprintf ( "%cF", 0xfe );
print DISPLAY "$clear\n$off\n";
close ( DISPLAY );
}
#
# moInitLargeDigit ( );
# init the display for large digits
#
sub moInitLargeDigit
{
$largedigits = sprintf ( "%cn", 0xfe );
print DISPLAY "$largedigits\n";
}
#
# moLargeDigit ( $x, $digit );
# writes large digit at column $x given.
#
sub moLargeDigit
{
my ( $x, $digit ) = @_;
$digitpos = sprintf "%c#%c%c", 0xfe, $x, $digit;
print DISPLAY "$digitpos";
}
#
# moPosition ( $x, $y );
# homes the cursor to the x and y coordinates given.
#
sub moPosition
{
my ( $x, $y ) = @_;
$pos = sprintf "%cG%c%c", 0xfe, $y, $x;
print DISPLAY "$pos";
}
# moBlinkOn ( );
# turns the cursor blinking on.
#
sub moBlinkOn {
$cmd = sprintf "%cS", 0xfe;
print DISPLAY "$cmd\n";
}
#
# moBlinkOff ( );
# turns the cursor blinking off.
#
sub moBlinkOff {
$cmd = sprintf "%cT", 0xfe;
print DISPLAY "$cmd\n";
}
More information about the asterisk-users
mailing list