2001-09-21 21:08:10 +00:00
/*
* Matrix Orbital driver
*
* For the Matrix Orbital LCD* LKD* VFD* and VKD* displays
*
* September 16, 2001
*
* NOTE: GLK displays have a different driver.
*
*/
1999-12-09 23:15:14 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
2001-09-21 21:08:10 +00:00
#include <sys/types.h>
#include <sys/time.h>
1999-12-09 23:15:14 +00:00
#include <termios.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
2001-09-21 21:08:10 +00:00
#include <syslog.h>
2001-05-25 03:14:27 +00:00
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
1999-12-09 23:15:14 +00:00
#include "lcd.h"
#include "MtxOrb.h"
#include "drv_base.h"
2001-05-25 03:14:27 +00:00
#include "shared/debug.h"
#include "shared/str.h"
1999-12-09 23:15:14 +00:00
2001-09-21 21:08:10 +00:00
#define DEFAULT_CONTRAST 140
#define DEFAULT_DEVICE "/dev/lcd"
#define DEFAULT_SPEED B19200
#define DEFAULT_LINEWRAP 1
#define DEFAULT_AUTOSCROLL 1
#define DEFAULT_CURSORBLINK 0
#define IS_LCD_DISPLAY (MtxOrb_type == MTXORB_LCD)
#define IS_LKD_DISPLAY (MtxOrb_type == MTXORB_LKD)
#define IS_VFD_DISPLAY (MtxOrb_type == MTXORB_VFD)
#define IS_VKD_DISPLAY (MtxOrb_type == MTXORB_VKD)
#define NotEnoughArgs (i + 1 > argc)
// NOTE: This does not appear to make use of the
// hbar and vbar functions present in the LKD202-25.
// Why I do not know.
2000-03-30 20:20:41 +00:00
static int custom = 0 ;
2001-03-22 22:51:49 +00:00
static enum { MTXORB_LCD , MTXORB_LKD , MTXORB_VFD , MTXORB_VKD } MtxOrb_type ;
2001-09-24 22:33:59 +00:00
extern int debug_level ;
1999-12-09 23:15:14 +00:00
// TODO: Remove this custom_type if not in use anymore.
typedef enum {
2000-04-03 22:13:57 +00:00
hbar = 1 ,
vbar = 2 ,
bign = 4 ,
beat = 8
2000-03-30 20:20:41 +00:00
} custom_type ;
1999-12-09 23:15:14 +00:00
// TODO: This is my ugglyest piece of code.
typedef enum {
2000-04-03 22:13:57 +00:00
baru1 = 0 ,
baru2 = 1 ,
baru3 = 2 ,
baru4 = 3 ,
baru5 = 4 ,
baru6 = 5 ,
baru7 = 6 ,
bard1 = 7 ,
bard2 = 8 ,
bard3 = 9 ,
bard4 = 10 ,
bard5 = 11 ,
bard6 = 12 ,
bard7 = 13 ,
barr1 = 14 ,
barr2 = 15 ,
barr3 = 16 ,
barr4 = 17 ,
barl1 = 18 ,
barl2 = 19 ,
barl3 = 20 ,
barl4 = 21 ,
barw = 32 ,
barb = 255
2000-03-30 20:20:41 +00:00
} bar_type ;
1999-12-09 23:15:14 +00:00
static int fd ;
2000-03-30 20:20:41 +00:00
static int clear = 1 ;
1999-12-09 23:15:14 +00:00
2000-03-30 20:20:41 +00:00
static int def [ 9 ] = { - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 };
static int use [ 9 ] = { 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
1999-12-09 23:15:14 +00:00
2000-03-30 20:20:41 +00:00
static void MtxOrb_linewrap ( int on );
static void MtxOrb_autoscroll ( int on );
static void MtxOrb_cursorblink ( int on );
2001-09-24 22:33:59 +00:00
static void MtxOrb_string ( int x , int y , char * string );
1999-12-09 23:15:14 +00:00
2001-09-24 22:33:59 +00:00
static int
2001-09-21 21:08:10 +00:00
MtxOrb_set_type ( char * str ) {
char c ;
c = str [ 0 ];
if ( c == 'l' ) {
if ( strcmp ( str , "lcd" ) == 0 ) {
return MTXORB_LCD ;
} else if ( strcmp ( str , "lkd" ) == 0 ) {
return MTXORB_LKD ;
} else {
fprintf ( stderr , "MtxOrb_init: unknwon display type %s; must be one of lcd, lkd, vfd, or vkd \n " , str );
}
} else if ( c == 'v' ) {
if ( strcmp ( str , "vfd" ) == 0 ) {
return MTXORB_VFD ;
} else if ( strcmp ( str , "vkd" ) == 0 ) {
return MTXORB_VKD ;
} else {
fprintf ( stderr , "MtxOrb_init: unknwon display type %s; must be one of lcd, lkd, vfd, or vkd \n " , str );
}
} else {
fprintf ( stderr , "MtxOrb_init: unknwon display type %s; must be one of lcd, lkd, vfd, or vkd \n " , str );
}
return ( - 1 );
}
2001-09-24 22:33:59 +00:00
static int
2001-09-21 21:08:10 +00:00
MtxOrb_get_speed ( char * arg ) {
int speed ;
switch ( atoi ( arg )) {
case 1200 : speed = B1200 ; break ;
case 2400 : speed = B2400 ; break ;
case 9600 : speed = B9600 ; break ;
case 19200 : speed = B19200 ; break ;
default :
speed = DEFAULT_SPEED ;
fprintf ( stderr , "MtxOrb_init: argument must be 1200, 2400, 9600 or 19200. Using default value" );
switch ( speed ) {
case B1200 : fprintf ( stderr , " of 1200 baud. \n " ); break ;
case B2400 : fprintf ( stderr , " of 2400 baud. \n " ); break ;
case B9600 : fprintf ( stderr , " of 9600 baud. \n " ); break ;
case B19200 : fprintf ( stderr , " of 19200 baud. \n " ); break ;
default : fprintf ( stderr , ". \n " ); break ;
}
}
return speed ;
}
2001-09-24 22:33:59 +00:00
static void
2001-09-21 21:08:10 +00:00
MtxOrb_usage ( void ) {
printf ( "LCDproc Matrix-Orbital LCD driver \n "
" \t -d \t --device \t Select the output device to use [/dev/lcd] \n "
// "\t-t\t--type\t\tSelect the LCD type (size) [20x4]\n"
// "\t-b\t--backlight\tSelect the backlight state [on]\n"
" \t -c \t --contrast \t Set the initial contrast [140] \n "
" \t -s \t --speed \t\t Set the communication speed [19200] \n "
" \t -h \t --help \t\t Show this help information \n "
" \t -t \t --type \t\t display type: lcd, lkd, vfd, vkd \n " );
}
2001-09-24 22:33:59 +00:00
static int
2001-09-21 21:08:10 +00:00
MtxOrb_set_contrast ( char * str ) {
int contrast ;
contrast = atoi ( str );
if (( contrast < 0 ) || ( contrast > 255 )) {
fprintf ( stderr , "MtxOrb_init: argument must between 0 and 255 (found %s). Using default contrast value of %d. \n " , str , DEFAULT_CONTRAST );
contrast = DEFAULT_CONTRAST ;
}
return contrast ;
}
2001-09-24 22:33:59 +00:00
// TODO: Get rid of this variable? Probably not...
2001-09-21 21:08:10 +00:00
lcd_logical_driver * MtxOrb ; // set by MtxOrb_init(); doesn't seem to be used anywhere
1999-12-09 23:15:14 +00:00
// TODO: Get the frame buffers working right
/////////////////////////////////////////////////////////////////
// Opens com port and sets baud correctly...
//
2001-09-21 21:08:10 +00:00
// Called to initialize driver settings
//
2000-03-30 20:20:41 +00:00
int
MtxOrb_init ( lcd_logical_driver * driver , char * args )
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
char * argv [ 64 ]; // Notice: 64 arguments - overflows?
2000-04-03 22:13:57 +00:00
int argc ;
struct termios portset ;
int i ;
int tmp ;
2000-03-30 20:20:41 +00:00
2001-09-21 21:08:10 +00:00
int contrast = DEFAULT_CONTRAST ;
char device [ 256 ] = DEFAULT_DEVICE ;
int speed = DEFAULT_SPEED ;
2001-07-18 22:30:12 +00:00
MtxOrb_type = MTXORB_LKD ; // Assume it's an LCD w/keypad
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
MtxOrb = driver ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
//debug("MtxOrb_init: Args(all): %s\n", args);
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
argc = get_args ( argv , args , 64 );
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
/*
for(i=0; i<argc; i++)
{
printf("Arg(%i): %s\n", i, argv[i]);
}
*/
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
for ( i = 0 ; i < argc ; i ++ ) {
//printf("Arg(%i): %s\n", i, argv[i]);
if ( 0 == strcmp ( argv [ i ], "-d" ) || 0 == strcmp ( argv [ i ], "--device" )) {
if ( i + 1 > argc ) {
fprintf ( stderr , "MtxOrb_init: %s requires an argument \n " , argv [ i ]);
return - 1 ;
}
strcpy ( device , argv [ ++ i ]);
} else if ( 0 == strcmp ( argv [ i ], "-c" ) || 0 == strcmp ( argv [ i ], "--contrast" )) {
if ( i + 1 > argc ) {
fprintf ( stderr , "MtxOrb_init: %s requires an argument \n " , argv [ i ]);
return - 1 ;
}
tmp = atoi ( argv [ ++ i ]);
if (( tmp < 0 ) || ( tmp > 255 )) {
fprintf ( stderr , "MtxOrb_init: %s argument must between 0 and 255. Ussing default value. \n " , argv [ i ]);
} else
contrast = tmp ;
} else if ( 0 == strcmp ( argv [ i ], "-s" ) || 0 == strcmp ( argv [ i ], "--speed" )) {
if ( i + 1 > argc ) {
fprintf ( stderr , "MtxOrb_init: %s requires an argument \n " , argv [ i ]);
return - 1 ;
}
tmp = atoi ( argv [ ++ i ]);
if ( tmp == 1200 )
speed = B1200 ;
else if ( tmp == 2400 )
speed = B2400 ;
else if ( tmp == 9600 )
speed = B9600 ;
else if ( tmp == 19200 )
speed = B19200 ;
else {
fprintf ( stderr , "MtxOrb_init: %s argument must be 1200, 2400, 9600 or 19200. Ussing default value. \n " , argv [ i ]);
}
} else if ( 0 == strcmp ( argv [ i ], "-h" ) || 0 == strcmp ( argv [ i ], "--help" )) {
printf ( "LCDproc Matrix-Orbital LCD driver \n " " \t -d \t --device \t Select the output device to use [/dev/lcd] \n "
2000-03-30 20:20:41 +00:00
// "\t-t\t--type\t\tSelect the LCD type (size) [20x4]\n"
2001-03-22 22:51:49 +00:00
" \t -c \t --contrast \t Set the initial contrast [140] \n " " \t -s \t --speed \t\t Set the communication speed [19200] \n " " \t -h \t --help \t\t Show this help information \n " " \t -t \t --type \t\t display type: lcd, lkd, vfd, vkd \n " );
2000-04-03 22:13:57 +00:00
return - 1 ;
2001-03-22 22:51:49 +00:00
} else if ( 0 == strcmp ( argv [ i ], "-t" ) || 0 == strcmp ( argv [ i ], "--type" )) {
if ( i + 1 > argc ) {
fprintf ( stderr , "MtxOrb_init: %s requires an argument \n " , argv [ i ]);
return - 1 ;
}
i ++ ;
if ( 0 == strcmp ( argv [ i ], "lcd" ) ) {
MtxOrb_type = MTXORB_LCD ;
} else if ( 0 == strcmp ( argv [ i ], "lkd" ) ) {
MtxOrb_type = MTXORB_LKD ;
} else if ( 0 == strcmp ( argv [ i ], "vfd" ) ) {
MtxOrb_type = MTXORB_VFD ;
} else if ( 0 == strcmp ( argv [ i ], "vkd" ) ) {
MtxOrb_type = MTXORB_VKD ;
} else {
fprintf ( stderr , "MtxOrb_init: unknwon display type %s \n " , argv [ i ]);
return ( - 1 );
}
2000-04-03 22:13:57 +00:00
} else {
printf ( "Invalid parameter: %s \n " , argv [ i ]);
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
// Set up io port correctly, and open it...
fd = open ( device , O_RDWR | O_NOCTTY | O_NDELAY );
if ( fd == - 1 ) {
2001-09-21 21:08:10 +00:00
switch ( errno ) {
case ENOENT : fprintf ( stderr , "MtxOrb_init: %s device file missing! \n " , device );
break ;
case EACCES : fprintf ( stderr , "MtxOrb_init: %s device could not be opened... \n " , device );
fprintf ( stderr , "MtxOrb_init: perhaps you should run LCDd as root? \n " );
break ;
default : fprintf ( stderr , "MtxOrb_init: failed (%s) \n " , strerror ( errno ));
break ;
}
return - 1 ;
} else
syslog ( LOG_INFO , "opened Matrix Orbital display on %s \n " , device );
2000-04-03 22:13:57 +00:00
tcgetattr ( fd , & portset );
2001-07-18 22:30:12 +00:00
// We use RAW mode
#ifdef HAVE_CFMAKERAW
// The easy way
cfmakeraw ( & portset );
#else
// The hard way
portset . c_iflag &= ~ ( IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON );
portset . c_oflag &= ~ OPOST ;
portset . c_lflag &= ~ ( ECHO | ECHONL | ICANON | ISIG | IEXTEN );
portset . c_cflag &= ~ ( CSIZE | PARENB | CRTSCTS );
portset . c_cflag |= CS8 | CREAD | CLOCAL ;
1999-12-09 23:15:14 +00:00
#endif
2001-07-18 22:30:12 +00:00
// Set port speed
2000-04-03 22:13:57 +00:00
cfsetospeed ( & portset , speed );
2001-07-18 22:30:12 +00:00
cfsetispeed ( & portset , B0 );
// Do it...
2000-04-03 22:13:57 +00:00
tcsetattr ( fd , TCSANOW , & portset );
1999-12-09 23:15:14 +00:00
2001-09-21 21:08:10 +00:00
/*
* Configure display
*/
MtxOrb_linewrap ( DEFAULT_LINEWRAP );
MtxOrb_autoscroll ( DEFAULT_AUTOSCROLL );
MtxOrb_cursorblink ( DEFAULT_CURSORBLINK );
MtxOrb_contrast ( contrast );
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
if ( ! driver -> framebuf ) {
2001-09-24 22:33:59 +00:00
syslog ( LOG_ERR , "no frame buffer! exiting driver init..." );
2000-04-03 22:13:57 +00:00
driver -> close ();
return - 1 ;
}
1999-12-09 23:15:14 +00:00
2001-09-21 21:08:10 +00:00
/*
* Configure the display functions
*/
2001-09-24 22:33:59 +00:00
driver -> clear = MtxOrb_clear ;
driver -> string = MtxOrb_string ;
driver -> chr = MtxOrb_chr ;
2000-04-03 22:13:57 +00:00
driver -> vbar = MtxOrb_vbar ;
2001-09-24 22:33:59 +00:00
driver -> init_vbar = MtxOrb_init_vbar ;
2000-04-03 22:13:57 +00:00
driver -> hbar = MtxOrb_hbar ;
2001-09-24 22:33:59 +00:00
driver -> init_hbar = MtxOrb_init_hbar ;
2000-04-03 22:13:57 +00:00
driver -> num = MtxOrb_num ;
driver -> init_num = MtxOrb_init_num ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
driver -> init = MtxOrb_init ;
driver -> close = MtxOrb_close ;
driver -> flush = MtxOrb_flush ;
driver -> flush_box = MtxOrb_flush_box ;
driver -> contrast = MtxOrb_contrast ;
driver -> backlight = MtxOrb_backlight ;
driver -> output = MtxOrb_output ;
driver -> set_char = MtxOrb_set_char ;
driver -> icon = MtxOrb_icon ;
driver -> draw_frame = MtxOrb_draw_frame ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
driver -> getkey = MtxOrb_getkey ;
2001-09-21 21:08:10 +00:00
driver -> getinfo = MtxOrb_getinfo ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
return fd ;
1999-12-09 23:15:14 +00:00
}
2001-09-25 00:54:24 +00:00
#define ValidX(a) { if (x > MtxOrb->wid) { x = MtxOrb->wid; } else x < 1 ? 1 : x; }
#define ValidY(a) { if (y > MtxOrb->hgt) { y = MtxOrb->hgt; } else y < 1 ? 1 : y; }
1999-12-09 23:15:14 +00:00
// TODO: Check this quick hack to detect clear of the screen.
/////////////////////////////////////////////////////////////////
// Clear: catch up when the screen get clear to be able to
// forget bar caracter not in use anymore and reuse the
// slot for another bar caracter.
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_clear ()
1999-12-09 23:15:14 +00:00
{
2001-09-24 22:33:59 +00:00
if ( MtxOrb -> framebuf != NULL )
memset ( MtxOrb -> framebuf , ' ' , ( MtxOrb -> wid * MtxOrb -> hgt ));
write ( fd , " \x0FE " "X" , 2 ); // instant clear...
2000-04-03 22:13:57 +00:00
clear = 1 ;
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Clean-up
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_close ()
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
close ( fd );
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
if ( MtxOrb -> framebuf )
free ( MtxOrb -> framebuf );
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
MtxOrb -> framebuf = NULL ;
1999-12-09 23:15:14 +00:00
}
2001-09-24 22:33:59 +00:00
static void
MtxOrb_string ( int x , int y , char * string )
1999-12-09 23:15:14 +00:00
{
2001-09-24 22:33:59 +00:00
int offset , siz ;
2001-09-25 00:54:24 +00:00
ValidX ( x );
ValidY ( y );
2001-09-24 22:33:59 +00:00
x -- ; y -- ; // Convert 1-based coords to 0-based...
offset = ( y * MtxOrb -> wid ) + x ;
siz = ( MtxOrb -> wid * MtxOrb -> hgt ) - offset - 1 ;
siz = siz > strlen ( string ) ? strlen ( string ) : siz ;
memcpy ( MtxOrb -> framebuf + offset , string , siz );
1999-12-09 23:15:14 +00:00
}
2001-09-24 22:33:59 +00:00
static void
MtxOrb_flush ()
{
MtxOrb_draw_frame ( MtxOrb -> framebuf );
}
static void
2000-03-30 20:20:41 +00:00
MtxOrb_flush_box ( int lft , int top , int rgt , int bot )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
int y ;
char out [ LCD_MAX_WIDTH ];
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
for ( y = top ; y <= bot ; y ++ ) {
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE G%c%c" , lft , y );
2000-04-03 22:13:57 +00:00
write ( fd , out , 4 );
2001-09-24 22:33:59 +00:00
write ( fd , MtxOrb -> framebuf + ( y * MtxOrb -> wid ) + lft , rgt - lft + 1 );
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
}
2000-03-30 20:20:41 +00:00
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Prints a character on the lcd display, at position (x,y). The
// upper-left is (1,1), and the lower right should be (20,4).
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_chr ( int x , int y , char c )
1999-12-09 23:15:14 +00:00
{
2001-09-24 22:33:59 +00:00
char out [ 10 ], buf [ 64 ];
int offset ;
// Characters may or may NOT be alphabetic; it appears
// that characters 0..4 (or similar) are graphic fonts
2000-03-30 20:20:41 +00:00
2001-09-25 00:54:24 +00:00
ValidX ( x );
ValidY ( y );
2001-09-24 22:33:59 +00:00
2001-09-21 21:08:10 +00:00
// write immediately to screen... this code was taken
// from the LK202-25; should work for others, yes?
2001-09-25 15:02:33 +00:00
// snprintf(out, sizeof(out), "\x0FEG%c%c%c", x, y, c);
2001-09-24 22:33:59 +00:00
// write (fd, out, 4);
2001-09-21 21:08:10 +00:00
// write to frame buffer
2001-09-24 22:33:59 +00:00
y -- ; x -- ; // translate to 0-index
offset = ( y * MtxOrb -> wid ) + x ;
MtxOrb -> framebuf [ offset ] = c ;
if ( debug_level > 2 ) {
snprintf ( buf , sizeof ( buf ), "writing character %02X to position (%d,%d)" ,
c , x , y );
syslog ( LOG_DEBUG , buf );
}
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Changes screen contrast (0-255; 140 seems good)
2001-03-22 22:51:49 +00:00
// note: works only for LCD displays
// Is it better to use the brightness for VFD/VKD displays ?
1999-12-09 23:15:14 +00:00
//
2001-09-24 22:33:59 +00:00
static int
2000-03-30 20:20:41 +00:00
MtxOrb_contrast ( int contrast )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char out [ 4 ];
1999-12-09 23:15:14 +00:00
2001-09-21 21:08:10 +00:00
// validate contrast value
if ( contrast > 255 )
contrast = 255 ;
if ( contrast < 0 )
contrast = 0 ;
if ( IS_LCD_DISPLAY || IS_LKD_DISPLAY ) {
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE P%c" , contrast );
2000-04-03 22:13:57 +00:00
write ( fd , out , 3 );
}
2001-09-21 21:08:10 +00:00
return contrast ;
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Sets the backlight on or off -- can be done quickly for
// an intermediate brightness...
//
2001-09-21 21:08:10 +00:00
// WARNING: off switches vfd/vkd displays off entirely
// so maybe it is best to start LCDd with -b on
//
// WARNING: there seems to be a movement afoot to add more
// functions than just on/off to this..
#define BACKLIGHT_OFF 0
#define BACKLIGHT_ON 1
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_backlight ( int on )
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
switch ( on ) {
case BACKLIGHT_ON :
write ( fd , " \x0FE " "F" , 2 );
break ;
case BACKLIGHT_OFF :
if ( IS_VKD_DISPLAY || IS_VFD_DISPLAY )
; // turns display off entirely (whoops!)
else
write ( fd , " \x0FE " "B" " \x000 " , 3 );
break ;
default : // ignored...
break ;
}
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Sets output port on or off
2001-03-22 22:51:49 +00:00
// displays with keypad have 6 outputs but the one without kepad
// have only one output
// NOTE: length of command are different
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_output ( int on )
1999-12-09 23:15:14 +00:00
{
2001-03-22 22:51:49 +00:00
char out [ 5 ];
2001-09-21 21:08:10 +00:00
if ( IS_LCD_DISPLAY || IS_VFD_DISPLAY ) {
// LCD and VFD displays only have one output port
( on ) ?
write ( fd , " \x0FE W" , 2 ) :
write ( fd , " \x0FE V" , 2 );
2001-03-22 22:51:49 +00:00
} else {
int i ;
2001-09-21 21:08:10 +00:00
// Other displays have six output ports;
// the value "on" is a binary value determining which
// ports are turned on (1) and off (0).
on = on & 077 ; // strip to six bits
for ( i = 0 ; i < 6 ; i ++ ) {
( on & ( 1 << i )) ?
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE W%c" , i + 1 ) :
snprintf ( out , sizeof ( out ), " \x0FE V%c" , i + 1 );
2001-03-22 22:51:49 +00:00
write ( fd , out , 3 );
}
2000-04-03 22:13:57 +00:00
}
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Toggle the built-in linewrapping feature
//
2000-03-30 20:20:41 +00:00
static void
MtxOrb_linewrap ( int on )
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
( on ) ? write ( fd , " \x0FE " "C" , 2 ) : write ( fd , " \x0FE " "D" , 2 );
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Toggle the built-in automatic scrolling feature
//
2000-03-30 20:20:41 +00:00
static void
MtxOrb_autoscroll ( int on )
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
( on ) ? write ( fd , " \x0FE Q" , 2 ) : write ( fd , " \x0FE R" , 2 );
1999-12-09 23:15:14 +00:00
}
// TODO: make sure this doesn't mess up non-VFD displays
/////////////////////////////////////////////////////////////////
// Toggle cursor blink on/off
//
2000-03-30 20:20:41 +00:00
static void
MtxOrb_cursorblink ( int on )
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
( on ) ? write ( fd , " \x0FE S" , 2 ) : write ( fd , " \x0FE T" , 2 );
1999-12-09 23:15:14 +00:00
}
//// TODO: Might not be needed anymore...
/////////////////////////////////////////////////////////////////
// Sets up for vertical bars. Call before lcd.vbar()
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_init_vbar ()
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
// Isn't this function supposed to go away?
2000-04-03 22:13:57 +00:00
MtxOrb_init_all ( vbar );
1999-12-09 23:15:14 +00:00
}
// TODO: Might not be needed anymore...
/////////////////////////////////////////////////////////////////
// Inits horizontal bars...
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_init_hbar ()
1999-12-09 23:15:14 +00:00
{
2001-09-21 21:08:10 +00:00
// Isn't this function supposed to go away?
2000-04-03 22:13:57 +00:00
MtxOrb_init_all ( hbar );
1999-12-09 23:15:14 +00:00
}
2001-09-21 21:08:10 +00:00
/////////////////////////////////////////////////////////////////
// Returns string with general information about the display
//
2001-09-24 22:33:59 +00:00
static char *
2001-09-21 21:08:10 +00:00
MtxOrb_getinfo ( void )
{
char in = 0 ;
static char info [ 255 ];
char tmp [ 255 ], buf [ 64 ];
int i = 0 ;
fd_set rfds ;
struct timeval tv ;
int retval ;
memset ( info , '\0' , sizeof ( info ));
strcpy ( info , "Matrix Orbital Driver " );
/*
* Read type of display
*/
write ( fd , " \x0FE " "7" , 2 );
/* Watch fd to see when it has input. */
FD_ZERO ( & rfds );
FD_SET ( fd , & rfds );
/* Wait the specified amount of time. */
tv . tv_sec = 0 ; // seconds
tv . tv_usec = 500 ; // microseconds
retval = select ( 1 , & rfds , NULL , NULL , & tv );
if ( retval ) {
if ( read ( fd , & in , 1 ) < 0 ) {
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read data" );
} else {
switch ( in ) {
case '\x01' : strcat ( info , "LCD0821 " ); break ;
case '\x03' : strcat ( info , "LCD2021 " ); break ;
case '\x04' : strcat ( info , "LCD1641 " ); break ;
case '\x05' : strcat ( info , "LCD2041 " ); break ;
case '\x06' : strcat ( info , "LCD4021 " ); break ;
case '\x07' : strcat ( info , "LCD4041 " ); break ;
case '\x08' : strcat ( info , "LK202-25 " ); break ;
case '\x09' : strcat ( info , "LK204-25 " ); break ;
case '\x0A' : strcat ( info , "LK404-55 " ); break ;
case '\x0B' : strcat ( info , "VFD2021 " ); break ;
case '\x0C' : strcat ( info , "VFD2041 " ); break ;
case '\x0D' : strcat ( info , "VFD4021 " ); break ;
case '\x0E' : strcat ( info , "VK202-25 " ); break ;
case '\x0F' : strcat ( info , "VK204-25 " ); break ;
case '\x10' : strcat ( info , "GLC12232 " ); break ;
case '\x11' : strcat ( info , "GLC12864 " ); break ;
case '\x12' : strcat ( info , "GLC128128 " ); break ;
case '\x13' : strcat ( info , "GLC24064 " ); break ;
case '\x14' : strcat ( info , "GLK12864-25 " ); break ;
case '\x15' : strcat ( info , "GLK24064-25 " ); break ;
case '\x21' : strcat ( info , "GLK128128-25 " ); break ;
case '\x22' : strcat ( info , "GLK12232-25 " ); break ;
case '\x31' : strcat ( info , "LK404-AT " ); break ;
case '\x32' : strcat ( info , "VFD1621 " ); break ;
case '\x33' : strcat ( info , "LK402-12 " ); break ;
case '\x34' : strcat ( info , "LK162-12 " ); break ;
case '\x35' : strcat ( info , "LK204-25PC " ); break ;
2001-09-25 15:02:33 +00:00
default : //snprintf(tmp, sizeof(tmp), "Unknown (%X) ", in); strcat(info, tmp);
2001-09-21 21:08:10 +00:00
break ;
}
}
} else
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read device type" );
/*
* Read serial number of display
*/
memset ( tmp , '\0' , sizeof ( tmp ));
write ( fd , " \x0FE " "5" , 2 );
/* Wait the specified amount of time. */
tv . tv_sec = 0 ; // seconds
tv . tv_usec = 500 ; // microseconds
retval = select ( 1 , & rfds , NULL , NULL , & tv );
if ( retval ) {
if ( read ( fd , & tmp , 2 ) < 0 ) {
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read data" );
} else {
2001-09-25 15:02:33 +00:00
snprintf ( buf , sizeof ( buf ), "Serial No: %ld " , ( long int ) tmp );
2001-09-21 21:08:10 +00:00
strcat ( info , buf );
}
} else
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read device serial number" );
/*
* Read firmware revision number
*/
memset ( tmp , '\0' , sizeof ( tmp ));
write ( fd , " \x0FE " "6" , 2 );
/* Wait the specified amount of time. */
tv . tv_sec = 0 ; // seconds
tv . tv_usec = 500 ; // microseconds
retval = select ( 1 , & rfds , NULL , NULL , & tv );
if ( retval ) {
if ( read ( fd , & tmp , 2 ) < 0 ) {
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read data" );
} else {
2001-09-25 15:02:33 +00:00
snprintf ( buf , sizeof ( buf ), "Firmware Rev. %ld " , ( long int ) tmp );
2001-09-21 21:08:10 +00:00
strcat ( info , buf );
}
} else
syslog ( LOG_WARNING , "MatrixOrbital driver: unable to read device firmware revision" );
return info ;
}
1999-12-09 23:15:14 +00:00
// TODO: Finish the support for bar growing reverse way.
// TODO: Need a "y" as input also !!!
/////////////////////////////////////////////////////////////////
// Draws a vertical bar...
// This is the new version ussing dynamic icon alocation
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_vbar ( int x , int len )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
unsigned char mapu [ 9 ] = { barw , baru1 , baru2 , baru3 , baru4 , baru5 , baru6 , baru7 , barb };
unsigned char mapd [ 9 ] = { barw , bard1 , bard2 , bard3 , bard4 , bard5 , bard6 , bard7 , barb };
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
int y ;
1999-12-09 23:15:14 +00:00
2001-09-21 21:08:10 +00:00
// REMOVE THE NEXT LINE FOR TESTING ONLY...
1999-12-09 23:15:14 +00:00
// len=-len;
2001-09-21 21:08:10 +00:00
// REMOVE THE PREVIOUS LINE FOR TESTING ONLY...
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
if ( len > 0 ) {
2001-09-24 22:33:59 +00:00
for ( y = MtxOrb -> hgt ; y > 0 && len > 0 ; y -- ) {
if ( len >= MtxOrb -> cellhgt )
2000-04-03 22:13:57 +00:00
MtxOrb_chr ( x , y , 255 );
else
MtxOrb_chr ( x , y , MtxOrb_ask_bar ( mapu [ len ]));
1999-12-09 23:15:14 +00:00
2001-09-24 22:33:59 +00:00
len -= MtxOrb -> cellhgt ;
2000-04-03 22:13:57 +00:00
}
} else {
len = - len ;
2001-09-24 22:33:59 +00:00
for ( y = 2 ; y <= MtxOrb -> hgt && len > 0 ; y ++ ) {
if ( len >= MtxOrb -> cellhgt )
2000-04-03 22:13:57 +00:00
MtxOrb_chr ( x , y , 255 );
else
MtxOrb_chr ( x , y , MtxOrb_ask_bar ( mapd [ len ]));
2000-03-30 20:20:41 +00:00
2001-09-24 22:33:59 +00:00
len -= MtxOrb -> cellhgt ;
2000-04-03 22:13:57 +00:00
}
}
1999-12-09 23:15:14 +00:00
}
// TODO: Finish the support for bar growing reverse way.
/////////////////////////////////////////////////////////////////
// Draws a horizontal bar to the right.
// This is the new version ussing dynamic icon alocation
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_hbar ( int x , int y , int len )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
unsigned char mapr [ 6 ] = { barw , barr1 , barr2 , barr3 , barr4 , barb };
unsigned char mapl [ 6 ] = { barw , barl1 , barl2 , barl3 , barl4 , barb };
1999-12-09 23:15:14 +00:00
2001-09-25 00:54:24 +00:00
ValidX ( x );
ValidY ( y );
2000-04-03 22:13:57 +00:00
if ( len > 0 ) {
2001-09-24 22:33:59 +00:00
for (; x <= MtxOrb -> wid && len > 0 ; x ++ ) {
if ( len >= MtxOrb -> cellwid )
2000-04-03 22:13:57 +00:00
MtxOrb_chr ( x , y , 255 );
else
MtxOrb_chr ( x , y , MtxOrb_ask_bar ( mapr [ len ]));
2000-03-30 20:20:41 +00:00
2001-09-24 22:33:59 +00:00
len -= MtxOrb -> cellwid ;
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
}
} else {
len = - len ;
for (; x > 0 && len > 0 ; x -- ) {
2001-09-24 22:33:59 +00:00
if ( len >= MtxOrb -> cellwid )
2000-04-03 22:13:57 +00:00
MtxOrb_chr ( x , y , 255 );
else
MtxOrb_chr ( x , y , MtxOrb_ask_bar ( mapl [ len ]));
2000-03-30 20:20:41 +00:00
2001-09-24 22:33:59 +00:00
len -= MtxOrb -> cellwid ;
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
}
}
1999-12-09 23:15:14 +00:00
}
// TODO: Might not work, bignum is untested... an untested with dynamic bar.
/////////////////////////////////////////////////////////////////
// Sets up for big numbers.
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_init_num ()
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
if ( custom != bign ) {
2001-09-21 21:08:10 +00:00
write ( fd , " \x0FE n" , 2 );
2000-04-03 22:13:57 +00:00
custom = bign ;
}
1999-12-09 23:15:14 +00:00
}
// TODO: Might not work, bignum is untested... an untested with dynamic bar.
/////////////////////////////////////////////////////////////////
// Writes a big number.
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_num ( int x , int num )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char out [ 5 ];
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE #%c%c" , x , num );
2000-04-03 22:13:57 +00:00
write ( fd , out , 4 );
1999-12-09 23:15:14 +00:00
}
// TODO: This could be higly optimised if data where to be pre-computed.
/////////////////////////////////////////////////////////////////
// Sets a custom character from 0-7...
//
// For input, values > 0 mean "on" and values <= 0 are "off".
//
// The input is just an array of characters...
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_set_char ( int n , char * dat )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char out [ 4 ];
int row , col ;
int letter ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
if ( n < 0 || n > 7 )
return ;
if ( ! dat )
return ;
1999-12-09 23:15:14 +00:00
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE N%c" , n );
2000-04-03 22:13:57 +00:00
write ( fd , out , 3 );
2000-03-30 20:20:41 +00:00
2001-09-24 22:33:59 +00:00
for ( row = 0 ; row < MtxOrb -> cellhgt ; row ++ ) {
2000-04-03 22:13:57 +00:00
letter = 0 ;
2001-09-24 22:33:59 +00:00
for ( col = 0 ; col < MtxOrb -> cellwid ; col ++ ) {
2000-04-03 22:13:57 +00:00
letter <<= 1 ;
2001-09-24 22:33:59 +00:00
letter |= ( dat [( row * MtxOrb -> cellwid ) + col ] > 0 );
2000-04-03 22:13:57 +00:00
}
write ( fd , & letter , 1 );
}
1999-12-09 23:15:14 +00:00
}
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_icon ( int which , char dest )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char icons [ 3 ][ 5 * 8 ] = {
{
1 , 1 , 1 , 1 , 1 , // Empty Heart
1 , 0 , 1 , 0 , 1 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
1 , 0 , 0 , 0 , 1 ,
1 , 1 , 0 , 1 , 1 ,
1 , 1 , 1 , 1 , 1 ,
},
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
{
1 , 1 , 1 , 1 , 1 , // Filled Heart
1 , 0 , 1 , 0 , 1 ,
0 , 1 , 0 , 1 , 0 ,
0 , 1 , 1 , 1 , 0 ,
0 , 1 , 1 , 1 , 0 ,
1 , 0 , 1 , 0 , 1 ,
1 , 1 , 0 , 1 , 1 ,
1 , 1 , 1 , 1 , 1 ,
},
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
{
0 , 0 , 0 , 0 , 0 , // Ellipsis
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
1 , 0 , 1 , 0 , 1 ,
},
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
};
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
if ( custom == bign )
custom = beat ;
MtxOrb_set_char ( dest , & icons [ which ][ 0 ]);
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////
// Blasts a single frame onscreen, to the lcd...
//
// Input is a character array, sized lcd.wid*lcd.hgt
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_draw_frame ( char * dat )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char out [ LCD_MAX_WIDTH * LCD_MAX_HEIGHT ];
int i ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
if ( ! dat )
return ;
2001-09-25 00:54:24 +00:00
2001-09-25 15:02:33 +00:00
// snprintf(out, sizeof(out), "%cG%c%c", 254, 1, 1);
2001-09-25 00:54:24 +00:00
// write(fd, out, 4);
// write(fd, dat, lcd.wid*lcd.hgt);
2001-09-24 22:33:59 +00:00
for ( i = 0 ; i < MtxOrb -> hgt ; i ++ ) {
2001-09-25 15:02:33 +00:00
snprintf ( out , sizeof ( out ), " \x0FE G \x001 %c" , i + 1 );
2000-04-03 22:13:57 +00:00
write ( fd , out , 4 );
2001-09-24 22:33:59 +00:00
write ( fd , dat + ( MtxOrb -> wid * i ), MtxOrb -> wid );
2000-04-03 22:13:57 +00:00
}
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////
// returns one character from the keypad...
// (A-Z) on success, 0 on failure...
//
2001-09-24 22:33:59 +00:00
static char
2000-03-30 20:20:41 +00:00
MtxOrb_getkey ()
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char in = 0 ;
2001-09-21 21:08:10 +00:00
2000-04-03 22:13:57 +00:00
read ( fd , & in , 1 );
return in ;
1999-12-09 23:15:14 +00:00
}
/////////////////////////////////////////////////////////////////
// Ask for dynamic allocation of a custom caracter to be
// a well none bar graphic. The function is suppose to
// return a value between 0 and 7 but 0 is reserver for
// heart beat.
// This function manadge a cache of graphical caracter in use.
// I really hope it is working and bug-less because it is not
// completely tested, just a quick hack.
//
2001-09-24 22:33:59 +00:00
static int
2000-03-30 20:20:41 +00:00
MtxOrb_ask_bar ( int type )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
int i ;
int last_not_in_use ;
int pos ; // 0 is icon, 1 to 7 are free, 8 is not found.
// TODO: Reuse graphic caracter 0 if heartbeat is not in use.
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
// REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar(%d).\n", type);
// Check if the screen was clear.
if ( clear ) { // If the screen was clear then graphic caracter are not in use.
//REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar| clear was set.\n");
use [ 0 ] = 1 ; // Heartbeat is always in use (not true but it help).
for ( pos = 1 ; pos < 8 ; pos ++ ) {
use [ pos ] = 0 ; // Other are not in use.
}
clear = 0 ; // We made the special treatement.
} else {
// Nothing special if some caracter a curently in use (...) ?
}
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
// Search for a match with caracter already defined.
pos = 8 ; // Not found.
last_not_in_use = 8 ; // No empty slot to reuse.
for ( i = 1 ; i < 8 ; i ++ ) { // For all but first (heartbeat).
if ( ! use [ i ])
last_not_in_use = i ; // New empty slot.
if ( def [ i ] == type )
pos = i ; // Founded (should break now).
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
if ( pos == 8 ) {
// REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar| not found.\n");
pos = last_not_in_use ;
// TODO: Best match/deep search is no more graphic caracter are available.
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
if ( pos != 8 ) { // A caracter is found (Best match could solve our problem).
// REMOVE: fprintf(stderr, "GLU: MtxOrb_ask_bar| found at %d.\n", pos);
if ( def [ pos ] != type ) {
MtxOrb_set_known_char ( pos , type ); // Define a new graphic caracter.
def [ pos ] = type ; // Remember that now the caracter is available.
}
if ( ! use [ pos ]) { // If the caracter is no yet in use (but defined).
use [ pos ] = 1 ; // Remember it is in use (so protect it from re-use).
}
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
if ( pos == 8 ) // TODO: Choose a character to approximate the graph
{
//pos=65; // ("A")?
switch ( type ) {
case baru1 :
pos = '_' ;
break ;
case baru2 :
pos = '.' ;
break ;
case baru3 :
pos = ',' ;
break ;
case baru4 :
pos = 'o' ;
break ;
case baru5 :
pos = 'o' ;
break ;
case baru6 :
pos = 'O' ;
break ;
case baru7 :
pos = '8' ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
case bard1 :
pos = '\'' ;
break ;
case bard2 :
pos = '"' ;
break ;
case bard3 :
pos = '^' ;
break ;
case bard4 :
pos = '^' ;
break ;
case bard5 :
pos = '*' ;
break ;
case bard6 :
pos = 'O' ;
break ;
case bard7 :
pos = '8' ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
case barr1 :
pos = '-' ;
break ;
case barr2 :
pos = '-' ;
break ;
case barr3 :
pos = '=' ;
break ;
case barr4 :
pos = '=' ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
case barl1 :
pos = '-' ;
break ;
case barl2 :
pos = '-' ;
break ;
case barl3 :
pos = '=' ;
break ;
case barl4 :
pos = '=' ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
case barw :
pos = ' ' ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
case barb :
pos = 255 ;
break ;
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
default :
pos = '?' ;
break ;
}
}
2000-03-30 20:20:41 +00:00
2000-04-03 22:13:57 +00:00
return ( pos );
1999-12-09 23:15:14 +00:00
}
2001-09-21 21:08:10 +00:00
/////////////////////////////////////////////////////////////
// Does the heartbeat...
//
2001-09-24 22:33:59 +00:00
static char
2001-09-21 21:08:10 +00:00
MtxOrb_heartbeat ( int timer )
{
MtxOrb_icon ( ! (( timer + 4 ) & 5 ), 0 );
2001-09-24 22:33:59 +00:00
MtxOrb_chr ( MtxOrb -> wid , 1 , 0 );
2001-09-21 21:08:10 +00:00
return ( char ) 0 ;
}
1999-12-09 23:15:14 +00:00
/////////////////////////////////////////////////////////////////
// Sets up a well known character for use.
//
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_set_known_char ( int car , int type )
1999-12-09 23:15:14 +00:00
{
2000-04-03 22:13:57 +00:00
char all_bar [ 25 ][ 5 * 8 ] = {
{
0 , 0 , 0 , 0 , 0 , // char u1[] =
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
1 , 1 , 1 ,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 , 1 ,
}, {
0 , 0 , 0 , 0 , 0 , // Ellipsis
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
1 , 0 , 1 , 0 , 1 ,
}
};
1999-12-09 23:15:14 +00:00
2000-04-03 22:13:57 +00:00
MtxOrb_set_char ( car , & all_bar [ type ][ 0 ]);
1999-12-09 23:15:14 +00:00
}
/////////////////STOP READING --- TRASH IS AT THE END////////////////
// TODO: Remove this code wich was use for developpement.
// PS: There might be reference to this code left, so keep it for some time.
2001-09-21 21:08:10 +00:00
//
// MtxOrb_init_hbar and MtxOrb_init_vbar use it; it's prototyped in MtxOrb.h ...
2001-09-24 22:33:59 +00:00
static void
2000-03-30 20:20:41 +00:00
MtxOrb_init_all ( int type )
1999-12-09 23:15:14 +00:00
{
}