Removed lcddriver.c (doesn't do anything, isn't in any makefiles, etc.).
Passed *every* piece of source in this project through indent. I'm setting things up with ctags soon and am actually going to *gasp* use a nice programming environment to continue development in. :)
This commit is contained in:
+462
-481
File diff suppressed because it is too large
Load Diff
+16
-16
@@ -4,22 +4,22 @@
|
||||
|
||||
extern lcd_logical_driver *CFontz;
|
||||
|
||||
int CFontz_init(lcd_logical_driver *driver, char *device);
|
||||
void CFontz_close();
|
||||
void CFontz_flush();
|
||||
void CFontz_flush_box(int lft, int top, int rgt, int bot);
|
||||
void CFontz_chr(int x, int y, char c) ;
|
||||
int CFontz_contrast(int contrast);
|
||||
void CFontz_backlight(int on);
|
||||
void CFontz_init_vbar();
|
||||
void CFontz_init_hbar();
|
||||
void CFontz_vbar(int x, int len);
|
||||
void CFontz_hbar(int x, int y, int len);
|
||||
void CFontz_init_num();
|
||||
void CFontz_num(int x, int num);
|
||||
void CFontz_set_char(int n, char *dat);
|
||||
void CFontz_icon(int which, char dest);
|
||||
void CFontz_draw_frame(char *dat);
|
||||
int CFontz_init (lcd_logical_driver * driver, char *device);
|
||||
void CFontz_close ();
|
||||
void CFontz_flush ();
|
||||
void CFontz_flush_box (int lft, int top, int rgt, int bot);
|
||||
void CFontz_chr (int x, int y, char c);
|
||||
int CFontz_contrast (int contrast);
|
||||
void CFontz_backlight (int on);
|
||||
void CFontz_init_vbar ();
|
||||
void CFontz_init_hbar ();
|
||||
void CFontz_vbar (int x, int len);
|
||||
void CFontz_hbar (int x, int y, int len);
|
||||
void CFontz_init_num ();
|
||||
void CFontz_num (int x, int num);
|
||||
void CFontz_set_char (int n, char *dat);
|
||||
void CFontz_icon (int which, char dest);
|
||||
void CFontz_draw_frame (char *dat);
|
||||
|
||||
|
||||
|
||||
|
||||
+706
-653
File diff suppressed because it is too large
Load Diff
+22
-22
@@ -4,28 +4,28 @@
|
||||
|
||||
extern lcd_logical_driver *MtxOrb;
|
||||
|
||||
int MtxOrb_init(lcd_logical_driver *driver, char *device);
|
||||
void MtxOrb_clear();
|
||||
void MtxOrb_close();
|
||||
void MtxOrb_flush();
|
||||
void MtxOrb_flush_box(int lft, int top, int rgt, int bot);
|
||||
void MtxOrb_chr(int x, int y, char c) ;
|
||||
int MtxOrb_contrast(int contrast);
|
||||
void MtxOrb_backlight(int on);
|
||||
void MtxOrb_output(int on);
|
||||
void MtxOrb_init_vbar();
|
||||
void MtxOrb_init_hbar();
|
||||
void MtxOrb_vbar(int x, int len);
|
||||
void MtxOrb_hbar(int x, int y, int len);
|
||||
void MtxOrb_init_num();
|
||||
void MtxOrb_num(int x, int num);
|
||||
void MtxOrb_set_char(int n, char *dat);
|
||||
void MtxOrb_icon(int which, char dest);
|
||||
void MtxOrb_draw_frame(char *dat);
|
||||
char MtxOrb_getkey();
|
||||
int MtxOrb_init (lcd_logical_driver * driver, char *device);
|
||||
void MtxOrb_clear ();
|
||||
void MtxOrb_close ();
|
||||
void MtxOrb_flush ();
|
||||
void MtxOrb_flush_box (int lft, int top, int rgt, int bot);
|
||||
void MtxOrb_chr (int x, int y, char c);
|
||||
int MtxOrb_contrast (int contrast);
|
||||
void MtxOrb_backlight (int on);
|
||||
void MtxOrb_output (int on);
|
||||
void MtxOrb_init_vbar ();
|
||||
void MtxOrb_init_hbar ();
|
||||
void MtxOrb_vbar (int x, int len);
|
||||
void MtxOrb_hbar (int x, int y, int len);
|
||||
void MtxOrb_init_num ();
|
||||
void MtxOrb_num (int x, int num);
|
||||
void MtxOrb_set_char (int n, char *dat);
|
||||
void MtxOrb_icon (int which, char dest);
|
||||
void MtxOrb_draw_frame (char *dat);
|
||||
char MtxOrb_getkey ();
|
||||
|
||||
void MtxOrb_init_all(int type);
|
||||
int MtxOrb_ask_bar(int type);
|
||||
void MtxOrb_set_known_char(int car, int type);
|
||||
void MtxOrb_init_all (int type);
|
||||
int MtxOrb_ask_bar (int type);
|
||||
void MtxOrb_set_known_char (int car, int type);
|
||||
|
||||
#endif
|
||||
|
||||
+142
-134
@@ -24,8 +24,8 @@
|
||||
|
||||
lcd_logical_driver *curses_drv;
|
||||
|
||||
int PAD=255;
|
||||
int ELLIPSIS=7;
|
||||
int PAD = 255;
|
||||
int ELLIPSIS = 7;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// For Curses Terminal Output ////////////////////////
|
||||
@@ -34,85 +34,65 @@ int ELLIPSIS=7;
|
||||
static char icon_char = '@';
|
||||
|
||||
|
||||
int curses_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
curses_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i,j;
|
||||
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
int i, j;
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
if(0 == strcmp(argv[i], "-f") ||
|
||||
0 == strcmp(argv[i], "--forecolor"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "curses_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (0 == strcmp (argv[i], "-f") || 0 == strcmp (argv[i], "--forecolor")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
// TODO: color display in curses driver!
|
||||
printf("Sorry, colors not yet implemented...\n");
|
||||
printf ("Sorry, colors not yet implemented...\n");
|
||||
//strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-b") ||
|
||||
0 == strcmp(argv[i], "--backcolor"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "curses_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
} else if (0 == strcmp (argv[i], "-b") || 0 == strcmp (argv[i], "--backcolor")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
// TODO: color display in curses driver!
|
||||
printf("Sorry, colors not yet implemented...\n");
|
||||
printf ("Sorry, colors not yet implemented...\n");
|
||||
//strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-B") ||
|
||||
0 == strcmp(argv[i], "--backlight"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "curses_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
} else if (0 == strcmp (argv[i], "-B") || 0 == strcmp (argv[i], "--backlight")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "curses_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
// TODO: color display in curses driver!
|
||||
printf("Sorry, colors not yet implemented...\n");
|
||||
printf ("Sorry, colors not yet implemented...\n");
|
||||
//strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-h") ||
|
||||
0 == strcmp(argv[i], "--help"))
|
||||
{
|
||||
printf("LCDproc [n]curses driver\n"
|
||||
"\t-f\t--forecolor\tChange the foreground color\n"
|
||||
"\t-b\t--backcolor\tChange the backlight's \"off\" color\n"
|
||||
"\t-B\t--backlight\tChange the backlight's \"on\" color\n"
|
||||
"\t-h\t--help\t\tShow this help information\n");
|
||||
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
|
||||
printf ("LCDproc [n]curses driver\n" "\t-f\t--forecolor\tChange the foreground color\n" "\t-b\t--backcolor\tChange the backlight's \"off\" color\n" "\t-B\t--backlight\tChange the backlight's \"on\" color\n" "\t-h\t--help\t\tShow this help information\n");
|
||||
return -1;
|
||||
} else {
|
||||
printf ("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
curses_drv = driver;
|
||||
|
||||
// Init curses...
|
||||
initscr();
|
||||
cbreak();
|
||||
noecho();
|
||||
nodelay(stdscr, TRUE);
|
||||
nonl();
|
||||
intrflush(stdscr, FALSE);
|
||||
keypad(stdscr, TRUE);
|
||||
initscr ();
|
||||
cbreak ();
|
||||
noecho ();
|
||||
nodelay (stdscr, TRUE);
|
||||
nonl ();
|
||||
intrflush (stdscr, FALSE);
|
||||
keypad (stdscr, TRUE);
|
||||
|
||||
curses_drv_clear();
|
||||
curses_drv_clear ();
|
||||
|
||||
// Override output functions...
|
||||
// Override output functions...
|
||||
driver->clear = curses_drv_clear;
|
||||
driver->string = curses_drv_string;
|
||||
driver->chr = curses_drv_chr;
|
||||
@@ -122,7 +102,7 @@ int curses_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
driver->init_hbar = NULL;
|
||||
driver->num = curses_drv_num;
|
||||
driver->init_num = curses_drv_init_num;
|
||||
|
||||
|
||||
driver->init = curses_drv_init;
|
||||
driver->close = curses_drv_close;
|
||||
driver->flush = curses_drv_flush;
|
||||
@@ -139,29 +119,31 @@ int curses_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
PAD = '#';
|
||||
// Change the character used for "..."
|
||||
ELLIPSIS = '~';
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
void curses_drv_close()
|
||||
void
|
||||
curses_drv_close ()
|
||||
{
|
||||
// Close curses
|
||||
clear();
|
||||
move(0,0);
|
||||
refresh();
|
||||
endwin();
|
||||
clear ();
|
||||
move (0, 0);
|
||||
refresh ();
|
||||
endwin ();
|
||||
|
||||
drv_base_close ();
|
||||
|
||||
drv_base_close();
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void curses_drv_clear()
|
||||
void
|
||||
curses_drv_clear ()
|
||||
{
|
||||
clear();
|
||||
|
||||
clear ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -169,100 +151,111 @@ void curses_drv_clear()
|
||||
// Prints a string on the lcd display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void curses_drv_string(int x, int y, char string[])
|
||||
void
|
||||
curses_drv_string (int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
unsigned char *c;
|
||||
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
for (i = 0; string[i]; i++) {
|
||||
c = &string[i];
|
||||
switch(*c)
|
||||
{
|
||||
case 0: *c = icon_char; break;
|
||||
case 255: *c = '#'; break;
|
||||
switch (*c) {
|
||||
case 0:
|
||||
*c = icon_char;
|
||||
break;
|
||||
case 255:
|
||||
*c = '#';
|
||||
break;
|
||||
}
|
||||
}
|
||||
mvaddstr(y-1, x-1, string);
|
||||
mvaddstr (y - 1, x - 1, string);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void curses_drv_chr(int x, int y, char c)
|
||||
void
|
||||
curses_drv_chr (int x, int y, char c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case 0: c = icon_char; break;
|
||||
case -1: c = '#'; break;
|
||||
switch (c) {
|
||||
case 0:
|
||||
c = icon_char;
|
||||
break;
|
||||
case -1:
|
||||
c = '#';
|
||||
break;
|
||||
}
|
||||
|
||||
mvaddch(y-1, x-1, c);
|
||||
mvaddch (y - 1, x - 1, c);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for big numbers.
|
||||
//
|
||||
void curses_drv_init_num()
|
||||
void
|
||||
curses_drv_init_num ()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number.
|
||||
//
|
||||
void curses_drv_num(int x, int num)
|
||||
void
|
||||
curses_drv_num (int x, int num)
|
||||
{
|
||||
char c;
|
||||
int y, dx;
|
||||
|
||||
c='0'+num;
|
||||
c = '0' + num;
|
||||
// printf(&c,"%1d",num);
|
||||
|
||||
for(y=1; y<5; y++)
|
||||
for(dx=0; dx<3; dx++)
|
||||
curses_drv_chr(x+dx, y, c);
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
curses_drv_chr (x + dx, y, c);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void curses_drv_vbar(int x, int len)
|
||||
void
|
||||
curses_drv_vbar (int x, int len)
|
||||
{
|
||||
char map[]="_.,,ooO8";
|
||||
|
||||
char map[] = "_.,,ooO8";
|
||||
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
if(len >= lcd.cellhgt) curses_drv_chr(x, y, '8');
|
||||
else curses_drv_chr(x, y, map[len-1]);
|
||||
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
if (len >= lcd.cellhgt)
|
||||
curses_drv_chr (x, y, '8');
|
||||
else
|
||||
curses_drv_chr (x, y, map[len - 1]);
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
// move(4-len/lcd.cellhgt, x-1);
|
||||
// vline(0, len/lcd.cellhgt);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void curses_drv_hbar(int x, int y, int len)
|
||||
void
|
||||
curses_drv_hbar (int x, int y, int len)
|
||||
{
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
if(len>=lcd.cellwid)
|
||||
curses_drv_chr(x, y, '=');
|
||||
for (; x <= lcd.wid && len > 0; x++) {
|
||||
if (len >= lcd.cellwid)
|
||||
curses_drv_chr (x, y, '=');
|
||||
else
|
||||
curses_drv_chr(x, y, '-');
|
||||
|
||||
curses_drv_chr (x, y, '-');
|
||||
|
||||
len -= lcd.cellwid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// move(y-1, x-1);
|
||||
// hline(0, len/lcd.cellwid);
|
||||
}
|
||||
@@ -271,56 +264,71 @@ void curses_drv_hbar(int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void curses_drv_icon(int which, char dest)
|
||||
void
|
||||
curses_drv_icon (int which, char dest)
|
||||
{
|
||||
if(dest == 0)
|
||||
switch(which)
|
||||
{
|
||||
case 0: icon_char = '+'; break;
|
||||
case 1: icon_char = '*'; break;
|
||||
default: icon_char = '#'; break;
|
||||
if (dest == 0)
|
||||
switch (which) {
|
||||
case 0:
|
||||
icon_char = '+';
|
||||
break;
|
||||
case 1:
|
||||
icon_char = '*';
|
||||
break;
|
||||
default:
|
||||
icon_char = '#';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void curses_drv_flush()
|
||||
void
|
||||
curses_drv_flush ()
|
||||
{
|
||||
curses_drv_draw_frame(curses_drv->framebuf);
|
||||
curses_drv_draw_frame (curses_drv->framebuf);
|
||||
}
|
||||
|
||||
|
||||
void curses_drv_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
curses_drv_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
curses_drv_flush();
|
||||
curses_drv_flush ();
|
||||
}
|
||||
|
||||
|
||||
void curses_drv_draw_frame(char *dat)
|
||||
void
|
||||
curses_drv_draw_frame (char *dat)
|
||||
{
|
||||
// border(0, 0, 0, 0, 0, 0, lcd.wid+1, lcd.hgt+1);
|
||||
|
||||
refresh();
|
||||
|
||||
refresh ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
char curses_drv_getkey()
|
||||
char
|
||||
curses_drv_getkey ()
|
||||
{
|
||||
int i;
|
||||
|
||||
i = getch();
|
||||
|
||||
if(i == KEY_LEFT) return 'D';
|
||||
if(i == KEY_UP) return 'B';
|
||||
if(i == KEY_DOWN) return 'C';
|
||||
if(i == KEY_RIGHT) return 'A';
|
||||
|
||||
if(i != ERR) return i;
|
||||
else return 0;
|
||||
|
||||
i = getch ();
|
||||
|
||||
if (i == KEY_LEFT)
|
||||
return 'D';
|
||||
if (i == KEY_UP)
|
||||
return 'B';
|
||||
if (i == KEY_DOWN)
|
||||
return 'C';
|
||||
if (i == KEY_RIGHT)
|
||||
return 'A';
|
||||
|
||||
if (i != ERR)
|
||||
return i;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -4,21 +4,21 @@
|
||||
|
||||
extern lcd_logical_driver *curses_drv;
|
||||
|
||||
int curses_drv_init(struct lcd_logical_driver *driver, char *args);
|
||||
void curses_drv_close();
|
||||
void curses_drv_clear();
|
||||
void curses_drv_flush();
|
||||
void curses_drv_string(int x, int y, char string[]);
|
||||
void curses_drv_chr(int x, int y, char c);
|
||||
void curses_drv_vbar(int x, int len);
|
||||
void curses_drv_hbar(int x, int y, int len);
|
||||
void curses_drv_icon(int which, char dest);
|
||||
void curses_drv_flush();
|
||||
void curses_drv_flush_box(int lft, int top, int rgt, int bot);
|
||||
void curses_drv_draw_frame(char *dat);
|
||||
char curses_drv_getkey();
|
||||
void curses_drv_init_num();
|
||||
void curses_drv_num(int x, int num);
|
||||
int curses_drv_init (struct lcd_logical_driver *driver, char *args);
|
||||
void curses_drv_close ();
|
||||
void curses_drv_clear ();
|
||||
void curses_drv_flush ();
|
||||
void curses_drv_string (int x, int y, char string[]);
|
||||
void curses_drv_chr (int x, int y, char c);
|
||||
void curses_drv_vbar (int x, int len);
|
||||
void curses_drv_hbar (int x, int y, int len);
|
||||
void curses_drv_icon (int which, char dest);
|
||||
void curses_drv_flush ();
|
||||
void curses_drv_flush_box (int lft, int top, int rgt, int bot);
|
||||
void curses_drv_draw_frame (char *dat);
|
||||
char curses_drv_getkey ();
|
||||
void curses_drv_init_num ();
|
||||
void curses_drv_num (int x, int num);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+159
-148
@@ -18,88 +18,93 @@
|
||||
// function...
|
||||
|
||||
|
||||
int debug_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
debug_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
printf("debug_init(%s)\n", device);
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
printf("Allocating frame buffer (%ix%i)\n", lcd.wid, lcd.hgt);
|
||||
driver->framebuf = malloc(lcd.wid * lcd.hgt);
|
||||
}
|
||||
|
||||
printf ("debug_init(%s)\n", device);
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
debug_close();
|
||||
if (!driver->framebuf) {
|
||||
printf ("Allocating frame buffer (%ix%i)\n", lcd.wid, lcd.hgt);
|
||||
driver->framebuf = malloc (lcd.wid * lcd.hgt);
|
||||
}
|
||||
|
||||
|
||||
if (!driver->framebuf) {
|
||||
debug_close ();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(driver->framebuf) printf("Frame buffer: %i\n", (int)driver->framebuf);
|
||||
if (driver->framebuf)
|
||||
printf ("Frame buffer: %i\n", (int) driver->framebuf);
|
||||
|
||||
debug_clear();
|
||||
debug_clear ();
|
||||
|
||||
driver->clear = debug_clear;
|
||||
driver->string = debug_string;
|
||||
driver->chr = debug_chr;
|
||||
driver->vbar = debug_vbar;
|
||||
driver->hbar = debug_hbar;
|
||||
driver->init_num = debug_init_num;
|
||||
driver->num = debug_num;
|
||||
|
||||
driver->init = debug_init;
|
||||
driver->close = debug_close;
|
||||
driver->flush = debug_flush;
|
||||
driver->flush_box = debug_flush_box;
|
||||
driver->contrast = debug_contrast;
|
||||
driver->backlight = debug_backlight;
|
||||
driver->set_char = debug_set_char;
|
||||
driver->icon = debug_icon;
|
||||
driver->init_vbar = debug_init_vbar;
|
||||
driver->init_hbar = debug_init_hbar;
|
||||
driver->draw_frame = debug_draw_frame;
|
||||
driver->clear = debug_clear;
|
||||
driver->string = debug_string;
|
||||
driver->chr = debug_chr;
|
||||
driver->vbar = debug_vbar;
|
||||
driver->hbar = debug_hbar;
|
||||
driver->init_num = debug_init_num;
|
||||
driver->num = debug_num;
|
||||
|
||||
driver->getkey = debug_getkey;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
driver->init = debug_init;
|
||||
driver->close = debug_close;
|
||||
driver->flush = debug_flush;
|
||||
driver->flush_box = debug_flush_box;
|
||||
driver->contrast = debug_contrast;
|
||||
driver->backlight = debug_backlight;
|
||||
driver->set_char = debug_set_char;
|
||||
driver->icon = debug_icon;
|
||||
driver->init_vbar = debug_init_vbar;
|
||||
driver->init_hbar = debug_init_hbar;
|
||||
driver->draw_frame = debug_draw_frame;
|
||||
|
||||
driver->getkey = debug_getkey;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
void debug_close()
|
||||
void
|
||||
debug_close ()
|
||||
{
|
||||
// Ack! This shouldn't crash the program, but does.. Why??
|
||||
|
||||
|
||||
printf("debug_close()\n");
|
||||
printf ("debug_close()\n");
|
||||
|
||||
// This is the line which crashes.
|
||||
if(driver->framebuf) free(driver->framebuf);
|
||||
if (driver->framebuf)
|
||||
free (driver->framebuf);
|
||||
|
||||
if(driver->framebuf) printf("Frame buffer: %i\n", (int)driver->framebuf);
|
||||
driver->framebuf = NULL;
|
||||
if (driver->framebuf)
|
||||
printf ("Frame buffer: %i\n", (int) driver->framebuf);
|
||||
driver->framebuf = NULL;
|
||||
// printf("debug_close() finished\n");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void debug_clear()
|
||||
void
|
||||
debug_clear ()
|
||||
{
|
||||
printf("clear()\n");
|
||||
|
||||
memset(driver->framebuf, ' ', lcd.wid*lcd.hgt);
|
||||
|
||||
printf ("clear()\n");
|
||||
|
||||
memset (driver->framebuf, ' ', lcd.wid * lcd.hgt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void debug_flush()
|
||||
void
|
||||
debug_flush ()
|
||||
{
|
||||
printf("flush()\n");
|
||||
|
||||
lcd.draw_frame();
|
||||
printf ("flush()\n");
|
||||
|
||||
lcd.draw_frame ();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,182 +112,188 @@ void debug_flush()
|
||||
// Prints a string on the lcd display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void debug_string(int x, int y, char string[])
|
||||
void
|
||||
debug_string (int x, int y, char string[])
|
||||
{
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
printf("string(%i, %i):%s \n", x, y, string);
|
||||
|
||||
printf ("string(%i, %i):%s \n", x, y, string);
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
driver->framebuf[(y*lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
driver->framebuf[(y * lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void debug_chr(int x, int y, char c)
|
||||
void
|
||||
debug_chr (int x, int y, char c)
|
||||
{
|
||||
printf("character(%i, %i):%c\n", x, y, c);
|
||||
|
||||
printf ("character(%i, %i):%c\n", x, y, c);
|
||||
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y*lcd.wid) + x] = c;
|
||||
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y * lcd.wid) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void debug_contrast(int contrast)
|
||||
void
|
||||
debug_contrast (int contrast)
|
||||
{
|
||||
printf("Contrast: %i\n", contrast);
|
||||
printf ("Contrast: %i\n", contrast);
|
||||
}
|
||||
|
||||
void debug_backlight(int on)
|
||||
void
|
||||
debug_backlight (int on)
|
||||
{
|
||||
if(on)
|
||||
{
|
||||
printf("Backlight ON\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Backlight OFF\n");
|
||||
}
|
||||
if (on) {
|
||||
printf ("Backlight ON\n");
|
||||
} else {
|
||||
printf ("Backlight OFF\n");
|
||||
}
|
||||
}
|
||||
|
||||
void debug_init_vbar()
|
||||
void
|
||||
debug_init_vbar ()
|
||||
{
|
||||
printf("Vertical bars.\n");
|
||||
printf ("Vertical bars.\n");
|
||||
}
|
||||
|
||||
void debug_init_hbar()
|
||||
void
|
||||
debug_init_hbar ()
|
||||
{
|
||||
printf("Horizontal bars.\n");
|
||||
printf ("Horizontal bars.\n");
|
||||
}
|
||||
|
||||
void debug_init_num()
|
||||
void
|
||||
debug_init_num ()
|
||||
{
|
||||
printf("Big Numbers.\n");
|
||||
printf ("Big Numbers.\n");
|
||||
}
|
||||
|
||||
void debug_num(int x, int num)
|
||||
void
|
||||
debug_num (int x, int num)
|
||||
{
|
||||
printf("BigNum(%i, %i)\n", x, num);
|
||||
printf ("BigNum(%i, %i)\n", x, num);
|
||||
}
|
||||
|
||||
void debug_set_char(int n, char *dat)
|
||||
void
|
||||
debug_set_char (int n, char *dat)
|
||||
{
|
||||
printf("Set Character %i\n", n);
|
||||
printf ("Set Character %i\n", n);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void debug_vbar(int x, int len)
|
||||
void
|
||||
debug_vbar (int x, int len)
|
||||
{
|
||||
int y;
|
||||
int y;
|
||||
|
||||
printf("Vbar(%i, %i)\n", x, len);
|
||||
|
||||
printf ("Vbar(%i, %i)\n", x, len);
|
||||
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
debug_chr(x, y, '|');
|
||||
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
debug_chr (x, y, '|');
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void debug_hbar(int x, int y, int len)
|
||||
void
|
||||
debug_hbar (int x, int y, int len)
|
||||
{
|
||||
printf("Hbar(%i, %i, %i)\n", x, y, len);
|
||||
|
||||
|
||||
for(; x<lcd.wid && len>0; x++)
|
||||
{
|
||||
debug_chr(x,y,'-');
|
||||
|
||||
printf ("Hbar(%i, %i, %i)\n", x, y, len);
|
||||
|
||||
|
||||
for (; x < lcd.wid && len > 0; x++) {
|
||||
debug_chr (x, y, '-');
|
||||
|
||||
len -= lcd.cellwid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void debug_icon(int which, char dest)
|
||||
void
|
||||
debug_icon (int which, char dest)
|
||||
{
|
||||
printf("Char %i is icon %i\n", dest, which);
|
||||
printf ("Char %i is icon %i\n", dest, which);
|
||||
}
|
||||
|
||||
|
||||
void debug_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
debug_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
printf("Flush Box(%i, %i)-(%i, %i)\n", lft, top, rgt, bot);
|
||||
|
||||
printf ("Flush Box(%i, %i)-(%i, %i)\n", lft, top, rgt, bot);
|
||||
|
||||
|
||||
debug_flush ();
|
||||
|
||||
debug_flush();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void debug_draw_frame(char *dat)
|
||||
void
|
||||
debug_draw_frame (char *dat)
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
char out[LCD_MAX_WIDTH];
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
printf("draw_frame()\n");
|
||||
|
||||
printf ("draw_frame()\n");
|
||||
|
||||
if(!dat) return;
|
||||
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
// printf("Frame (%ix%i): \n%s\n", lcd.wid, lcd.hgt, dat);
|
||||
|
||||
for(i=0; i<lcd.wid; i++)
|
||||
{
|
||||
for (i = 0; i < lcd.wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("+%s+\n", out);
|
||||
|
||||
|
||||
for(i=0; i<lcd.hgt; i++)
|
||||
{
|
||||
for(j=0; j<lcd.wid; j++)
|
||||
{
|
||||
out[j] = dat[j+(i*lcd.wid)];
|
||||
}
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
|
||||
for (i = 0; i < lcd.hgt; i++) {
|
||||
for (j = 0; j < lcd.wid; j++) {
|
||||
out[j] = dat[j + (i * lcd.wid)];
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for(i=0; i<lcd.wid; i++)
|
||||
{
|
||||
printf ("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < lcd.wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("+%s+\n", out);
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char debug_getkey()
|
||||
char
|
||||
debug_getkey ()
|
||||
{
|
||||
printf("Trying to grab keypress.\n");
|
||||
return 0;
|
||||
printf ("Trying to grab keypress.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+19
-19
@@ -2,25 +2,25 @@
|
||||
#define LCD_DEBUG_H
|
||||
|
||||
|
||||
int debug_init(struct lcd_logical_driver *driver, char *args);
|
||||
void debug_close();
|
||||
void debug_clear();
|
||||
void debug_flush();
|
||||
void debug_string(int x, int y, char string[]);
|
||||
void debug_chr(int x, int y, char c);
|
||||
void debug_contrast(int contrast);
|
||||
void debug_backlight(int on);
|
||||
void debug_init_vbar();
|
||||
void debug_init_hbar();
|
||||
void debug_init_num();
|
||||
void debug_vbar(int x, int len);
|
||||
void debug_hbar(int x, int y, int len);
|
||||
void debug_num(int x, int num);
|
||||
void debug_set_char(int n, char *dat);
|
||||
void debug_icon(int which, char dest);
|
||||
void debug_flush_box(int lft, int top, int rgt, int bot);
|
||||
void debug_draw_frame(char *dat);
|
||||
char debug_getkey();
|
||||
int debug_init (struct lcd_logical_driver *driver, char *args);
|
||||
void debug_close ();
|
||||
void debug_clear ();
|
||||
void debug_flush ();
|
||||
void debug_string (int x, int y, char string[]);
|
||||
void debug_chr (int x, int y, char c);
|
||||
void debug_contrast (int contrast);
|
||||
void debug_backlight (int on);
|
||||
void debug_init_vbar ();
|
||||
void debug_init_hbar ();
|
||||
void debug_init_num ();
|
||||
void debug_vbar (int x, int len);
|
||||
void debug_hbar (int x, int y, int len);
|
||||
void debug_num (int x, int num);
|
||||
void debug_set_char (int n, char *dat);
|
||||
void debug_icon (int which, char dest);
|
||||
void debug_flush_box (int lft, int top, int rgt, int bot);
|
||||
void debug_draw_frame (char *dat);
|
||||
char debug_getkey ();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+115
-99
@@ -22,57 +22,57 @@ lcd_logical_driver *drv_base;
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int drv_base_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
drv_base_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
// printf("drv_base_init()\n");
|
||||
|
||||
drv_base = driver;
|
||||
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if(!driver->framebuf)
|
||||
driver->framebuf = malloc(driver->wid * driver->hgt);
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
drv_base_close();
|
||||
// You must use driver->framebuf here, but may use lcd.framebuf later.
|
||||
if (!driver->framebuf)
|
||||
driver->framebuf = malloc (driver->wid * driver->hgt);
|
||||
|
||||
if (!driver->framebuf) {
|
||||
drv_base_close ();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// Debugging...
|
||||
// if(lcd.framebuf) printf("Frame buffer: %i\n", (int)lcd.framebuf);
|
||||
|
||||
memset(driver->framebuf, ' ', driver->wid*driver->hgt);
|
||||
memset (driver->framebuf, ' ', driver->wid * driver->hgt);
|
||||
// drv_base_clear();
|
||||
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
driver->clear = drv_base_clear;
|
||||
driver->string = drv_base_string;
|
||||
driver->chr = drv_base_chr;
|
||||
driver->vbar = drv_base_vbar;
|
||||
driver->init_vbar = drv_base_init_vbar;
|
||||
driver->hbar = drv_base_hbar;
|
||||
driver->init_hbar = drv_base_init_hbar;
|
||||
driver->num = drv_base_num;
|
||||
driver->init_num = drv_base_init_num;
|
||||
|
||||
driver->init = drv_base_init;
|
||||
driver->close = drv_base_close;
|
||||
driver->flush = drv_base_flush;
|
||||
driver->flush_box = drv_base_flush_box;
|
||||
driver->contrast = drv_base_contrast;
|
||||
driver->backlight = drv_base_backlight;
|
||||
driver->set_char = drv_base_set_char;
|
||||
driver->icon = drv_base_icon;
|
||||
driver->draw_frame = drv_base_draw_frame;
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
driver->getkey = drv_base_getkey;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
driver->clear = drv_base_clear;
|
||||
driver->string = drv_base_string;
|
||||
driver->chr = drv_base_chr;
|
||||
driver->vbar = drv_base_vbar;
|
||||
driver->init_vbar = drv_base_init_vbar;
|
||||
driver->hbar = drv_base_hbar;
|
||||
driver->init_hbar = drv_base_init_hbar;
|
||||
driver->num = drv_base_num;
|
||||
driver->init_num = drv_base_init_num;
|
||||
|
||||
driver->init = drv_base_init;
|
||||
driver->close = drv_base_close;
|
||||
driver->flush = drv_base_flush;
|
||||
driver->flush_box = drv_base_flush_box;
|
||||
driver->contrast = drv_base_contrast;
|
||||
driver->backlight = drv_base_backlight;
|
||||
driver->set_char = drv_base_set_char;
|
||||
driver->icon = drv_base_icon;
|
||||
driver->draw_frame = drv_base_draw_frame;
|
||||
|
||||
driver->getkey = drv_base_getkey;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
|
||||
@@ -80,27 +80,31 @@ int drv_base_init(struct lcd_logical_driver *driver, char *args)
|
||||
// lcd.framebuf will be set to the appropriate buffer before calling
|
||||
// your driver.
|
||||
|
||||
void drv_base_close()
|
||||
void
|
||||
drv_base_close ()
|
||||
{
|
||||
if(lcd.framebuf != NULL) free(lcd.framebuf);
|
||||
if (lcd.framebuf != NULL)
|
||||
free (lcd.framebuf);
|
||||
|
||||
lcd.framebuf = NULL;
|
||||
lcd.framebuf = NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void drv_base_clear()
|
||||
void
|
||||
drv_base_clear ()
|
||||
{
|
||||
memset(lcd.framebuf, ' ', lcd.wid*lcd.hgt);
|
||||
|
||||
memset (lcd.framebuf, ' ', lcd.wid * lcd.hgt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void drv_base_flush()
|
||||
void
|
||||
drv_base_flush ()
|
||||
{
|
||||
//lcd.draw_frame(lcd.framebuf);
|
||||
}
|
||||
@@ -110,31 +114,33 @@ void drv_base_flush()
|
||||
// Prints a string on the lcd display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void drv_base_string(int x, int y, char string[])
|
||||
void
|
||||
drv_base_string (int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
// Check for buffer overflows...
|
||||
if((y*lcd.wid) + x + i > (lcd.wid*lcd.hgt)) break;
|
||||
lcd.framebuf[(y*lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
// Check for buffer overflows...
|
||||
if ((y * lcd.wid) + x + i > (lcd.wid * lcd.hgt))
|
||||
break;
|
||||
lcd.framebuf[(y * lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void drv_base_chr(int x, int y, char c)
|
||||
void
|
||||
drv_base_chr (int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y*lcd.wid) + x] = c;
|
||||
lcd.framebuf[(y * lcd.wid) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,33 +148,36 @@ void drv_base_chr(int x, int y, char c)
|
||||
// Sets the contrast of the display. Value is 0-255, where 140 is
|
||||
// what I consider "just right".
|
||||
//
|
||||
int drv_base_contrast(int contrast)
|
||||
int
|
||||
drv_base_contrast (int contrast)
|
||||
{
|
||||
// printf("Contrast: %i\n", contrast);
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Turns the lcd backlight on or off...
|
||||
//
|
||||
void drv_base_backlight(int on)
|
||||
void
|
||||
drv_base_backlight (int on)
|
||||
{
|
||||
/*
|
||||
if(on)
|
||||
{
|
||||
printf("Backlight ON\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Backlight OFF\n");
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if(on)
|
||||
{
|
||||
printf("Backlight ON\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Backlight OFF\n");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for vertical bargraphs.
|
||||
//
|
||||
void drv_base_init_vbar()
|
||||
void
|
||||
drv_base_init_vbar ()
|
||||
{
|
||||
// printf("Vertical bars.\n");
|
||||
}
|
||||
@@ -176,7 +185,8 @@ void drv_base_init_vbar()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for horizontal bargraphs.
|
||||
//
|
||||
void drv_base_init_hbar()
|
||||
void
|
||||
drv_base_init_hbar ()
|
||||
{
|
||||
// printf("Horizontal bars.\n");
|
||||
}
|
||||
@@ -184,7 +194,8 @@ void drv_base_init_hbar()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Tells the driver to get ready for big numbers, if possible.
|
||||
//
|
||||
void drv_base_init_num()
|
||||
void
|
||||
drv_base_init_num ()
|
||||
{
|
||||
// printf("Big Numbers.\n");
|
||||
}
|
||||
@@ -192,7 +203,8 @@ void drv_base_init_num()
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Draws a big (4-row) number.
|
||||
//
|
||||
void drv_base_num(int x, int num)
|
||||
void
|
||||
drv_base_num (int x, int num)
|
||||
{
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
}
|
||||
@@ -200,7 +212,8 @@ void drv_base_num(int x, int num)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Changes the font data of character n.
|
||||
//
|
||||
void drv_base_set_char(int n, char *dat)
|
||||
void
|
||||
drv_base_set_char (int n, char *dat)
|
||||
{
|
||||
// printf("Set Character %i\n", n);
|
||||
}
|
||||
@@ -208,37 +221,38 @@ void drv_base_set_char(int n, char *dat)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar, from the bottom of the screen up.
|
||||
//
|
||||
void drv_base_vbar(int x, int len)
|
||||
void
|
||||
drv_base_vbar (int x, int len)
|
||||
{
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
drv_base_chr(x, y, '|');
|
||||
int y;
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
drv_base_chr (x, y, '|');
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void drv_base_hbar(int x, int y, int len)
|
||||
void
|
||||
drv_base_hbar (int x, int y, int len)
|
||||
{
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
drv_base_chr(x,y,'-');
|
||||
|
||||
for (; x <= lcd.wid && len > 0; x++) {
|
||||
drv_base_chr (x, y, '-');
|
||||
|
||||
len -= lcd.cellwid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void drv_base_icon(int which, char dest)
|
||||
void
|
||||
drv_base_icon (int which, char dest)
|
||||
{
|
||||
// printf("Char %i set to icon %i\n", dest, which);
|
||||
}
|
||||
@@ -250,10 +264,11 @@ void drv_base_icon(int which, char dest)
|
||||
// I've just called drv_base_flush() because there's not much point yet
|
||||
// in flushing less than the entire framebuffer.
|
||||
//
|
||||
void drv_base_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
drv_base_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
//drv_base_flush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -261,7 +276,8 @@ void drv_base_flush_box(int lft, int top, int rgt, int bot)
|
||||
//
|
||||
// The commented-out code is from the text driver.
|
||||
//
|
||||
void drv_base_draw_frame(char *dat)
|
||||
void
|
||||
drv_base_draw_frame (char *dat)
|
||||
{
|
||||
/*
|
||||
int i, j;
|
||||
@@ -304,8 +320,8 @@ void drv_base_draw_frame(char *dat)
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char drv_base_getkey()
|
||||
char
|
||||
drv_base_getkey ()
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+20
-20
@@ -94,26 +94,26 @@
|
||||
|
||||
extern lcd_logical_driver *drv_base;
|
||||
|
||||
int drv_base_init(struct lcd_logical_driver *driver, char *args);
|
||||
void drv_base_close();
|
||||
void drv_base_clear();
|
||||
void drv_base_flush();
|
||||
void drv_base_string(int x, int y, char string[]);
|
||||
void drv_base_chr(int x, int y, char c);
|
||||
int drv_base_contrast(int contrast);
|
||||
void drv_base_backlight(int on);
|
||||
void drv_base_output(int on);
|
||||
void drv_base_vbar(int x, int len);
|
||||
void drv_base_init_vbar();
|
||||
void drv_base_hbar(int x, int y, int len);
|
||||
void drv_base_init_hbar();
|
||||
void drv_base_num(int x, int num);
|
||||
void drv_base_init_num();
|
||||
void drv_base_set_char(int n, char *dat);
|
||||
void drv_base_icon(int which, char dest);
|
||||
void drv_base_flush_box(int lft, int top, int rgt, int bot);
|
||||
void drv_base_draw_frame(char *dat);
|
||||
char drv_base_getkey();
|
||||
int drv_base_init (struct lcd_logical_driver *driver, char *args);
|
||||
void drv_base_close ();
|
||||
void drv_base_clear ();
|
||||
void drv_base_flush ();
|
||||
void drv_base_string (int x, int y, char string[]);
|
||||
void drv_base_chr (int x, int y, char c);
|
||||
int drv_base_contrast (int contrast);
|
||||
void drv_base_backlight (int on);
|
||||
void drv_base_output (int on);
|
||||
void drv_base_vbar (int x, int len);
|
||||
void drv_base_init_vbar ();
|
||||
void drv_base_hbar (int x, int y, int len);
|
||||
void drv_base_init_hbar ();
|
||||
void drv_base_num (int x, int num);
|
||||
void drv_base_init_num ();
|
||||
void drv_base_set_char (int n, char *dat);
|
||||
void drv_base_icon (int which, char dest);
|
||||
void drv_base_flush_box (int lft, int top, int rgt, int bot);
|
||||
void drv_base_draw_frame (char *dat);
|
||||
char drv_base_getkey ();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+100
-107
@@ -49,9 +49,7 @@
|
||||
// implemented separately for each HW design. This is typically just
|
||||
// HD44780_senddata
|
||||
|
||||
void lcdstat_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch);
|
||||
void lcdstat_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
|
||||
|
||||
#define RS 0x10
|
||||
@@ -61,136 +59,131 @@ void lcdstat_HD44780_senddata(unsigned char displayID,
|
||||
#define EN3 0x20
|
||||
|
||||
static unsigned char EnMask[] = { EN1, EN2, EN3, STRB, LF, INIT, SEL };
|
||||
static int EnMaskSize = sizeof(EnMask) / sizeof(unsigned char);
|
||||
static int EnMaskSize = sizeof (EnMask) / sizeof (unsigned char);
|
||||
|
||||
static unsigned int lptPort;
|
||||
static int extIF = 0; // non-zero if extended interface
|
||||
|
||||
// initialisation function
|
||||
int hd_init_4bit(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port)
|
||||
int
|
||||
hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
{
|
||||
// TODO: remove magic numbers below
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i;
|
||||
int displayID = EN1 | EN2;
|
||||
// TODO: remove magic numbers below
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i;
|
||||
int displayID = EN1 | EN2;
|
||||
|
||||
lptPort = port;
|
||||
lptPort = port;
|
||||
|
||||
hd44780_functions->senddata = lcdstat_HD44780_senddata;
|
||||
hd44780_functions->senddata = lcdstat_HD44780_senddata;
|
||||
|
||||
// parse command-line arguments
|
||||
argc = get_args(argv, args, 64);
|
||||
// parse command-line arguments
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
for (i = 0; i < argc; ++i)
|
||||
{
|
||||
if (strcmp(argv[i], "-e") == 0 ||
|
||||
strcmp(argv[i], "--extended") == 0)
|
||||
{
|
||||
extIF = 1;
|
||||
if ((ioperm(port + 2, 1, 255)) == -1) {
|
||||
fprintf(stderr, "HD44780_init: failed (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0) {
|
||||
extIF = 1;
|
||||
if ((ioperm (port + 2, 1, 255)) == -1) {
|
||||
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// powerup the lcd now
|
||||
if (extIF)
|
||||
{
|
||||
displayID |= EN3;
|
||||
port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
}
|
||||
|
||||
port_out(lptPort, displayID | 0x03);
|
||||
if (extIF) port_out(lptPort + 2,
|
||||
(EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort, 0x03);
|
||||
if (extIF) port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(4100);
|
||||
// powerup the lcd now
|
||||
if (extIF) {
|
||||
displayID |= EN3;
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
|
||||
port_out(lptPort, displayID | 0x03);
|
||||
if (extIF) port_out(lptPort + 2,
|
||||
(EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort, 0x03);
|
||||
if (extIF) port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(100);
|
||||
port_out (lptPort, displayID | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, (EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (4100);
|
||||
|
||||
port_out(lptPort, displayID | 0x03);
|
||||
if (extIF) port_out(lptPort + 2,
|
||||
(EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort, 0x03);
|
||||
if (extIF) port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(40);
|
||||
port_out (lptPort, displayID | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, (EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (100);
|
||||
|
||||
// now in 8-bit mode... set 4-bit mode
|
||||
port_out(lptPort,displayID | 0x02);
|
||||
if (extIF) port_out(lptPort + 2,
|
||||
(EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort, 0x02);
|
||||
if (extIF) port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause(40);
|
||||
port_out (lptPort, displayID | 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, (EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x03);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (40);
|
||||
|
||||
common_init(IF_4bit);
|
||||
return 0;
|
||||
// now in 8-bit mode... set 4-bit mode
|
||||
port_out (lptPort, displayID | 0x02);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, (EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6]) ^ OUTMASK);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort, 0x02);
|
||||
if (extIF)
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
hd44780_functions->uPause (40);
|
||||
|
||||
common_init (IF_4bit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// lcdstat_HD44780_senddata
|
||||
void lcdstat_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char iflags,
|
||||
unsigned char ch)
|
||||
void
|
||||
lcdstat_HD44780_senddata (unsigned char displayID, unsigned char iflags, unsigned char ch)
|
||||
{
|
||||
unsigned char dispID = 0, flags = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
unsigned char l = ch & 0x0f;
|
||||
unsigned char dispID = 0, flags = 0;
|
||||
unsigned char h = (ch >> 4) & 0x0f; // high and low nibbles
|
||||
unsigned char l = ch & 0x0f;
|
||||
|
||||
if (iflags == RS_INSTR)
|
||||
flags = 0;
|
||||
else //if (iflags == RS_DATA)
|
||||
flags = RS;
|
||||
if (iflags == RS_INSTR)
|
||||
flags = 0;
|
||||
else //if (iflags == RS_DATA)
|
||||
flags = RS;
|
||||
|
||||
if (displayID <= 3)
|
||||
{
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[0] | EnMask[1] | EnMask[2];
|
||||
else
|
||||
dispID = EnMask[displayID - 1];
|
||||
if (displayID <= 3) {
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[0] | EnMask[1] | EnMask[2];
|
||||
else
|
||||
dispID = EnMask[displayID - 1];
|
||||
|
||||
port_out(lptPort, flags | h);
|
||||
hd44780_functions->uPause(2);
|
||||
port_out(lptPort, dispID | flags | h);
|
||||
hd44780_functions->uPause(4);
|
||||
port_out(lptPort, flags | h);
|
||||
port_out (lptPort, flags | h);
|
||||
hd44780_functions->uPause (2);
|
||||
port_out (lptPort, dispID | flags | h);
|
||||
hd44780_functions->uPause (4);
|
||||
port_out (lptPort, flags | h);
|
||||
|
||||
port_out(lptPort, dispID | flags | l);
|
||||
hd44780_functions->uPause(4);
|
||||
port_out(lptPort, flags | l);
|
||||
}
|
||||
port_out (lptPort, dispID | flags | l);
|
||||
hd44780_functions->uPause (4);
|
||||
port_out (lptPort, flags | l);
|
||||
}
|
||||
|
||||
if (extIF && (displayID == 0 || displayID >= 4))
|
||||
{
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6];
|
||||
else
|
||||
dispID = EnMask[(displayID - 1) % EnMaskSize];
|
||||
if (extIF && (displayID == 0 || displayID >= 4)) {
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[3] | EnMask[4] | EnMask[5] | EnMask[6];
|
||||
else
|
||||
dispID = EnMask[(displayID - 1) % EnMaskSize];
|
||||
|
||||
port_out(lptPort, flags | h);
|
||||
hd44780_functions->uPause(2);
|
||||
port_out(lptPort + 2, dispID ^ OUTMASK);
|
||||
hd44780_functions->uPause(4);
|
||||
port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
port_out (lptPort, flags | h);
|
||||
hd44780_functions->uPause (2);
|
||||
port_out (lptPort + 2, dispID ^ OUTMASK);
|
||||
hd44780_functions->uPause (4);
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
|
||||
port_out(lptPort, flags | l);
|
||||
port_out(lptPort + 2, dispID ^ OUTMASK);
|
||||
hd44780_functions->uPause(4);
|
||||
port_out(lptPort + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
port_out (lptPort, flags | l);
|
||||
port_out (lptPort + 2, dispID ^ OUTMASK);
|
||||
hd44780_functions->uPause (4);
|
||||
port_out (lptPort + 2, 0 ^ OUTMASK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_4bit(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port);
|
||||
int hd_init_4bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,36 +18,30 @@
|
||||
// add new connection type header files here
|
||||
|
||||
enum connectionType { HD_4bit, HD_8bit, HD_serialLpt, HD_winamp,
|
||||
// add new connection types here
|
||||
// add new connection types here
|
||||
|
||||
HD_unknown };
|
||||
HD_unknown
|
||||
};
|
||||
|
||||
static struct ConnectionMapping
|
||||
{
|
||||
enum connectionType type;
|
||||
char *connectionTypeStr;
|
||||
int (*init_fn)(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port);
|
||||
const char *helpMsg;
|
||||
static struct ConnectionMapping {
|
||||
enum connectionType type;
|
||||
char *connectionTypeStr;
|
||||
int (*init_fn) (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
const char *helpMsg;
|
||||
} connectionMapping[] = {
|
||||
// connectionType enumerator
|
||||
// string to identify connection on command line
|
||||
// your initialisation function
|
||||
// help string for your particular connection
|
||||
{ HD_4bit, "4bit", hd_init_4bit,
|
||||
"\t-e\t--extended\tEnable three or more displays\n" },
|
||||
{ HD_8bit, "8bit", hd_init_ext8bit,
|
||||
"\tnone\n" },
|
||||
{ HD_serialLpt, "serialLpt", hd_init_serialLpt,
|
||||
"\tnone\n" },
|
||||
{ HD_winamp, "winamp", hd_init_winamp,
|
||||
"\t-e\t--extended\tEnable three or more displays\n" },
|
||||
// add new connection types and their string specifier here
|
||||
|
||||
// default, end of structure element (do not delete)
|
||||
{ HD_unknown, "", NULL, "" }
|
||||
// connectionType enumerator
|
||||
// string to identify connection on command line
|
||||
// your initialisation function
|
||||
// help string for your particular connection
|
||||
{
|
||||
HD_4bit, "4bit", hd_init_4bit, "\t-e\t--extended\tEnable three or more displays\n"}, {
|
||||
HD_8bit, "8bit", hd_init_ext8bit, "\tnone\n"}, {
|
||||
HD_serialLpt, "serialLpt", hd_init_serialLpt, "\tnone\n"}, {
|
||||
HD_winamp, "winamp", hd_init_winamp, "\t-e\t--extended\tEnable three or more displays\n"},
|
||||
// add new connection types and their string specifier here
|
||||
// default, end of structure element (do not delete)
|
||||
{
|
||||
HD_unknown, "", NULL, ""}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,9 +43,7 @@
|
||||
// restricted to):
|
||||
// HD44780_senddata
|
||||
|
||||
void lcdtime_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch);
|
||||
void lcdtime_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
|
||||
|
||||
#define nRS nSTRB
|
||||
@@ -62,48 +60,45 @@ static int semid;
|
||||
|
||||
|
||||
// initialise the driver
|
||||
int hd_init_ext8bit(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port)
|
||||
int
|
||||
hd_init_ext8bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
{
|
||||
lptPort = port;
|
||||
semid = sem_get();
|
||||
lptPort = port;
|
||||
semid = sem_get ();
|
||||
|
||||
hd44780_functions->senddata = lcdtime_HD44780_senddata;
|
||||
hd44780_functions->senddata = lcdtime_HD44780_senddata;
|
||||
|
||||
if ((ioperm(port + 2, 1, 255)) == -1) {
|
||||
fprintf(stderr, "HD44780_init: failed (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if ((ioperm (port + 2, 1, 255)) == -1) {
|
||||
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
common_init(IF_8bit);
|
||||
return 0;
|
||||
common_init (IF_8bit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// lcdtime_HD44780_senddata
|
||||
void lcdtime_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch)
|
||||
void
|
||||
lcdtime_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char dispID = 0, portControl;
|
||||
unsigned char dispID = 0, portControl;
|
||||
|
||||
if (displayID == 1)
|
||||
dispID |= EN1;
|
||||
else //if (displayID == 0)
|
||||
dispID |= EN1;
|
||||
if (displayID == 1)
|
||||
dispID |= EN1;
|
||||
else //if (displayID == 0)
|
||||
dispID |= EN1;
|
||||
|
||||
if (flags == RS_DATA)
|
||||
portControl = CHAR;
|
||||
else
|
||||
portControl = CTRL;
|
||||
if (flags == RS_DATA)
|
||||
portControl = CHAR;
|
||||
else
|
||||
portControl = CTRL;
|
||||
|
||||
sem_wait(semid);
|
||||
port_out(lptPort + 2, SETUPLCD);
|
||||
port_out(lptPort, ch);
|
||||
port_out(lptPort + 2, dispID | portControl);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort + 2, portControl);
|
||||
sem_signal(semid);
|
||||
sem_wait (semid);
|
||||
port_out (lptPort + 2, SETUPLCD);
|
||||
port_out (lptPort, ch);
|
||||
port_out (lptPort + 2, dispID | portControl);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, portControl);
|
||||
sem_signal (semid);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_ext8bit(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port);
|
||||
int hd_init_ext8bit (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,29 +6,28 @@
|
||||
|
||||
enum ifWidth { IF_4bit, IF_8bit };
|
||||
|
||||
void common_init(enum ifWidth ifwidth);
|
||||
void common_init (enum ifWidth ifwidth);
|
||||
|
||||
// Structures holding pointers to HD44780 specific functions
|
||||
typedef struct hwDependentFns
|
||||
{
|
||||
// microsec pauses
|
||||
void (*uPause)(int microSecondsTenths);
|
||||
typedef struct hwDependentFns {
|
||||
// microsec pauses
|
||||
void (*uPause) (int microSecondsTenths);
|
||||
|
||||
// senddata to the LCD
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// flags - data or instruction command (RS_DATA | RS_INSTR)
|
||||
// ch - character to display or instruction value
|
||||
void (*senddata)(unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
// senddata to the LCD
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// flags - data or instruction command (RS_DATA | RS_INSTR)
|
||||
// ch - character to display or instruction value
|
||||
void (*senddata) (unsigned char dispID, unsigned char flags, unsigned char ch);
|
||||
|
||||
// position the cursor
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// DDaddr - display data address (see sect 2.5.2 of the LCD module FAQ)
|
||||
void (*position)(int dispID, int DDaddr);
|
||||
// position the cursor
|
||||
// dispID - display to send data to (0 = all displays)
|
||||
// DDaddr - display data address (see sect 2.5.2 of the LCD module FAQ)
|
||||
void (*position) (int dispID, int DDaddr);
|
||||
|
||||
// toggle vertical autoscroll on all displays
|
||||
// on - non-zero turns autoscroll on, zero value turns it off
|
||||
void (*autoscroll)(int on);
|
||||
} HD44780_functions; /* for want of a better name :-) */
|
||||
// toggle vertical autoscroll on all displays
|
||||
// on - non-zero turns autoscroll on, zero value turns it off
|
||||
void (*autoscroll) (int on);
|
||||
} HD44780_functions; /* for want of a better name :-) */
|
||||
|
||||
extern HD44780_functions *hd44780_functions;
|
||||
|
||||
@@ -42,32 +41,32 @@ extern HD44780_functions *hd44780_functions;
|
||||
#define HOMECURSOR 0x02
|
||||
|
||||
#define ENTRYMODE 0x04
|
||||
#define E_MOVERIGHT 0x02
|
||||
#define E_MOVELEFT 0x00
|
||||
#define EDGESCROLL 0x01
|
||||
#define NOSCROLL 0x00
|
||||
#define E_MOVERIGHT 0x02
|
||||
#define E_MOVELEFT 0x00
|
||||
#define EDGESCROLL 0x01
|
||||
#define NOSCROLL 0x00
|
||||
|
||||
#define ONOFFCTRL 0x08
|
||||
#define DISPON 0x04
|
||||
#define DISPOFF 0x00
|
||||
#define CURSORON 0x02
|
||||
#define CURSOROFF 0x00
|
||||
#define CURSORBLINK 0x01
|
||||
#define CURSORNOBLINK 0x00
|
||||
#define DISPON 0x04
|
||||
#define DISPOFF 0x00
|
||||
#define CURSORON 0x02
|
||||
#define CURSOROFF 0x00
|
||||
#define CURSORBLINK 0x01
|
||||
#define CURSORNOBLINK 0x00
|
||||
|
||||
#define CURSORSHIFT 0x10
|
||||
#define SCROLLDISP 0x08
|
||||
#define MOVECURSOR 0x00
|
||||
#define MOVERIGHT 0x04
|
||||
#define MOVELEFT 0x00
|
||||
#define SCROLLDISP 0x08
|
||||
#define MOVECURSOR 0x00
|
||||
#define MOVERIGHT 0x04
|
||||
#define MOVELEFT 0x00
|
||||
|
||||
#define FUNCSET 0x20
|
||||
#define IF_8BIT 0x10
|
||||
#define IF_4BIT 0x00
|
||||
#define TWOLINE 0x08
|
||||
#define ONELINE 0x00
|
||||
#define LARGECHAR 0x04 /* 5x11 characters */
|
||||
#define SMALLCHAR 0x00 /* 5x8 characters */
|
||||
#define IF_8BIT 0x10
|
||||
#define IF_4BIT 0x00
|
||||
#define TWOLINE 0x08
|
||||
#define ONELINE 0x00
|
||||
#define LARGECHAR 0x04 /* 5x11 characters */
|
||||
#define SMALLCHAR 0x00 /* 5x8 characters */
|
||||
|
||||
#define SETCHAR 0x40
|
||||
|
||||
@@ -76,11 +75,11 @@ extern HD44780_functions *hd44780_functions;
|
||||
|
||||
// Parallel port pin definitions
|
||||
// Output lines
|
||||
#define nSTRB 0x01 /* negative logic */
|
||||
#define nSTRB 0x01 /* negative logic */
|
||||
#define STRB 0x01
|
||||
#define nLF 0x02
|
||||
#define LF 0x02
|
||||
#define INIT 0x04 /* the only positive logic output line */
|
||||
#define INIT 0x04 /* the only positive logic output line */
|
||||
#define nSEL 0x08
|
||||
#define SEL 0x08
|
||||
|
||||
@@ -98,5 +97,3 @@ extern HD44780_functions *hd44780_functions;
|
||||
#define INMASK 0x48
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -31,13 +31,11 @@
|
||||
#include "port.h"
|
||||
|
||||
// Hardware specific functions
|
||||
void lcdserLpt_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch);
|
||||
void lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
|
||||
static char lcdserLpt_HD44780_getkey(void);
|
||||
void rawshift(unsigned char r);
|
||||
void shiftreg(unsigned char displayID, unsigned char r);
|
||||
static char lcdserLpt_HD44780_getkey (void);
|
||||
void rawshift (unsigned char r);
|
||||
void shiftreg (unsigned char displayID, unsigned char r);
|
||||
|
||||
#define RS 16
|
||||
#define LCDDATA 8
|
||||
@@ -47,127 +45,118 @@ void shiftreg(unsigned char displayID, unsigned char r);
|
||||
|
||||
|
||||
static unsigned int lp;
|
||||
static char lastkey=0;
|
||||
static char lastkey = 0;
|
||||
|
||||
|
||||
// Initialisation
|
||||
int hd_init_serialLpt(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port)
|
||||
int
|
||||
hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
{
|
||||
int displayID = EN1 | EN2;
|
||||
int displayID = EN1 | EN2;
|
||||
|
||||
lp = port;
|
||||
lp = port;
|
||||
|
||||
hd44780_functions->senddata = lcdserLpt_HD44780_senddata;
|
||||
hd44780_functions->senddata = lcdserLpt_HD44780_senddata;
|
||||
|
||||
// TODO: enable keypad only if specified on command line
|
||||
driver->getkey = lcdserLpt_HD44780_getkey;
|
||||
// TODO: enable keypad only if specified on command line
|
||||
driver->getkey = lcdserLpt_HD44780_getkey;
|
||||
|
||||
// setup the lcd in 4 bit mode
|
||||
shiftreg(displayID,3);
|
||||
hd44780_functions->uPause(4100);
|
||||
// setup the lcd in 4 bit mode
|
||||
shiftreg (displayID, 3);
|
||||
hd44780_functions->uPause (4100);
|
||||
|
||||
shiftreg(displayID,3);
|
||||
hd44780_functions->uPause(100);
|
||||
shiftreg (displayID, 3);
|
||||
hd44780_functions->uPause (100);
|
||||
|
||||
shiftreg(displayID,3);
|
||||
hd44780_functions->uPause(40);
|
||||
shiftreg (displayID, 3);
|
||||
hd44780_functions->uPause (40);
|
||||
|
||||
shiftreg(displayID,2);
|
||||
hd44780_functions->uPause(40);
|
||||
shiftreg (displayID, 2);
|
||||
hd44780_functions->uPause (40);
|
||||
|
||||
// set display type functions
|
||||
lcdserLpt_HD44780_senddata(0,
|
||||
RS_INSTR,
|
||||
FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
// clear
|
||||
lcdserLpt_HD44780_senddata(0, RS_INSTR, CLEAR);
|
||||
hd44780_functions->uPause(1600);
|
||||
// Now turn on the display
|
||||
lcdserLpt_HD44780_senddata(displayID,
|
||||
RS_INSTR,
|
||||
ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK);
|
||||
hd44780_functions->uPause(1600);
|
||||
// set display type functions
|
||||
lcdserLpt_HD44780_senddata (0, RS_INSTR, FUNCSET | IF_4BIT | TWOLINE | SMALLCHAR);
|
||||
// clear
|
||||
lcdserLpt_HD44780_senddata (0, RS_INSTR, CLEAR);
|
||||
hd44780_functions->uPause (1600);
|
||||
// Now turn on the display
|
||||
lcdserLpt_HD44780_senddata (displayID, RS_INSTR, ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK);
|
||||
hd44780_functions->uPause (1600);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void lcdserLpt_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch)
|
||||
void
|
||||
lcdserLpt_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char dispID = 0,
|
||||
portControl = 0,
|
||||
h = ch >> 4,
|
||||
l = ch & 15;
|
||||
unsigned char dispID = 0, portControl = 0, h = ch >> 4, l = ch & 15;
|
||||
|
||||
if (displayID == 1)
|
||||
dispID |= EN1;
|
||||
else if (displayID == 2)
|
||||
dispID |= EN2;
|
||||
else
|
||||
dispID |= EN1 | EN2;
|
||||
if (displayID == 1)
|
||||
dispID |= EN1;
|
||||
else if (displayID == 2)
|
||||
dispID |= EN2;
|
||||
else
|
||||
dispID |= EN1 | EN2;
|
||||
|
||||
if (flags == RS_DATA)
|
||||
portControl = RS;
|
||||
else
|
||||
portControl = 0;
|
||||
if (flags == RS_DATA)
|
||||
portControl = RS;
|
||||
else
|
||||
portControl = 0;
|
||||
|
||||
shiftreg(displayID,flags | portControl | h);
|
||||
shiftreg(displayID,flags | portControl | l);
|
||||
shiftreg (displayID, flags | portControl | h);
|
||||
shiftreg (displayID, flags | portControl | l);
|
||||
|
||||
/* TODO: instead of delay read keys here */
|
||||
/* TODO: instead of delay read keys here */
|
||||
}
|
||||
|
||||
char lcdserLpt_HD44780_getkey()
|
||||
char
|
||||
lcdserLpt_HD44780_getkey ()
|
||||
{
|
||||
// TODO: a keypad scan that does not use shift register
|
||||
// define a key table
|
||||
char keytr[]="ABCDEFGH";
|
||||
int n;
|
||||
// TODO: a keypad scan that does not use shift register
|
||||
// define a key table
|
||||
char keytr[] = "ABCDEFGH";
|
||||
int n;
|
||||
|
||||
rawshift(0); //send all line on shift register low
|
||||
hd44780_functions->uPause(1);
|
||||
if ((port_in(lp+1)&32)==0) //test if line back is low - if not return(0)
|
||||
{ //else
|
||||
//start walking a single zero across the eight lines
|
||||
for(n=7;n>=0;n--)
|
||||
{
|
||||
rawshift(255 - (1<<n));
|
||||
hd44780_functions->uPause(1);
|
||||
|
||||
if ((port_in(lp+1)&32)==0) // check if line back is low if yes debounce
|
||||
{
|
||||
if (lastkey==keytr[n])
|
||||
return(0);
|
||||
// printf("key is %c %d\n",keytr[n],n);
|
||||
lastkey=keytr[n];
|
||||
return(keytr[n]); //return correct key code.
|
||||
rawshift (0); //send all line on shift register low
|
||||
hd44780_functions->uPause (1);
|
||||
if ((port_in (lp + 1) & 32) == 0) //test if line back is low - if not return(0)
|
||||
{ //else
|
||||
//start walking a single zero across the eight lines
|
||||
for (n = 7; n >= 0; n--) {
|
||||
rawshift (255 - (1 << n));
|
||||
hd44780_functions->uPause (1);
|
||||
|
||||
if ((port_in (lp + 1) & 32) == 0) // check if line back is low if yes debounce
|
||||
{
|
||||
if (lastkey == keytr[n])
|
||||
return (0);
|
||||
// printf("key is %c %d\n",keytr[n],n);
|
||||
lastkey = keytr[n];
|
||||
return (keytr[n]); //return correct key code.
|
||||
}
|
||||
}
|
||||
}
|
||||
} //else fall out and return(0) [too transient a keypress]
|
||||
lastkey=0;
|
||||
return(0);
|
||||
} //else fall out and return(0) [too transient a keypress]
|
||||
lastkey = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* this function sends r out onto the shift register */
|
||||
void rawshift (unsigned char r)
|
||||
void
|
||||
rawshift (unsigned char r)
|
||||
{
|
||||
int i;
|
||||
for (i=7;i>=0;i--) /* MSB first */
|
||||
{
|
||||
port_out(lp,((r>>i)&1)*LCDDATA); /*set up data */
|
||||
port_out(lp,(((r>>i)&1)*LCDDATA)|LCDCLOCK);/*rising edge of clock */
|
||||
}
|
||||
int i;
|
||||
for (i = 7; i >= 0; i--) { /* MSB first */
|
||||
port_out (lp, ((r >> i) & 1) * LCDDATA); /*set up data */
|
||||
port_out (lp, (((r >> i) & 1) * LCDDATA) | LCDCLOCK); /*rising edge of clock */
|
||||
}
|
||||
}
|
||||
|
||||
// displayID = value on parallel port to toggle the correct display
|
||||
void shiftreg (unsigned char displayID, unsigned char r)
|
||||
{
|
||||
rawshift(r);
|
||||
port_out(lp,displayID); //latch it, to correct display
|
||||
port_out(lp,0);
|
||||
void
|
||||
shiftreg (unsigned char displayID, unsigned char r)
|
||||
{
|
||||
rawshift (r);
|
||||
port_out (lp, displayID); //latch it, to correct display
|
||||
port_out (lp, 0);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#ifndef HD_SERIALLPT_H
|
||||
#define HD_SERIALLPT_H
|
||||
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
#include "lcd.h" /* for lcd_logical_driver */
|
||||
#include "hd44780-low.h" /* for HD44780_functions */
|
||||
|
||||
// initialise this particular driver
|
||||
int hd_init_serialLpt(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port);
|
||||
int hd_init_serialLpt (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
void lcdwinamp_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch);
|
||||
void lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch);
|
||||
|
||||
#define EN1 STRB
|
||||
#define EN2 SEL
|
||||
@@ -46,64 +44,59 @@ void lcdwinamp_HD44780_senddata(unsigned char displayID,
|
||||
#define RS INIT
|
||||
|
||||
static unsigned char EnMask[] = { EN1, EN2, EN3 };
|
||||
static int EnMaskSize = sizeof(EnMask) / sizeof(unsigned char);
|
||||
static int EnMaskSize = sizeof (EnMask) / sizeof (unsigned char);
|
||||
|
||||
static unsigned int lptPort;
|
||||
static int extIF = 0; // non-zero if extended interface
|
||||
|
||||
|
||||
// initialise the driver
|
||||
int hd_init_winamp(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port)
|
||||
int
|
||||
hd_init_winamp (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port)
|
||||
{
|
||||
// TODO: remove magic numbers below
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i;
|
||||
|
||||
hd44780_functions->senddata = lcdwinamp_HD44780_senddata;
|
||||
lptPort = port;
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i;
|
||||
|
||||
// parse command-line arguments
|
||||
argc = get_args(argv, args, 64);
|
||||
hd44780_functions->senddata = lcdwinamp_HD44780_senddata;
|
||||
lptPort = port;
|
||||
|
||||
for (i = 0; i < argc; ++i)
|
||||
if (strcmp(argv[i], "-e") == 0 ||
|
||||
strcmp(argv[i], "--extended") == 0)
|
||||
extIF = 1;
|
||||
// parse command-line arguments
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
if ((ioperm(lptPort + 2, 1, 255)) == -1) {
|
||||
fprintf(stderr, "HD44780_init: failed (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < argc; ++i)
|
||||
if (strcmp (argv[i], "-e") == 0 || strcmp (argv[i], "--extended") == 0)
|
||||
extIF = 1;
|
||||
|
||||
common_init(IF_8bit);
|
||||
return 0;
|
||||
if ((ioperm (lptPort + 2, 1, 255)) == -1) {
|
||||
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
common_init (IF_8bit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// lcdwinamp_HD44780_senddata
|
||||
void lcdwinamp_HD44780_senddata(unsigned char displayID,
|
||||
unsigned char flags,
|
||||
unsigned char ch)
|
||||
void
|
||||
lcdwinamp_HD44780_senddata (unsigned char displayID, unsigned char flags, unsigned char ch)
|
||||
{
|
||||
unsigned char dispID = 0, portControl;
|
||||
unsigned char dispID = 0, portControl;
|
||||
|
||||
if (flags == RS_DATA)
|
||||
portControl = RS;
|
||||
else
|
||||
portControl = 0;
|
||||
if (flags == RS_DATA)
|
||||
portControl = RS;
|
||||
else
|
||||
portControl = 0;
|
||||
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[0] | EnMask [1] | ((extIF) ? EnMask[2] : 0);
|
||||
else
|
||||
dispID = EnMask[displayID - 1];
|
||||
|
||||
port_out(lptPort, ch);
|
||||
port_out(lptPort + 2, (dispID | portControl) ^ OUTMASK);
|
||||
hd44780_functions->uPause(1);
|
||||
port_out(lptPort + 2, portControl ^ OUTMASK);
|
||||
if (displayID == 0)
|
||||
dispID = EnMask[0] | EnMask[1] | ((extIF) ? EnMask[2] : 0);
|
||||
else
|
||||
dispID = EnMask[displayID - 1];
|
||||
|
||||
port_out (lptPort, ch);
|
||||
port_out (lptPort + 2, (dispID | portControl) ^ OUTMASK);
|
||||
hd44780_functions->uPause (1);
|
||||
port_out (lptPort + 2, portControl ^ OUTMASK);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
|
||||
// initialise this particular driver, args is probably not used but keep
|
||||
// for consistency
|
||||
int hd_init_winamp(HD44780_functions *hd44780_functions,
|
||||
lcd_logical_driver *driver,
|
||||
char *args,
|
||||
unsigned int port);
|
||||
int hd_init_winamp (HD44780_functions * hd44780_functions, lcd_logical_driver * driver, char *args, unsigned int port);
|
||||
|
||||
#endif
|
||||
|
||||
+508
-561
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "port.h"
|
||||
|
||||
int HD44780_init(struct lcd_logical_driver *driver, char *args);
|
||||
int HD44780_init (struct lcd_logical_driver *driver, char *args);
|
||||
/* The following methods can all be hidden. They are used through function ptrs
|
||||
void HD44780_close();
|
||||
void HD44780_flush();
|
||||
|
||||
+97
-109
@@ -32,34 +32,34 @@
|
||||
char *progname = "irmanin";
|
||||
|
||||
char *codes[] = {
|
||||
/* dummy */ NULL,
|
||||
/* KeyToLcd */ "lcdproc-A",
|
||||
/* KeyToLcd */ "lcdproc-B",
|
||||
/* KeyToLcd */ "lcdproc-C",
|
||||
/* KeyToLcd */ "lcdproc-D",
|
||||
/* KeyToLcd */ "lcdproc-E",
|
||||
/* KeyToLcd */ "lcdproc-F",
|
||||
/* KeyToLcd */ "lcdproc-G",
|
||||
/* KeyToLcd */ "lcdproc-H",
|
||||
/* KeyToLcd */ "lcdproc-I",
|
||||
/* KeyToLcd */ "lcdproc-J",
|
||||
/* KeyToLcd */ "lcdproc-K",
|
||||
/* KeyToLcd */ "lcdproc-L",
|
||||
/* KeyToLcd */ "lcdproc-M",
|
||||
/* KeyToLcd */ "lcdproc-N",
|
||||
/* KeyToLcd */ "lcdproc-O",
|
||||
/* KeyToLcd */ "lcdproc-P",
|
||||
/* KeyToLcd */ "lcdproc-Q",
|
||||
/* KeyToLcd */ "lcdproc-R",
|
||||
/* KeyToLcd */ "lcdproc-S",
|
||||
/* KeyToLcd */ "lcdproc-T",
|
||||
/* KeyToLcd */ "lcdproc-U",
|
||||
/* KeyToLcd */ "lcdproc-V",
|
||||
/* KeyToLcd */ "lcdproc-W",
|
||||
/* KeyToLcd */ "lcdproc-X",
|
||||
/* KeyToLcd */ "lcdproc-Y",
|
||||
/* KeyToLcd */ "lcdproc-Z",
|
||||
/* end */ NULL
|
||||
/* dummy */ NULL,
|
||||
/* KeyToLcd */ "lcdproc-A",
|
||||
/* KeyToLcd */ "lcdproc-B",
|
||||
/* KeyToLcd */ "lcdproc-C",
|
||||
/* KeyToLcd */ "lcdproc-D",
|
||||
/* KeyToLcd */ "lcdproc-E",
|
||||
/* KeyToLcd */ "lcdproc-F",
|
||||
/* KeyToLcd */ "lcdproc-G",
|
||||
/* KeyToLcd */ "lcdproc-H",
|
||||
/* KeyToLcd */ "lcdproc-I",
|
||||
/* KeyToLcd */ "lcdproc-J",
|
||||
/* KeyToLcd */ "lcdproc-K",
|
||||
/* KeyToLcd */ "lcdproc-L",
|
||||
/* KeyToLcd */ "lcdproc-M",
|
||||
/* KeyToLcd */ "lcdproc-N",
|
||||
/* KeyToLcd */ "lcdproc-O",
|
||||
/* KeyToLcd */ "lcdproc-P",
|
||||
/* KeyToLcd */ "lcdproc-Q",
|
||||
/* KeyToLcd */ "lcdproc-R",
|
||||
/* KeyToLcd */ "lcdproc-S",
|
||||
/* KeyToLcd */ "lcdproc-T",
|
||||
/* KeyToLcd */ "lcdproc-U",
|
||||
/* KeyToLcd */ "lcdproc-V",
|
||||
/* KeyToLcd */ "lcdproc-W",
|
||||
/* KeyToLcd */ "lcdproc-X",
|
||||
/* KeyToLcd */ "lcdproc-Y",
|
||||
/* KeyToLcd */ "lcdproc-Z",
|
||||
/* end */ NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ lcd_logical_driver *irmanin;
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int irmanin_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
irmanin_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
char device[256];
|
||||
char *ptrdevice;
|
||||
@@ -93,99 +94,85 @@ int irmanin_init(struct lcd_logical_driver *driver, char *args)
|
||||
int argc, i, j;
|
||||
char *filename;
|
||||
|
||||
ptrconfig=NULL;
|
||||
ptrdevice=NULL;
|
||||
|
||||
ptrconfig = NULL;
|
||||
ptrdevice = NULL;
|
||||
|
||||
irmanin = driver;
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
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, "irmanin_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "irmanin_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strcpy(device, argv[++i]);
|
||||
ptrdevice=device;
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-c") ||
|
||||
0 == strcmp(argv[i], "--config"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "irmanin_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
strcpy (device, argv[++i]);
|
||||
ptrdevice = device;
|
||||
} else if (0 == strcmp (argv[i], "-c") || 0 == strcmp (argv[i], "--config")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "irmanin_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strcpy(config, argv[++i]);
|
||||
ptrconfig=config;
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-h") ||
|
||||
0 == strcmp(argv[i], "--help"))
|
||||
{
|
||||
printf("LCDproc IrMan input driver\n"
|
||||
"\t-d\t--device\tSelect the input device to use\n"
|
||||
"\t-d\t--config\tSelect the configuration file to use\n"
|
||||
"\t-h\t--help\t\tShow this help information\n");
|
||||
strcpy (config, argv[++i]);
|
||||
ptrconfig = config;
|
||||
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
|
||||
printf ("LCDproc IrMan input driver\n" "\t-d\t--device\tSelect the input device to use\n" "\t-d\t--config\tSelect the configuration file to use\n" "\t-h\t--help\t\tShow this help information\n");
|
||||
return -1;
|
||||
} else {
|
||||
printf ("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ir_init_commands(ptrconfig, 1) < 0) {
|
||||
fprintf(stderr, "error initialising commands: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
portname = ir_default_portname();
|
||||
if(portname==NULL){
|
||||
if(ptrdevice==NULL){
|
||||
portname=ptrdevice;
|
||||
}else{
|
||||
fprintf(stderr, "error no device defined\n");
|
||||
exit(1);
|
||||
}
|
||||
if (ir_init_commands (ptrconfig, 1) < 0) {
|
||||
fprintf (stderr, "error initialising commands: %s\n", strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
portname = ir_default_portname ();
|
||||
if (portname == NULL) {
|
||||
if (ptrdevice == NULL) {
|
||||
portname = ptrdevice;
|
||||
} else {
|
||||
fprintf (stderr, "error no device defined\n");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
driver->getkey = irmanin_getkey;
|
||||
driver->close = irmanin_close;
|
||||
|
||||
for (i=1; codes[i] != NULL; i++) {
|
||||
if (ir_register_command(codes[i], i) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stderr, "%s: no code set for `%s'\n", progname, codes[i]);
|
||||
} else {
|
||||
fprintf(stderr, "error registering `%s': `%s'\n", codes[i], strerror(errno));
|
||||
}
|
||||
}
|
||||
for (i = 1; codes[i] != NULL; i++) {
|
||||
if (ir_register_command (codes[i], i) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
fprintf (stderr, "%s: no code set for `%s'\n", progname, codes[i]);
|
||||
} else {
|
||||
fprintf (stderr, "error registering `%s': `%s'\n", codes[i], strerror (errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if (ir_init(portname) < 0) {
|
||||
fprintf(stderr, "%s: error initialising Irman: `%s'\n", strerror(errno), portname);
|
||||
exit(1);
|
||||
errno = 0;
|
||||
if (ir_init (portname) < 0) {
|
||||
fprintf (stderr, "%s: error initialising Irman: `%s'\n", strerror (errno), portname);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return 1; // 200 is arbitrary. (must be 1 or more)
|
||||
return 1; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
|
||||
void irmanin_close()
|
||||
void
|
||||
irmanin_close ()
|
||||
{
|
||||
if(irmanin->framebuf != NULL) free(irmanin->framebuf);
|
||||
|
||||
irmanin->framebuf = NULL;
|
||||
if (irmanin->framebuf != NULL)
|
||||
free (irmanin->framebuf);
|
||||
|
||||
ir_free_commands();
|
||||
ir_finish();
|
||||
irmanin->framebuf = NULL;
|
||||
|
||||
ir_free_commands ();
|
||||
ir_finish ();
|
||||
}
|
||||
|
||||
|
||||
@@ -194,25 +181,26 @@ void irmanin_close()
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char irmanin_getkey()
|
||||
char
|
||||
irmanin_getkey ()
|
||||
{
|
||||
int i;
|
||||
int cmd;
|
||||
char key;
|
||||
int i;
|
||||
int cmd;
|
||||
char key;
|
||||
|
||||
key=(char)0;
|
||||
switch (cmd=ir_poll_command()) {
|
||||
case IR_CMD_ERROR:
|
||||
fprintf(stderr, "%s: error reading command: %s\n", progname, strerror(errno));
|
||||
key = (char) 0;
|
||||
switch (cmd = ir_poll_command ()) {
|
||||
case IR_CMD_ERROR:
|
||||
fprintf (stderr, "%s: error reading command: %s\n", progname, strerror (errno));
|
||||
break;
|
||||
case IR_CMD_UNKNOWN:
|
||||
case IR_CMD_UNKNOWN:
|
||||
break;
|
||||
default:
|
||||
key=(char)('A'-1+cmd);
|
||||
default:
|
||||
key = (char) ('A' - 1 + cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
return key;
|
||||
}
|
||||
|
||||
/* end of irmanin.c */
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
extern lcd_logical_driver *joy;
|
||||
|
||||
int irmanin_init(struct lcd_logical_driver *driver, char *args);
|
||||
void irmanin_close();
|
||||
char irmanin_getkey();
|
||||
int irmanin_init (struct lcd_logical_driver *driver, char *args);
|
||||
void irmanin_close ();
|
||||
char irmanin_getkey ();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+85
-102
@@ -46,125 +46,105 @@ int *button;
|
||||
|
||||
|
||||
// Configured for a Gravis Gamepad (2 axis, 4 button)
|
||||
char *axismap = "EFGHIJKLMNOPQRST";
|
||||
char *axismap = "EFGHIJKLMNOPQRST";
|
||||
char *buttonmap = "BDACEFGHIJKLMNOP";
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int joy_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
joy_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
char device[256];
|
||||
char *argv[64];
|
||||
int argc, i, j;
|
||||
|
||||
|
||||
joy = driver;
|
||||
|
||||
|
||||
strcpy(device, "/dev/js0");
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
strcpy (device, "/dev/js0");
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
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, "joy_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-a") ||
|
||||
0 == strcmp(argv[i], "--axes"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "joy_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
strcpy (device, argv[++i]);
|
||||
} else if (0 == strcmp (argv[i], "-a") || 0 == strcmp (argv[i], "--axes")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strncpy(axismap, argv[++i], 16);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-b") ||
|
||||
0 == strcmp(argv[i], "--buttons"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "joy_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
strncpy (axismap, argv[++i], 16);
|
||||
} else if (0 == strcmp (argv[i], "-b") || 0 == strcmp (argv[i], "--buttons")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "joy_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strncpy(buttonmap, argv[++i], 16);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-h") ||
|
||||
0 == strcmp(argv[i], "--help"))
|
||||
{
|
||||
printf("LCDproc Joystick input driver\n"
|
||||
"\t-d\t--device\tSelect the input device to use [/dev/js0]\n"
|
||||
"\t-a\t--axes\t\tModify the axis map [%s]\n"
|
||||
"\t-b\t--buttons\tModify the button map [%s]\n"
|
||||
"\t-h\t--help\t\tShow this help information\n",
|
||||
axismap, buttonmap);
|
||||
strncpy (buttonmap, argv[++i], 16);
|
||||
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
|
||||
printf ("LCDproc Joystick input driver\n" "\t-d\t--device\tSelect the input device to use [/dev/js0]\n" "\t-a\t--axes\t\tModify the axis map [%s]\n" "\t-b\t--buttons\tModify the button map [%s]\n" "\t-h\t--help\t\tShow this help information\n", axismap, buttonmap);
|
||||
return -1;
|
||||
} else {
|
||||
printf ("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
driver->getkey = joy_getkey;
|
||||
driver->close = joy_close;
|
||||
|
||||
|
||||
/* FIXME: This crashes!
|
||||
if(args)
|
||||
{
|
||||
if(args)
|
||||
{
|
||||
if(strlen(args) > 0)
|
||||
strcpy(device, args);
|
||||
}
|
||||
*/
|
||||
|
||||
strcpy(device, args);
|
||||
}
|
||||
*/
|
||||
|
||||
fd = open (device, O_RDONLY);
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl (fd, F_SETFL, O_NONBLOCK);
|
||||
|
||||
if(fd < 0) return -1;
|
||||
|
||||
ioctl(fd, JSIOCGVERSION, &jsversion);
|
||||
ioctl(fd, JSIOCGAXES, &axes);
|
||||
ioctl(fd, JSIOCGBUTTONS, &buttons);
|
||||
ioctl(fd, JSIOCGNAME(NAME_LENGTH), jsname);
|
||||
|
||||
debug("Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n",
|
||||
jsname, axes, buttons,
|
||||
jsversion >> 16, (jsversion >> 8) & 0xff, jsversion & 0xff);
|
||||
|
||||
axis = calloc(axes, sizeof(int));
|
||||
button = calloc(buttons, sizeof(char));
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
return fd; // 200 is arbitrary. (must be 1 or more)
|
||||
ioctl (fd, JSIOCGVERSION, &jsversion);
|
||||
ioctl (fd, JSIOCGAXES, &axes);
|
||||
ioctl (fd, JSIOCGBUTTONS, &buttons);
|
||||
ioctl (fd, JSIOCGNAME (NAME_LENGTH), jsname);
|
||||
|
||||
debug ("Joystick (%s) has %d axes and %d buttons. Driver version is %d.%d.%d.\n", jsname, axes, buttons, jsversion >> 16, (jsversion >> 8) & 0xff, jsversion & 0xff);
|
||||
|
||||
axis = calloc (axes, sizeof (int));
|
||||
button = calloc (buttons, sizeof (char));
|
||||
|
||||
return fd; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
|
||||
void joy_close()
|
||||
void
|
||||
joy_close ()
|
||||
{
|
||||
if(joy->framebuf != NULL) free(joy->framebuf);
|
||||
close(fd);
|
||||
|
||||
joy->framebuf = NULL;
|
||||
if (joy->framebuf != NULL)
|
||||
free (joy->framebuf);
|
||||
close (fd);
|
||||
|
||||
joy->framebuf = NULL;
|
||||
|
||||
// Why do I have so much trouble getting memory freed without segfaults??
|
||||
//if(axis) free(axis);
|
||||
//if(button) free(button);
|
||||
|
||||
// Why do I have so much trouble getting memory freed without segfaults??
|
||||
//if(axis) free(axis);
|
||||
//if(button) free(button);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -173,46 +153,49 @@ void joy_close()
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char joy_getkey()
|
||||
char
|
||||
joy_getkey ()
|
||||
{
|
||||
int i;
|
||||
int err;
|
||||
|
||||
err = read(fd, &js, sizeof(struct js_event));
|
||||
if (err <= 0) return 0;
|
||||
if (err != sizeof(struct js_event)) {
|
||||
fprintf(stderr, "\nerror reading joystick\n");
|
||||
|
||||
err = read (fd, &js, sizeof (struct js_event));
|
||||
if (err <= 0)
|
||||
return 0;
|
||||
if (err != sizeof (struct js_event)) {
|
||||
fprintf (stderr, "\nerror reading joystick\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if(js.type & JS_EVENT_INIT) return 0;
|
||||
|
||||
switch(js.type & ~JS_EVENT_INIT) {
|
||||
case JS_EVENT_BUTTON:
|
||||
button[js.number] = js.value;
|
||||
break;
|
||||
case JS_EVENT_AXIS:
|
||||
axis[js.number] = js.value;
|
||||
break;
|
||||
|
||||
switch (js.type & ~JS_EVENT_INIT) {
|
||||
case JS_EVENT_BUTTON:
|
||||
button[js.number] = js.value;
|
||||
break;
|
||||
case JS_EVENT_AXIS:
|
||||
axis[js.number] = js.value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (buttons) {
|
||||
//printf("Buttons: ");
|
||||
for (i = 0; i < buttons; i++)
|
||||
//printf("%2d:%s ", i, button[i] ? "on " : "off");
|
||||
if(button[i]) return buttonmap[i];
|
||||
if (button[i])
|
||||
return buttonmap[i];
|
||||
}
|
||||
|
||||
if (axes) {
|
||||
//printf("Axes: ");
|
||||
for (i = 0; i < axes; i++)
|
||||
{
|
||||
for (i = 0; i < axes; i++) {
|
||||
//printf("%2d:%6d ", i, axis[i]);
|
||||
// Eliminate noise...
|
||||
if(axis[i] > 20000) return axismap[(2*i) + 1];
|
||||
if(axis[i] < -20000) return axismap[(2*i)];
|
||||
if (axis[i] > 20000)
|
||||
return axismap[(2 * i) + 1];
|
||||
if (axis[i] < -20000)
|
||||
return axismap[(2 * i)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
extern lcd_logical_driver *joy;
|
||||
|
||||
int joy_init(struct lcd_logical_driver *driver, char *args);
|
||||
void joy_close();
|
||||
char joy_getkey();
|
||||
int joy_init (struct lcd_logical_driver *driver, char *args);
|
||||
void joy_close ();
|
||||
char joy_getkey ();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+338
-364
@@ -61,41 +61,40 @@
|
||||
|
||||
lcd_logical_driver lcd;
|
||||
|
||||
lcd_physical_driver drivers[] =
|
||||
{
|
||||
{ "base", drv_base_init, },
|
||||
lcd_physical_driver drivers[] = {
|
||||
{"base", drv_base_init,},
|
||||
#ifdef MTXORB_DRV
|
||||
{ "MtxOrb", MtxOrb_init, },
|
||||
{"MtxOrb", MtxOrb_init,},
|
||||
#endif
|
||||
#ifdef CFONTZ_DRV
|
||||
{ "CFontz", CFontz_init, },
|
||||
{"CFontz", CFontz_init,},
|
||||
#endif
|
||||
#ifdef HD44780_DRV
|
||||
{ "HD44780", HD44780_init, },
|
||||
{"HD44780", HD44780_init,},
|
||||
#endif
|
||||
#ifdef SLI_DRV
|
||||
{ "sli", sli_init, },
|
||||
{"sli", sli_init,},
|
||||
#endif
|
||||
#ifdef TEXT_DRV
|
||||
{ "text", text_init, },
|
||||
{"text", text_init,},
|
||||
#endif
|
||||
#ifdef DEBUG_DRV
|
||||
{ "debug", debug_init, },
|
||||
{"debug", debug_init,},
|
||||
#endif
|
||||
#ifdef CURSES_DRV
|
||||
{ "curses", curses_drv_init, },
|
||||
{"curses", curses_drv_init,},
|
||||
#endif
|
||||
#ifdef JOY_DRV
|
||||
{ "joy", joy_init, },
|
||||
{"joy", joy_init,},
|
||||
#endif
|
||||
#ifdef IRMANIN_DRV
|
||||
{ "irmanin", irmanin_init, },
|
||||
{"irmanin", irmanin_init,},
|
||||
#endif
|
||||
#ifdef LIRCIN_DRV
|
||||
{ "lircin", lircin_init, },
|
||||
{"lircin", lircin_init,},
|
||||
#endif
|
||||
{ NULL, NULL, },
|
||||
|
||||
{NULL, NULL,},
|
||||
|
||||
};
|
||||
|
||||
LL *list;
|
||||
@@ -103,92 +102,90 @@ LL *list;
|
||||
////////////////////////////////////////////////////////////
|
||||
// This sets up which driver to use and initializes stuff.
|
||||
//
|
||||
int lcd_init(char *args)
|
||||
int
|
||||
lcd_init (char *args)
|
||||
{
|
||||
// int i;
|
||||
int err;
|
||||
|
||||
list = LL_new();
|
||||
if(!list)
|
||||
{
|
||||
printf("Error allocating driver list.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
lcd_drv_init(NULL, NULL);
|
||||
|
||||
err = lcd_add_driver("base", args);
|
||||
list = LL_new ();
|
||||
if (!list) {
|
||||
printf ("Error allocating driver list.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
lcd.wid = 20;
|
||||
lcd.hgt = 4;
|
||||
lcd_drv_init (NULL, NULL);
|
||||
|
||||
return err;
|
||||
|
||||
/*
|
||||
drv_base_init(args);
|
||||
err = lcd_add_driver ("base", args);
|
||||
|
||||
for(i=0; drivers[i].name; i++)
|
||||
{
|
||||
if(!strcmp(driver, drivers[i].name))
|
||||
{
|
||||
lcd.wid = 20;
|
||||
lcd.hgt = 4;
|
||||
|
||||
return err;
|
||||
|
||||
/*
|
||||
drv_base_init(args);
|
||||
|
||||
for(i=0; drivers[i].name; i++)
|
||||
{
|
||||
if(!strcmp(driver, drivers[i].name))
|
||||
{
|
||||
return drivers[i].init(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("Invalid driver: %s\n", driver);
|
||||
return -1;
|
||||
*/
|
||||
|
||||
printf("Invalid driver: %s\n", driver);
|
||||
return -1;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: lcd_remove_driver()
|
||||
|
||||
int lcd_add_driver(char *driver, char *args)
|
||||
int
|
||||
lcd_add_driver (char *driver, char *args)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
lcd_logical_driver *add;
|
||||
|
||||
for(i=0; drivers[i].name; i++)
|
||||
{
|
||||
|
||||
for (i = 0; drivers[i].name; i++) {
|
||||
|
||||
//printf("Checking driver: %s\n", drivers[i].name);
|
||||
|
||||
if(0 == strcmp(driver, drivers[i].name))
|
||||
{
|
||||
if (0 == strcmp (driver, drivers[i].name)) {
|
||||
|
||||
//printf("Found driver: %s (%s)\n", drivers[i].name, driver);
|
||||
|
||||
add = malloc(sizeof(lcd_logical_driver));
|
||||
if(!add)
|
||||
{
|
||||
printf("Couldn't allocate driver \"%s\".\n", driver);
|
||||
add = malloc (sizeof (lcd_logical_driver));
|
||||
if (!add) {
|
||||
printf ("Couldn't allocate driver \"%s\".\n", driver);
|
||||
return -1;
|
||||
}
|
||||
//printf("Allocated driver\n");
|
||||
memset(add, 0, sizeof(lcd_logical_driver));
|
||||
memset (add, 0, sizeof (lcd_logical_driver));
|
||||
|
||||
add->wid = lcd.wid; add->hgt = lcd.hgt;
|
||||
add->cellwid = lcd.cellwid; add->cellhgt = lcd.cellhgt;
|
||||
add->wid = lcd.wid;
|
||||
add->hgt = lcd.hgt;
|
||||
add->cellwid = lcd.cellwid;
|
||||
add->cellhgt = lcd.cellhgt;
|
||||
|
||||
// printf("LCD driver info:\n\twid: %i\thgt: %i\n",
|
||||
// add->wid, add->hgt);
|
||||
|
||||
add->framebuf = malloc(add->wid * add->hgt);
|
||||
// printf("LCD driver info:\n\twid: %i\thgt: %i\n",
|
||||
// add->wid, add->hgt);
|
||||
|
||||
if(!add->framebuf)
|
||||
{
|
||||
printf("Couldn't allocate framebuffer for driver \"%s\".\n",
|
||||
driver);
|
||||
free(add);
|
||||
add->framebuf = malloc (add->wid * add->hgt);
|
||||
|
||||
if (!add->framebuf) {
|
||||
printf ("Couldn't allocate framebuffer for driver \"%s\".\n", driver);
|
||||
free (add);
|
||||
return -1;
|
||||
}
|
||||
//printf("Allocated frame buffer\n");
|
||||
|
||||
LL_Push(list, (void *)add);
|
||||
|
||||
return drivers[i].init(add, args);
|
||||
|
||||
LL_Push (list, (void *) add);
|
||||
|
||||
return drivers[i].init (add, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,49 +193,47 @@ int lcd_add_driver(char *driver, char *args)
|
||||
}
|
||||
|
||||
// TODO: Put lcd_shutdown in the shutdown function...
|
||||
int lcd_shutdown()
|
||||
int
|
||||
lcd_shutdown ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
|
||||
LL_Rewind(list);
|
||||
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
//printf("driver...\n");
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->close > 0)
|
||||
{
|
||||
driver->close();
|
||||
}
|
||||
else if((int)driver->close == -1)
|
||||
{
|
||||
drv_base->close();
|
||||
|
||||
if ((int) driver->close > 0) {
|
||||
driver->close ();
|
||||
} else if ((int) driver->close == -1) {
|
||||
drv_base->close ();
|
||||
}
|
||||
|
||||
LL_Shift(list);
|
||||
LL_Shift (list);
|
||||
// FIXME: This crashes!
|
||||
//if(driver) free(driver);
|
||||
//printf("...freed\n");
|
||||
}
|
||||
|
||||
} while(LL_Length(list) > 0);
|
||||
|
||||
} while (LL_Length (list) > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int lcd_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
lcd_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
// printf("lcd_drv_init()\n");
|
||||
|
||||
lcd.wid = LCD_MAX_WID;
|
||||
lcd.hgt = LCD_MAX_HGT;
|
||||
|
||||
lcd.framebuf = NULL;
|
||||
lcd.wid = LCD_MAX_WID;
|
||||
lcd.hgt = LCD_MAX_HGT;
|
||||
|
||||
lcd.framebuf = NULL;
|
||||
/*
|
||||
if(!lcd.framebuf)
|
||||
lcd.framebuf = malloc(lcd.wid * lcd.hgt);
|
||||
@@ -253,35 +248,35 @@ int lcd_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
// Debugging...
|
||||
// if(lcd.framebuf) printf("Frame buffer: %i\n", (int)lcd.framebuf);
|
||||
|
||||
lcd.cellwid = 5;
|
||||
lcd.cellhgt = 8;
|
||||
|
||||
// Set up these wrapper functions...
|
||||
lcd.clear = lcd_drv_clear;
|
||||
lcd.string = lcd_drv_string;
|
||||
lcd.chr = lcd_drv_chr;
|
||||
lcd.vbar = lcd_drv_vbar;
|
||||
lcd.hbar = lcd_drv_hbar;
|
||||
lcd.init_num = lcd_drv_init_num;
|
||||
lcd.num = lcd_drv_num;
|
||||
|
||||
lcd.init = lcd_drv_init;
|
||||
lcd.close = lcd_drv_close;
|
||||
lcd.flush = lcd_drv_flush;
|
||||
lcd.flush_box = lcd_drv_flush_box;
|
||||
lcd.contrast = lcd_drv_contrast;
|
||||
lcd.backlight = lcd_drv_backlight;
|
||||
lcd.output = lcd_drv_output;
|
||||
lcd.set_char = lcd_drv_set_char;
|
||||
lcd.icon = lcd_drv_icon;
|
||||
lcd.init_vbar = lcd_drv_init_vbar;
|
||||
lcd.init_hbar = lcd_drv_init_hbar;
|
||||
lcd.draw_frame = lcd_drv_draw_frame;
|
||||
lcd.cellwid = 5;
|
||||
lcd.cellhgt = 8;
|
||||
|
||||
lcd.getkey = lcd_drv_getkey;
|
||||
|
||||
|
||||
return 1; // 1 is arbitrary. (must be 1 or more)
|
||||
// Set up these wrapper functions...
|
||||
lcd.clear = lcd_drv_clear;
|
||||
lcd.string = lcd_drv_string;
|
||||
lcd.chr = lcd_drv_chr;
|
||||
lcd.vbar = lcd_drv_vbar;
|
||||
lcd.hbar = lcd_drv_hbar;
|
||||
lcd.init_num = lcd_drv_init_num;
|
||||
lcd.num = lcd_drv_num;
|
||||
|
||||
lcd.init = lcd_drv_init;
|
||||
lcd.close = lcd_drv_close;
|
||||
lcd.flush = lcd_drv_flush;
|
||||
lcd.flush_box = lcd_drv_flush_box;
|
||||
lcd.contrast = lcd_drv_contrast;
|
||||
lcd.backlight = lcd_drv_backlight;
|
||||
lcd.output = lcd_drv_output;
|
||||
lcd.set_char = lcd_drv_set_char;
|
||||
lcd.icon = lcd_drv_icon;
|
||||
lcd.init_vbar = lcd_drv_init_vbar;
|
||||
lcd.init_hbar = lcd_drv_init_hbar;
|
||||
lcd.draw_frame = lcd_drv_draw_frame;
|
||||
|
||||
lcd.getkey = lcd_drv_getkey;
|
||||
|
||||
|
||||
return 1; // 1 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
|
||||
@@ -302,437 +297,416 @@ int lcd_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void lcd_drv_close()
|
||||
void
|
||||
lcd_drv_close ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
// printf("lcd_drv_close()\n");
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->close > 0)
|
||||
{
|
||||
printf("Calling close()\n");
|
||||
driver->close();
|
||||
}
|
||||
else if((int)driver->close == -1)
|
||||
{
|
||||
drv_base->close();
|
||||
|
||||
if ((int) driver->close > 0) {
|
||||
printf ("Calling close()\n");
|
||||
driver->close ();
|
||||
} else if ((int) driver->close == -1) {
|
||||
drv_base->close ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
}
|
||||
|
||||
void lcd_drv_clear()
|
||||
void
|
||||
lcd_drv_clear ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->clear > 0)
|
||||
driver->clear();
|
||||
else if((int)driver->clear == -1)
|
||||
{
|
||||
drv_base->clear();
|
||||
|
||||
if ((int) driver->clear > 0)
|
||||
driver->clear ();
|
||||
else if ((int) driver->clear == -1) {
|
||||
drv_base->clear ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lcd_drv_flush()
|
||||
void
|
||||
lcd_drv_flush ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->flush > 0)
|
||||
driver->flush();
|
||||
else if((int)driver->flush == -1)
|
||||
{
|
||||
drv_base->flush();
|
||||
|
||||
if ((int) driver->flush > 0)
|
||||
driver->flush ();
|
||||
else if ((int) driver->flush == -1) {
|
||||
drv_base->flush ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
|
||||
void lcd_drv_string(int x, int y, char string[])
|
||||
void
|
||||
lcd_drv_string (int x, int y, char string[])
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->string > 0)
|
||||
driver->string(x,y,string);
|
||||
else if((int)driver->string == -1)
|
||||
{
|
||||
drv_base->string(x,y,string);
|
||||
|
||||
if ((int) driver->string > 0)
|
||||
driver->string (x, y, string);
|
||||
else if ((int) driver->string == -1) {
|
||||
drv_base->string (x, y, string);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_chr(int x, int y, char c)
|
||||
void
|
||||
lcd_drv_chr (int x, int y, char c)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->chr > 0)
|
||||
driver->chr(x,y,c);
|
||||
else if((int)driver->chr == -1)
|
||||
{
|
||||
drv_base->chr(x,y,c);
|
||||
|
||||
if ((int) driver->chr > 0)
|
||||
driver->chr (x, y, c);
|
||||
else if ((int) driver->chr == -1) {
|
||||
drv_base->chr (x, y, c);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int lcd_drv_contrast(int contrast)
|
||||
int
|
||||
lcd_drv_contrast (int contrast)
|
||||
{
|
||||
int res=0;
|
||||
int res = 0;
|
||||
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->contrast > 0)
|
||||
{
|
||||
res=driver->contrast(contrast);
|
||||
if(res >= 0) return res;
|
||||
|
||||
if ((int) driver->contrast > 0) {
|
||||
res = driver->contrast (contrast);
|
||||
if (res >= 0)
|
||||
return res;
|
||||
}
|
||||
/*
|
||||
else if((int)driver->contrast == -1)
|
||||
{
|
||||
res=drv_base->contrast(contrast);
|
||||
}
|
||||
*/
|
||||
else if((int)driver->contrast == -1)
|
||||
{
|
||||
res=drv_base->contrast(contrast);
|
||||
}
|
||||
*/
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void lcd_drv_backlight(int on)
|
||||
void
|
||||
lcd_drv_backlight (int on)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->backlight > 0)
|
||||
driver->backlight(on);
|
||||
else if((int)driver->backlight == -1)
|
||||
{
|
||||
drv_base->backlight(on);
|
||||
|
||||
if ((int) driver->backlight > 0)
|
||||
driver->backlight (on);
|
||||
else if ((int) driver->backlight == -1) {
|
||||
drv_base->backlight (on);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_output(int on)
|
||||
void
|
||||
lcd_drv_output (int on)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
LL_Rewind(list);
|
||||
do
|
||||
{
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
if((int)driver->output > 0)
|
||||
driver->output(on);
|
||||
else if((int)driver->output == -1)
|
||||
{
|
||||
drv_base->output(on);
|
||||
if ((int) driver->output > 0)
|
||||
driver->output (on);
|
||||
else if ((int) driver->output == -1) {
|
||||
drv_base->output (on);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
|
||||
void lcd_drv_init_vbar()
|
||||
void
|
||||
lcd_drv_init_vbar ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->init_vbar > 0)
|
||||
driver->init_vbar();
|
||||
else if((int)driver->init_vbar == -1)
|
||||
{
|
||||
drv_base->init_vbar();
|
||||
|
||||
if ((int) driver->init_vbar > 0)
|
||||
driver->init_vbar ();
|
||||
else if ((int) driver->init_vbar == -1) {
|
||||
drv_base->init_vbar ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_init_hbar()
|
||||
void
|
||||
lcd_drv_init_hbar ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->init_hbar > 0)
|
||||
driver->init_hbar();
|
||||
else if((int)driver->init_hbar == -1)
|
||||
{
|
||||
drv_base->init_hbar();
|
||||
|
||||
if ((int) driver->init_hbar > 0)
|
||||
driver->init_hbar ();
|
||||
else if ((int) driver->init_hbar == -1) {
|
||||
drv_base->init_hbar ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_init_num()
|
||||
void
|
||||
lcd_drv_init_num ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->init_num > 0)
|
||||
driver->init_num();
|
||||
else if((int)driver->init_num == -1)
|
||||
{
|
||||
drv_base->init_num();
|
||||
|
||||
if ((int) driver->init_num > 0)
|
||||
driver->init_num ();
|
||||
else if ((int) driver->init_num == -1) {
|
||||
drv_base->init_num ();
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_num(int x, int num)
|
||||
void
|
||||
lcd_drv_num (int x, int num)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->num > 0)
|
||||
driver->num(x,num);
|
||||
else if((int)driver->num == -1)
|
||||
{
|
||||
drv_base->num(x,num);
|
||||
|
||||
if ((int) driver->num > 0)
|
||||
driver->num (x, num);
|
||||
else if ((int) driver->num == -1) {
|
||||
drv_base->num (x, num);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_set_char(int n, char *dat)
|
||||
void
|
||||
lcd_drv_set_char (int n, char *dat)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->set_char > 0)
|
||||
driver->set_char(n,dat);
|
||||
else if((int)driver->set_char == -1)
|
||||
{
|
||||
drv_base->set_char(n,dat);
|
||||
|
||||
if ((int) driver->set_char > 0)
|
||||
driver->set_char (n, dat);
|
||||
else if ((int) driver->set_char == -1) {
|
||||
drv_base->set_char (n, dat);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_vbar(int x, int len)
|
||||
void
|
||||
lcd_drv_vbar (int x, int len)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->vbar > 0)
|
||||
driver->vbar(x,len);
|
||||
else if((int)driver->vbar == -1)
|
||||
{
|
||||
drv_base->vbar(x,len);
|
||||
|
||||
if ((int) driver->vbar > 0)
|
||||
driver->vbar (x, len);
|
||||
else if ((int) driver->vbar == -1) {
|
||||
drv_base->vbar (x, len);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
void lcd_drv_hbar(int x, int y, int len)
|
||||
void
|
||||
lcd_drv_hbar (int x, int y, int len)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->hbar > 0)
|
||||
driver->hbar(x,y,len);
|
||||
else if((int)driver->hbar == -1)
|
||||
{
|
||||
drv_base->hbar(x,y,len);
|
||||
|
||||
if ((int) driver->hbar > 0)
|
||||
driver->hbar (x, y, len);
|
||||
else if ((int) driver->hbar == -1) {
|
||||
drv_base->hbar (x, y, len);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
|
||||
void lcd_drv_icon(int which, char dest)
|
||||
void
|
||||
lcd_drv_icon (int which, char dest)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->icon > 0)
|
||||
driver->icon(which,dest);
|
||||
else if((int)driver->icon == -1)
|
||||
{
|
||||
drv_base->icon(which,dest);
|
||||
|
||||
if ((int) driver->icon > 0)
|
||||
driver->icon (which, dest);
|
||||
else if ((int) driver->icon == -1) {
|
||||
drv_base->icon (which, dest);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
}
|
||||
|
||||
|
||||
void lcd_drv_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
lcd_drv_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->flush_box > 0)
|
||||
driver->flush_box(lft,top,rgt,bot);
|
||||
else if((int)driver->flush_box == -1)
|
||||
{
|
||||
drv_base->flush_box(lft,top,rgt,bot);
|
||||
|
||||
if ((int) driver->flush_box > 0)
|
||||
driver->flush_box (lft, top, rgt, bot);
|
||||
else if ((int) driver->flush_box == -1) {
|
||||
drv_base->flush_box (lft, top, rgt, bot);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: Check whether lcd.draw_frame() should really take a framebuffer
|
||||
// TODO: as an argument, or if it should always use lcd.framebuf
|
||||
void lcd_drv_draw_frame(char *dat)
|
||||
void
|
||||
lcd_drv_draw_frame (char *dat)
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
LL_Rewind(list);
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->draw_frame > 0)
|
||||
driver->draw_frame(dat);
|
||||
else if((int)driver->draw_frame == -1)
|
||||
{
|
||||
drv_base->draw_frame(dat);
|
||||
|
||||
if ((int) driver->draw_frame > 0)
|
||||
driver->draw_frame (dat);
|
||||
else if ((int) driver->draw_frame == -1) {
|
||||
drv_base->draw_frame (dat);
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char lcd_drv_getkey()
|
||||
char
|
||||
lcd_drv_getkey ()
|
||||
{
|
||||
lcd_logical_driver *driver;
|
||||
|
||||
char key;
|
||||
|
||||
LL_Rewind(list);
|
||||
|
||||
LL_Rewind (list);
|
||||
do {
|
||||
driver = (lcd_logical_driver *)LL_Get(list);
|
||||
if(driver)
|
||||
{
|
||||
driver = (lcd_logical_driver *) LL_Get (list);
|
||||
if (driver) {
|
||||
lcd.framebuf = driver->framebuf;
|
||||
|
||||
if((int)driver->getkey > 0)
|
||||
{
|
||||
key = driver->getkey();
|
||||
if(key) return key;
|
||||
}
|
||||
else if((int)driver->getkey == -1)
|
||||
{
|
||||
key = drv_base->getkey();
|
||||
if(key) return key;
|
||||
|
||||
if ((int) driver->getkey > 0) {
|
||||
key = driver->getkey ();
|
||||
if (key)
|
||||
return key;
|
||||
} else if ((int) driver->getkey == -1) {
|
||||
key = drv_base->getkey ();
|
||||
if (key)
|
||||
return key;
|
||||
}
|
||||
}
|
||||
} while(LL_Next(list) == 0);
|
||||
} while (LL_Next (list) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+61
-64
@@ -8,9 +8,9 @@
|
||||
#define LCD_MAX_HEIGHT 256
|
||||
|
||||
|
||||
int lcd_init(char *args);
|
||||
int lcd_add_driver(char *driver, char *args);
|
||||
int lcd_shutdown();
|
||||
int lcd_init (char *args);
|
||||
int lcd_add_driver (char *driver, char *args);
|
||||
int lcd_shutdown ();
|
||||
|
||||
|
||||
|
||||
@@ -20,76 +20,73 @@ int lcd_shutdown();
|
||||
// Feel free to override any/all functions here with real driver
|
||||
// functions...
|
||||
//
|
||||
typedef struct lcd_logical_driver
|
||||
{
|
||||
// Size in cells of the LCD
|
||||
int wid, hgt;
|
||||
// Size of each LCD cell, in pixels
|
||||
int cellwid, cellhgt;
|
||||
// Frame buffer...
|
||||
char *framebuf;
|
||||
typedef struct lcd_logical_driver {
|
||||
// Size in cells of the LCD
|
||||
int wid, hgt;
|
||||
// Size of each LCD cell, in pixels
|
||||
int cellwid, cellhgt;
|
||||
// Frame buffer...
|
||||
char *framebuf;
|
||||
|
||||
// Functions which might be the same for all drivers...
|
||||
void (*clear)();
|
||||
void (*string)(int x, int y, char lcd[]);
|
||||
|
||||
void (*chr)(int x, int y, char c);
|
||||
void (*vbar)(int x, int len);
|
||||
void (*hbar)(int x, int y, int len);
|
||||
void (*init_num)();
|
||||
void (*num)(int x, int num);
|
||||
|
||||
// Functions which should probably be implemented in each driver...
|
||||
int (*init)(struct lcd_logical_driver *driver, char *args);
|
||||
void (*close)();
|
||||
void (*flush)();
|
||||
void (*flush_box)(int lft, int top, int rgt, int bot);
|
||||
int (*contrast)(int contrast);
|
||||
void (*backlight)(int on);
|
||||
void (*output)(int on);
|
||||
void (*set_char)(int n, char *dat);
|
||||
void (*icon)(int which, char dest);
|
||||
void (*init_vbar)();
|
||||
void (*init_hbar)();
|
||||
void (*draw_frame)();
|
||||
// Functions which might be the same for all drivers...
|
||||
void (*clear) ();
|
||||
void (*string) (int x, int y, char lcd[]);
|
||||
|
||||
void (*chr) (int x, int y, char c);
|
||||
void (*vbar) (int x, int len);
|
||||
void (*hbar) (int x, int y, int len);
|
||||
void (*init_num) ();
|
||||
void (*num) (int x, int num);
|
||||
|
||||
// Functions which should probably be implemented in each driver...
|
||||
int (*init) (struct lcd_logical_driver * driver, char *args);
|
||||
void (*close) ();
|
||||
void (*flush) ();
|
||||
void (*flush_box) (int lft, int top, int rgt, int bot);
|
||||
int (*contrast) (int contrast);
|
||||
void (*backlight) (int on);
|
||||
void (*output) (int on);
|
||||
void (*set_char) (int n, char *dat);
|
||||
void (*icon) (int which, char dest);
|
||||
void (*init_vbar) ();
|
||||
void (*init_hbar) ();
|
||||
void (*draw_frame) ();
|
||||
|
||||
// Returns 0 for "no key pressed", or (A-Z).
|
||||
char (*getkey) ();
|
||||
|
||||
// more?
|
||||
|
||||
// Returns 0 for "no key pressed", or (A-Z).
|
||||
char (*getkey)();
|
||||
|
||||
// more?
|
||||
|
||||
} lcd_logical_driver;
|
||||
|
||||
typedef struct lcd_physical_driver
|
||||
{
|
||||
char *name;
|
||||
int (*init)(struct lcd_logical_driver *driver, char *device);
|
||||
typedef struct lcd_physical_driver {
|
||||
char *name;
|
||||
int (*init) (struct lcd_logical_driver * driver, char *device);
|
||||
} lcd_physical_driver;
|
||||
|
||||
|
||||
extern lcd_logical_driver lcd;
|
||||
|
||||
|
||||
int lcd_drv_init(lcd_logical_driver *driver, char *args);
|
||||
void lcd_drv_close();
|
||||
void lcd_drv_clear();
|
||||
void lcd_drv_flush();
|
||||
void lcd_drv_string(int x, int y, char string[]);
|
||||
void lcd_drv_chr(int x, int y, char c);
|
||||
int lcd_drv_contrast(int contrast);
|
||||
void lcd_drv_backlight(int on);
|
||||
void lcd_drv_output(int on);
|
||||
void lcd_drv_init_vbar();
|
||||
void lcd_drv_init_hbar();
|
||||
void lcd_drv_init_num();
|
||||
void lcd_drv_num(int x, int num);
|
||||
void lcd_drv_set_char(int n, char *dat);
|
||||
void lcd_drv_vbar(int x, int len);
|
||||
void lcd_drv_hbar(int x, int y, int len);
|
||||
void lcd_drv_icon(int which, char dest);
|
||||
void lcd_drv_flush_box(int lft, int top, int rgt, int bot);
|
||||
void lcd_drv_draw_frame();
|
||||
char lcd_drv_getkey();
|
||||
int lcd_drv_init (lcd_logical_driver * driver, char *args);
|
||||
void lcd_drv_close ();
|
||||
void lcd_drv_clear ();
|
||||
void lcd_drv_flush ();
|
||||
void lcd_drv_string (int x, int y, char string[]);
|
||||
void lcd_drv_chr (int x, int y, char c);
|
||||
int lcd_drv_contrast (int contrast);
|
||||
void lcd_drv_backlight (int on);
|
||||
void lcd_drv_output (int on);
|
||||
void lcd_drv_init_vbar ();
|
||||
void lcd_drv_init_hbar ();
|
||||
void lcd_drv_init_num ();
|
||||
void lcd_drv_num (int x, int num);
|
||||
void lcd_drv_set_char (int n, char *dat);
|
||||
void lcd_drv_vbar (int x, int len);
|
||||
void lcd_drv_hbar (int x, int y, int len);
|
||||
void lcd_drv_icon (int which, char dest);
|
||||
void lcd_drv_flush_box (int lft, int top, int rgt, int bot);
|
||||
void lcd_drv_draw_frame ();
|
||||
char lcd_drv_getkey ();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+71
-84
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h> /* for semaphore functions */
|
||||
#include <sys/types.h> /* for semaphore functions */
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <errno.h>
|
||||
@@ -31,19 +31,19 @@
|
||||
#include "lcd_sem.h"
|
||||
|
||||
#define SEMAPHORE "portctrl"
|
||||
#define SEMKEY 0x706f7274 /* semaphore key */
|
||||
#define SEMCOUNT 1 /* number of semaphores to create */
|
||||
#define WMODE 0660 /* access permissions */
|
||||
#define SEMKEY 0x706f7274 /* semaphore key */
|
||||
#define SEMCOUNT 1 /* number of semaphores to create */
|
||||
#define WMODE 0660 /* access permissions */
|
||||
|
||||
#define SEM_SIGNAL 0,1,SEM_UNDO
|
||||
#define SEM_WAIT 0,-1,SEM_UNDO
|
||||
|
||||
/* functions local to this file */
|
||||
static key_t getkey(register char *p);
|
||||
|
||||
static key_t getkey (register char *p);
|
||||
|
||||
/* global variables */
|
||||
static struct sembuf semaphore_wait = {SEM_WAIT};
|
||||
static struct sembuf semaphore_signal = {SEM_SIGNAL};
|
||||
static struct sembuf semaphore_wait = { SEM_WAIT };
|
||||
static struct sembuf semaphore_signal = { SEM_SIGNAL };
|
||||
|
||||
static char rcsId[] = "$Id$";
|
||||
|
||||
@@ -52,9 +52,9 @@ static char rcsId[] = "$Id$";
|
||||
*/
|
||||
|
||||
static key_t
|
||||
getkey(register char *p)
|
||||
getkey (register char *p)
|
||||
{
|
||||
return((key_t) SEMKEY);
|
||||
return ((key_t) SEMKEY);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -63,50 +63,42 @@ getkey(register char *p)
|
||||
*/
|
||||
|
||||
int
|
||||
sem_get(void)
|
||||
sem_get (void)
|
||||
{
|
||||
int semid;
|
||||
union semun semval;
|
||||
int semid;
|
||||
union semun semval;
|
||||
|
||||
if ((semid = semget(getkey(SEMAPHORE), SEMCOUNT,
|
||||
IPC_CREAT | IPC_EXCL | WMODE)) < 0)
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case EEXIST:
|
||||
/* semaphore set exists, get id and return it */
|
||||
if ((semid = semget(getkey(SEMAPHORE), SEMCOUNT,
|
||||
IPC_EXCL | WMODE)) < 0)
|
||||
{
|
||||
perror("semget");
|
||||
exit(1);
|
||||
}
|
||||
return semid;
|
||||
break;
|
||||
case EACCES:
|
||||
/* don't have permissions for semaphore, need to change key */
|
||||
perror("semget, can't get permissions for semaphore");
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
perror("semget");
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* initialise semaphore to 1 */
|
||||
semval.val = 1;
|
||||
if ((semid = semget (getkey (SEMAPHORE), SEMCOUNT, IPC_CREAT | IPC_EXCL | WMODE)) < 0) {
|
||||
switch (errno) {
|
||||
case EEXIST:
|
||||
/* semaphore set exists, get id and return it */
|
||||
if ((semid = semget (getkey (SEMAPHORE), SEMCOUNT, IPC_EXCL | WMODE)) < 0) {
|
||||
perror ("semget");
|
||||
exit (1);
|
||||
}
|
||||
return semid;
|
||||
break;
|
||||
case EACCES:
|
||||
/* don't have permissions for semaphore, need to change key */
|
||||
perror ("semget, can't get permissions for semaphore");
|
||||
exit (1);
|
||||
break;
|
||||
default:
|
||||
perror ("semget");
|
||||
exit (1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* initialise semaphore to 1 */
|
||||
semval.val = 1;
|
||||
|
||||
if (semctl(semid, 0, SETVAL, semval) < 0)
|
||||
{
|
||||
perror("setval, can't initialise semaphore");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
return semid;
|
||||
if (semctl (semid, 0, SETVAL, semval) < 0) {
|
||||
perror ("setval, can't initialise semaphore");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
return semid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -114,15 +106,14 @@ sem_get(void)
|
||||
*/
|
||||
|
||||
int
|
||||
sem_wait(int sid)
|
||||
sem_wait (int sid)
|
||||
{
|
||||
if (semop(sid, &semaphore_wait, 1) < -1)
|
||||
{
|
||||
perror(SEMAPHORE);
|
||||
exit(1);
|
||||
}
|
||||
if (semop (sid, &semaphore_wait, 1) < -1) {
|
||||
perror (SEMAPHORE);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -130,15 +121,14 @@ sem_wait(int sid)
|
||||
*/
|
||||
|
||||
int
|
||||
sem_signal(int sid)
|
||||
sem_signal (int sid)
|
||||
{
|
||||
if (semop(sid, &semaphore_signal, 1) < -1)
|
||||
{
|
||||
perror(SEMAPHORE);
|
||||
exit(1);
|
||||
}
|
||||
if (semop (sid, &semaphore_signal, 1) < -1) {
|
||||
perror (SEMAPHORE);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -146,25 +136,22 @@ sem_signal(int sid)
|
||||
*/
|
||||
|
||||
int
|
||||
sem_remove(int sid)
|
||||
sem_remove (int sid)
|
||||
{
|
||||
int i;
|
||||
union semun dummy;
|
||||
|
||||
if ((i = semctl(sid, 0, IPC_RMID, dummy)) < 0)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case EIDRM:
|
||||
/* semaphore removed */
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
perror("semctl, removing semaphore");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
int i;
|
||||
union semun dummy;
|
||||
|
||||
return 0;
|
||||
if ((i = semctl (sid, 0, IPC_RMID, dummy)) < 0) {
|
||||
switch (i) {
|
||||
case EIDRM:
|
||||
/* semaphore removed */
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
perror ("semctl, removing semaphore");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#ifndef LCD_SEM_H
|
||||
#define LCD_SEM_H
|
||||
|
||||
int sem_get(void);
|
||||
int sem_wait(int sid);
|
||||
int sem_signal(int sid);
|
||||
int sem_remove(int sid);
|
||||
int sem_get (void);
|
||||
int sem_wait (int sid);
|
||||
int sem_signal (int sid);
|
||||
int sem_remove (int sid);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/* lcddriver.cd - test/demo of LIBIR's to interface with lcdproc (LCDd) */
|
||||
/* Copyright (C) 1999 David Glaude loosely based on workmanir.c */
|
||||
/* workmanir.c - test/demo of LIBIR's high level command functions */
|
||||
/* Copyright (C) 1998 Tom Wheeley, see file COPYING for details */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "irman.h"
|
||||
|
||||
char *progname = "lcddriver";
|
||||
|
||||
char *codes[] = {
|
||||
/* dummy */ NULL,
|
||||
/* KeyToLcd */ "lcdproc-A",
|
||||
/* KeyToLcd */ "lcdproc-B",
|
||||
/* KeyToLcd */ "lcdproc-C",
|
||||
/* KeyToLcd */ "lcdproc-D",
|
||||
/* KeyToLcd */ "lcdproc-E",
|
||||
/* KeyToLcd */ "lcdproc-F",
|
||||
/* KeyToLcd */ "lcdproc-G",
|
||||
/* KeyToLcd */ "lcdproc-H",
|
||||
/* KeyToLcd */ "lcdproc-I",
|
||||
/* KeyToLcd */ "lcdproc-J",
|
||||
/* KeyToLcd */ "lcdproc-K",
|
||||
/* KeyToLcd */ "lcdproc-L",
|
||||
/* KeyToLcd */ "lcdproc-M",
|
||||
/* KeyToLcd */ "lcdproc-N",
|
||||
/* KeyToLcd */ "lcdproc-O",
|
||||
/* KeyToLcd */ "lcdproc-P",
|
||||
/* KeyToLcd */ "lcdproc-Q",
|
||||
/* KeyToLcd */ "lcdproc-R",
|
||||
/* KeyToLcd */ "lcdproc-S",
|
||||
/* KeyToLcd */ "lcdproc-T",
|
||||
/* KeyToLcd */ "lcdproc-U",
|
||||
/* KeyToLcd */ "lcdproc-V",
|
||||
/* KeyToLcd */ "lcdproc-W",
|
||||
/* KeyToLcd */ "lcdproc-X",
|
||||
/* KeyToLcd */ "lcdproc-Y",
|
||||
/* KeyToLcd */ "lcdproc-Z",
|
||||
/* end */ NULL
|
||||
};
|
||||
|
||||
|
||||
//void sigterm(int sig)
|
||||
//{
|
||||
// ir_free_commands();
|
||||
// ir_finish();
|
||||
// raise(sig);
|
||||
//}
|
||||
|
||||
|
||||
// INIT $$$
|
||||
int INIT()
|
||||
{
|
||||
int i;
|
||||
char *filename;
|
||||
|
||||
if (ir_init_commands(NULL, 1) < 0) {
|
||||
fprintf(stderr, "error initialising commands: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
filename = ir_default_portname();
|
||||
filename = "option";
|
||||
}
|
||||
|
||||
for (i=1; codes[i] != NULL; i++) {
|
||||
if (ir_register_command(codes[i], i) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stderr, "%s: no code set for `%s'\n", progname, codes[i]);
|
||||
} else {
|
||||
fprintf(stderr, "error registering `%s': `%s'\n", codes[i], strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if (ir_init(filename) < 0) {
|
||||
fprintf(stderr, "%s: error initialising Irman: `%s'\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// KEY $$$
|
||||
int KEY(void)
|
||||
{
|
||||
int i;
|
||||
int cmd;
|
||||
char key;
|
||||
|
||||
key=(char)0;
|
||||
for(i=1;i;) {
|
||||
switch (cmd=ir_get_command()) {
|
||||
case IR_CMD_ERROR:
|
||||
fprintf(stderr, "%s: error reading command: %s\n", progname, strerror(errno));
|
||||
// No exit in LCDd !!!
|
||||
// exit(1);
|
||||
|
||||
case IR_CMD_UNKNOWN:
|
||||
fprintf(stderr,"IR unknown command\n");
|
||||
default: key='A'-1+cmd; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CLOSE $$$
|
||||
int CLOSE()
|
||||
{
|
||||
ir_free_commands();
|
||||
ir_finish();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* end of lcddriver.c */
|
||||
+41
-40
@@ -49,10 +49,11 @@ lcd_logical_driver *lircin;
|
||||
// raise(sig);
|
||||
//}
|
||||
|
||||
void lircin_close()
|
||||
void
|
||||
lircin_close ()
|
||||
{
|
||||
lirc_freeconfig(config);
|
||||
lirc_deinit();
|
||||
lirc_freeconfig (config);
|
||||
lirc_deinit ();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,33 +62,34 @@ void lircin_close()
|
||||
//
|
||||
// Return 0 for "nothing available".
|
||||
//
|
||||
char lircin_getkey()
|
||||
char
|
||||
lircin_getkey ()
|
||||
{
|
||||
char key;
|
||||
char *ir,*cmd;
|
||||
|
||||
if (!(ir = lirc_nextir()))
|
||||
{
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
if (!(cmd = lirc_ir2char(config,ir))) return 0;
|
||||
|
||||
printf("lirc: \"%s\"\n", cmd);
|
||||
sscanf(cmd,"%c",&key);
|
||||
printf("\n%c\n",key);
|
||||
free(ir);
|
||||
return key;
|
||||
}
|
||||
char key;
|
||||
char *ir, *cmd;
|
||||
|
||||
return 0;
|
||||
if (!(ir = lirc_nextir ())) {
|
||||
return 0;
|
||||
} else {
|
||||
if (!(cmd = lirc_ir2char (config, ir)))
|
||||
return 0;
|
||||
|
||||
printf ("lirc: \"%s\"\n", cmd);
|
||||
sscanf (cmd, "%c", &key);
|
||||
printf ("\n%c\n", key);
|
||||
free (ir);
|
||||
return key;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// init() should set up any device-specific stuff, and
|
||||
// point all the function pointers.
|
||||
int lircin_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
lircin_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
|
||||
/* assign funktions */
|
||||
@@ -99,24 +101,23 @@ int lircin_init(struct lcd_logical_driver *driver, char *args)
|
||||
|
||||
/* open socket to lirc */
|
||||
|
||||
|
||||
if (-1 == (fd = lirc_init("lcdd",1))) {
|
||||
fprintf(stderr,"no infrared remote support available\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != lirc_readconfig(NULL,&config,NULL)) {
|
||||
lirc_deinit();
|
||||
return -1;
|
||||
}
|
||||
fcntl(fd,F_SETFL,O_NONBLOCK);
|
||||
fcntl(fd,F_SETFD,FD_CLOEXEC);
|
||||
|
||||
|
||||
if (-1 == (fd = lirc_init ("lcdd", 1))) {
|
||||
fprintf (stderr, "no infrared remote support available\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != lirc_readconfig (NULL, &config, NULL)) {
|
||||
lirc_deinit ();
|
||||
return -1;
|
||||
}
|
||||
fcntl (fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
/* socket shouldn block lcdd */
|
||||
|
||||
fcntl(fd,F_SETFL,O_NONBLOCK);
|
||||
fcntl(fd,F_SETFD,FD_CLOEXEC);
|
||||
|
||||
return 1; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
fcntl (fd, F_SETFL, O_NONBLOCK);
|
||||
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
return 1; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
extern lcd_logical_driver *lircin;
|
||||
|
||||
int lircin_init(struct lcd_logical_driver *driver, char *args);
|
||||
void lircin_close();
|
||||
char lircin_getkey();
|
||||
int lircin_init (struct lcd_logical_driver *driver, char *args);
|
||||
void lircin_close ();
|
||||
char lircin_getkey ();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+15
-15
@@ -15,36 +15,36 @@
|
||||
#endif
|
||||
|
||||
#ifndef DOS
|
||||
static inline int port_in( int port )
|
||||
static inline int
|
||||
port_in (int port)
|
||||
{
|
||||
unsigned char value;
|
||||
__asm__ volatile ("inb %1,%0"
|
||||
: "=a" (value)
|
||||
: "d" ((unsigned short)port));
|
||||
__asm__ volatile ("inb %1,%0":"=a" (value)
|
||||
:"d" ((unsigned short) port));
|
||||
return value;
|
||||
}
|
||||
|
||||
static inline void port_out( unsigned short int port, unsigned char val )
|
||||
static inline void
|
||||
port_out (unsigned short int port, unsigned char val)
|
||||
{
|
||||
__asm__ volatile (
|
||||
"outb %0,%1\n"
|
||||
:
|
||||
: "a" (val), "d" (port)
|
||||
);
|
||||
__asm__ volatile ("outb %0,%1\n"::"a" (val), "d" (port)
|
||||
);
|
||||
}
|
||||
#else
|
||||
#include <pc.h>
|
||||
|
||||
static inline int port_in( int port )
|
||||
static inline int
|
||||
port_in (int port)
|
||||
{
|
||||
unsigned char value;
|
||||
value = inportb((unsigned short) port);
|
||||
return (int)value;
|
||||
value = inportb ((unsigned short) port);
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
static inline void port_out( unsigned int port, unsigned char val )
|
||||
static inline void
|
||||
port_out (unsigned int port, unsigned char val)
|
||||
{
|
||||
outportb((unsigned short) port, val);
|
||||
outportb ((unsigned short) port, val);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+355
-291
@@ -38,141 +38,141 @@
|
||||
/* Small font */
|
||||
|
||||
const unsigned char simple_font5x7[] = {
|
||||
/* ascii '0' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '1' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '2' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '3' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '4' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '5' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '6' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '7' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '8' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '9' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '10' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '11' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '12' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '13' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '14' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '15' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '16' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '17' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '18' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '19' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '20' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '21' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '22' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '23' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '24' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '25' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '26' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '27' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '28' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '29' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '30' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '31' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '0' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '1' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '2' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '3' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '4' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '5' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '6' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '7' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '8' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '9' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '10' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '11' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '12' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '13' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '14' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '15' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '16' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '17' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '18' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '19' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '20' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '21' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '22' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '23' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '24' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '25' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '26' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '27' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '28' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '29' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '30' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '31' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
|
||||
/* ascii '32' ( ) */ 31,31,31,31,31,31,31,
|
||||
/* ascii '33' (!) */ 27,27,27,27,31,31,27,
|
||||
/* ascii '34' (") */ 21,21,21,31,31,31,31,
|
||||
/* ascii '35' (#) */ 21,21,0,21,0,21,21,
|
||||
/* ascii '36' ($) */ 27,1,26,17,11,16,27,
|
||||
/* ascii '37' (%) */ 28,12,23,27,29,6,7,
|
||||
/* ascii '38' (&) */ 25,22,26,29,10,22,9,
|
||||
/* ascii '39' (') */ 25,27,29,31,31,31,31,
|
||||
/* ascii '40' (() */ 23,27,29,29,29,27,23,
|
||||
/* ascii '41' ()) */ 29,27,23,23,23,27,29,
|
||||
/* ascii '42' (*) */ 31,27,10,17,10,27,31,
|
||||
/* ascii '43' (+) */ 31,27,27,0,27,27,31,
|
||||
/* ascii '44' (,) */ 31,31,31,31,25,27,29,
|
||||
/* ascii '45' (-) */ 31,31,31,0,31,31,31,
|
||||
/* ascii '46' (.) */ 31,31,31,31,31,25,25,
|
||||
/* ascii '47' (/) */ 31,15,23,27,29,30,31,
|
||||
/* ascii '48' (0) */ 17,14,6,10,12,14,17,
|
||||
/* ascii '49' (1) */ 27,25,27,27,27,27,17,
|
||||
/* ascii '50' (2) */ 17,14,15,23,27,29,0,
|
||||
/* ascii '51' (3) */ 0,23,27,23,15,14,17,
|
||||
/* ascii '52' (4) */ 23,19,21,22,0,23,23,
|
||||
/* ascii '53' (5) */ 0,30,16,15,15,14,17,
|
||||
/* ascii '54' (6) */ 19,29,30,16,14,14,17,
|
||||
/* ascii '55' (7) */ 0,15,23,27,29,29,29,
|
||||
/* ascii '56' (8) */ 17,14,14,17,14,14,17,
|
||||
/* ascii '57' (9) */ 17,14,14,1,15,23,25,
|
||||
/* ascii '58' (:) */ 31,25,25,31,25,25,31,
|
||||
/* ascii '59' (;) */ 31,25,25,31,25,27,29,
|
||||
/* ascii '60' (<) */ 23,27,29,30,29,27,23,
|
||||
/* ascii '61' (=) */ 31,31,0,31,0,31,31,
|
||||
/* ascii '62' (>) */ 29,27,23,15,23,27,29,
|
||||
/* ascii '63' (?) */ 17,14,15,23,27,31,27,
|
||||
/* ascii '64' (@) */ 17,14,15,9,10,10,17,
|
||||
/* ascii '65' (A) */ 17,14,14,14,0,14,14,
|
||||
/* ascii '66' (B) */ 16,14,14,16,14,14,16,
|
||||
/* ascii '67' (C) */ 16,14,30,30,30,14,16,
|
||||
/* ascii '68' (D) */ 24,22,14,14,14,22,24,
|
||||
/* ascii '69' (E) */ 0,30,30,16,30,30,0,
|
||||
/* ascii '70' (F) */ 0,30,30,16,30,30,30,
|
||||
/* ascii '71' (G) */ 17,14,30,2,14,14,1,
|
||||
/* ascii '72' (H) */ 14,14,14,0,14,14,14,
|
||||
/* ascii '73' (I) */ 17,27,27,27,27,27,17,
|
||||
/* ascii '74' (J) */ 3,23,23,23,23,22,25,
|
||||
/* ascii '75' (K) */ 14,22,26,28,26,22,14,
|
||||
/* ascii '76' (L) */ 30,30,30,30,30,30,0,
|
||||
/* ascii '77' (M) */ 14,4,10,10,14,14,14,
|
||||
/* ascii '78' (N) */ 14,14,12,10,6,14,14,
|
||||
/* ascii '79' (O) */ 17,14,14,14,14,14,17,
|
||||
/* ascii '80' (P) */ 16,14,14,16,30,30,30,
|
||||
/* ascii '81' (Q) */ 17,14,14,14,10,22,9,
|
||||
/* ascii '82' (R) */ 16,14,14,16,26,22,14,
|
||||
/* ascii '83' (S) */ 1,30,30,17,15,15,16,
|
||||
/* ascii '84' (T) */ 0,27,27,27,27,27,27,
|
||||
/* ascii '85' (U) */ 14,14,14,14,14,14,17,
|
||||
/* ascii '86' (V) */ 14,14,14,14,14,21,27,
|
||||
/* ascii '87' (W) */ 14,14,14,14,10,10,21,
|
||||
/* ascii '88' (X) */ 14,14,21,27,21,14,14,
|
||||
/* ascii '89' (Y) */ 14,14,14,21,27,27,27,
|
||||
/* ascii '90' (Z) */ 0,15,23,27,29,30,0,
|
||||
/* ascii '91' ([) */ 17,29,29,29,29,29,17,
|
||||
/* ascii '92' (\) */ 31,30,29,27,23,15,31,
|
||||
/* ascii '93' (]) */ 17,23,23,23,23,23,17,
|
||||
/* ascii '94' (^) */ 27,21,14,31,31,31,31,
|
||||
/* ascii '95' (_) */ 31,31,31,31,31,31,0,
|
||||
/* ascii '96' (`) */ 29,27,23,31,31,31,31,
|
||||
/* ascii '97' (a) */ 31,31,17,15,1,14,1,
|
||||
/* ascii '98' (b) */ 30,30,18,12,14,14,16,
|
||||
/* ascii '99' (c) */ 31,31,17,30,30,14,17,
|
||||
/* ascii '100' (d) */ 15,15,9,6,14,14,1,
|
||||
/* ascii '101' (e) */ 31,31,17,14,0,30,17,
|
||||
/* ascii '102' (f) */ 19,13,29,24,29,29,29,
|
||||
/* ascii '103' (g) */ 31,1,14,14,1,15,17,
|
||||
/* ascii '104' (h) */ 30,30,18,12,14,14,14,
|
||||
/* ascii '105' (i) */ 27,31,25,27,27,27,17,
|
||||
/* ascii '106' (j) */ 23,31,19,23,23,22,25,
|
||||
/* ascii '107' (k) */ 30,30,22,26,28,26,22,
|
||||
/* ascii '108' (l) */ 25,27,27,27,27,27,17,
|
||||
/* ascii '109' (m) */ 31,31,20,10,10,14,14,
|
||||
/* ascii '110' (n) */ 31,31,18,12,14,14,14,
|
||||
/* ascii '111' (o) */ 31,31,17,14,14,14,17,
|
||||
/* ascii '112' (p) */ 31,31,16,14,16,30,30,
|
||||
/* ascii '113' (q) */ 31,31,9,6,1,15,15,
|
||||
/* ascii '114' (r) */ 31,31,18,12,30,30,30,
|
||||
/* ascii '115' (s) */ 31,31,17,30,17,15,16,
|
||||
/* ascii '116' (t) */ 29,29,24,29,29,13,19,
|
||||
/* ascii '117' (u) */ 31,31,14,14,14,6,9,
|
||||
/* ascii '118' (v) */ 31,31,14,14,14,21,27,
|
||||
/* ascii '119' (w) */ 31,31,14,14,10,10,21,
|
||||
/* ascii '120' (x) */ 31,31,14,21,27,21,14,
|
||||
/* ascii '121' (y) */ 31,31,14,14,1,15,17,
|
||||
/* ascii '122' (z) */ 31,31,0,23,27,29,0,
|
||||
/* ascii '123' ({) */ 23,27,27,29,27,27,23,
|
||||
/* ascii '124' (|) */ 27,27,27,27,27,27,27,
|
||||
/* ascii '125' (}) */ 29,27,27,23,27,27,29,
|
||||
/* ascii '126' (~) */ 31,27,23,0,23,27,31
|
||||
/* ascii '32' ( ) */ 31, 31, 31, 31, 31, 31, 31,
|
||||
/* ascii '33' (!) */ 27, 27, 27, 27, 31, 31, 27,
|
||||
/* ascii '34' (") */ 21, 21, 21, 31, 31, 31, 31,
|
||||
/* ascii '35' (#) */ 21, 21, 0, 21, 0, 21, 21,
|
||||
/* ascii '36' ($) */ 27, 1, 26, 17, 11, 16, 27,
|
||||
/* ascii '37' (%) */ 28, 12, 23, 27, 29, 6, 7,
|
||||
/* ascii '38' (&) */ 25, 22, 26, 29, 10, 22, 9,
|
||||
/* ascii '39' (') */ 25, 27, 29, 31, 31, 31, 31,
|
||||
/* ascii '40' (() */ 23, 27, 29, 29, 29, 27, 23,
|
||||
/* ascii '41' ()) */ 29, 27, 23, 23, 23, 27, 29,
|
||||
/* ascii '42' (*) */ 31, 27, 10, 17, 10, 27, 31,
|
||||
/* ascii '43' (+) */ 31, 27, 27, 0, 27, 27, 31,
|
||||
/* ascii '44' (,) */ 31, 31, 31, 31, 25, 27, 29,
|
||||
/* ascii '45' (-) */ 31, 31, 31, 0, 31, 31, 31,
|
||||
/* ascii '46' (.) */ 31, 31, 31, 31, 31, 25, 25,
|
||||
/* ascii '47' (/) */ 31, 15, 23, 27, 29, 30, 31,
|
||||
/* ascii '48' (0) */ 17, 14, 6, 10, 12, 14, 17,
|
||||
/* ascii '49' (1) */ 27, 25, 27, 27, 27, 27, 17,
|
||||
/* ascii '50' (2) */ 17, 14, 15, 23, 27, 29, 0,
|
||||
/* ascii '51' (3) */ 0, 23, 27, 23, 15, 14, 17,
|
||||
/* ascii '52' (4) */ 23, 19, 21, 22, 0, 23, 23,
|
||||
/* ascii '53' (5) */ 0, 30, 16, 15, 15, 14, 17,
|
||||
/* ascii '54' (6) */ 19, 29, 30, 16, 14, 14, 17,
|
||||
/* ascii '55' (7) */ 0, 15, 23, 27, 29, 29, 29,
|
||||
/* ascii '56' (8) */ 17, 14, 14, 17, 14, 14, 17,
|
||||
/* ascii '57' (9) */ 17, 14, 14, 1, 15, 23, 25,
|
||||
/* ascii '58' (:) */ 31, 25, 25, 31, 25, 25, 31,
|
||||
/* ascii '59' (;) */ 31, 25, 25, 31, 25, 27, 29,
|
||||
/* ascii '60' (<) */ 23, 27, 29, 30, 29, 27, 23,
|
||||
/* ascii '61' (=) */ 31, 31, 0, 31, 0, 31, 31,
|
||||
/* ascii '62' (>) */ 29, 27, 23, 15, 23, 27, 29,
|
||||
/* ascii '63' (?) */ 17, 14, 15, 23, 27, 31, 27,
|
||||
/* ascii '64' (@) */ 17, 14, 15, 9, 10, 10, 17,
|
||||
/* ascii '65' (A) */ 17, 14, 14, 14, 0, 14, 14,
|
||||
/* ascii '66' (B) */ 16, 14, 14, 16, 14, 14, 16,
|
||||
/* ascii '67' (C) */ 16, 14, 30, 30, 30, 14, 16,
|
||||
/* ascii '68' (D) */ 24, 22, 14, 14, 14, 22, 24,
|
||||
/* ascii '69' (E) */ 0, 30, 30, 16, 30, 30, 0,
|
||||
/* ascii '70' (F) */ 0, 30, 30, 16, 30, 30, 30,
|
||||
/* ascii '71' (G) */ 17, 14, 30, 2, 14, 14, 1,
|
||||
/* ascii '72' (H) */ 14, 14, 14, 0, 14, 14, 14,
|
||||
/* ascii '73' (I) */ 17, 27, 27, 27, 27, 27, 17,
|
||||
/* ascii '74' (J) */ 3, 23, 23, 23, 23, 22, 25,
|
||||
/* ascii '75' (K) */ 14, 22, 26, 28, 26, 22, 14,
|
||||
/* ascii '76' (L) */ 30, 30, 30, 30, 30, 30, 0,
|
||||
/* ascii '77' (M) */ 14, 4, 10, 10, 14, 14, 14,
|
||||
/* ascii '78' (N) */ 14, 14, 12, 10, 6, 14, 14,
|
||||
/* ascii '79' (O) */ 17, 14, 14, 14, 14, 14, 17,
|
||||
/* ascii '80' (P) */ 16, 14, 14, 16, 30, 30, 30,
|
||||
/* ascii '81' (Q) */ 17, 14, 14, 14, 10, 22, 9,
|
||||
/* ascii '82' (R) */ 16, 14, 14, 16, 26, 22, 14,
|
||||
/* ascii '83' (S) */ 1, 30, 30, 17, 15, 15, 16,
|
||||
/* ascii '84' (T) */ 0, 27, 27, 27, 27, 27, 27,
|
||||
/* ascii '85' (U) */ 14, 14, 14, 14, 14, 14, 17,
|
||||
/* ascii '86' (V) */ 14, 14, 14, 14, 14, 21, 27,
|
||||
/* ascii '87' (W) */ 14, 14, 14, 14, 10, 10, 21,
|
||||
/* ascii '88' (X) */ 14, 14, 21, 27, 21, 14, 14,
|
||||
/* ascii '89' (Y) */ 14, 14, 14, 21, 27, 27, 27,
|
||||
/* ascii '90' (Z) */ 0, 15, 23, 27, 29, 30, 0,
|
||||
/* ascii '91' ([) */ 17, 29, 29, 29, 29, 29, 17,
|
||||
/* ascii '92' (\) */ 31, 30, 29, 27, 23, 15, 31,
|
||||
/* ascii '93' (]) */ 17, 23, 23, 23, 23, 23, 17,
|
||||
/* ascii '94' (^) */ 27, 21, 14, 31, 31, 31, 31,
|
||||
/* ascii '95' (_) */ 31, 31, 31, 31, 31, 31, 0,
|
||||
/* ascii '96' (`) */ 29, 27, 23, 31, 31, 31, 31,
|
||||
/* ascii '97' (a) */ 31, 31, 17, 15, 1, 14, 1,
|
||||
/* ascii '98' (b) */ 30, 30, 18, 12, 14, 14, 16,
|
||||
/* ascii '99' (c) */ 31, 31, 17, 30, 30, 14, 17,
|
||||
/* ascii '100' (d) */ 15, 15, 9, 6, 14, 14, 1,
|
||||
/* ascii '101' (e) */ 31, 31, 17, 14, 0, 30, 17,
|
||||
/* ascii '102' (f) */ 19, 13, 29, 24, 29, 29, 29,
|
||||
/* ascii '103' (g) */ 31, 1, 14, 14, 1, 15, 17,
|
||||
/* ascii '104' (h) */ 30, 30, 18, 12, 14, 14, 14,
|
||||
/* ascii '105' (i) */ 27, 31, 25, 27, 27, 27, 17,
|
||||
/* ascii '106' (j) */ 23, 31, 19, 23, 23, 22, 25,
|
||||
/* ascii '107' (k) */ 30, 30, 22, 26, 28, 26, 22,
|
||||
/* ascii '108' (l) */ 25, 27, 27, 27, 27, 27, 17,
|
||||
/* ascii '109' (m) */ 31, 31, 20, 10, 10, 14, 14,
|
||||
/* ascii '110' (n) */ 31, 31, 18, 12, 14, 14, 14,
|
||||
/* ascii '111' (o) */ 31, 31, 17, 14, 14, 14, 17,
|
||||
/* ascii '112' (p) */ 31, 31, 16, 14, 16, 30, 30,
|
||||
/* ascii '113' (q) */ 31, 31, 9, 6, 1, 15, 15,
|
||||
/* ascii '114' (r) */ 31, 31, 18, 12, 30, 30, 30,
|
||||
/* ascii '115' (s) */ 31, 31, 17, 30, 17, 15, 16,
|
||||
/* ascii '116' (t) */ 29, 29, 24, 29, 29, 13, 19,
|
||||
/* ascii '117' (u) */ 31, 31, 14, 14, 14, 6, 9,
|
||||
/* ascii '118' (v) */ 31, 31, 14, 14, 14, 21, 27,
|
||||
/* ascii '119' (w) */ 31, 31, 14, 14, 10, 10, 21,
|
||||
/* ascii '120' (x) */ 31, 31, 14, 21, 27, 21, 14,
|
||||
/* ascii '121' (y) */ 31, 31, 14, 14, 1, 15, 17,
|
||||
/* ascii '122' (z) */ 31, 31, 0, 23, 27, 29, 0,
|
||||
/* ascii '123' ({) */ 23, 27, 27, 29, 27, 27, 23,
|
||||
/* ascii '124' (|) */ 27, 27, 27, 27, 27, 27, 27,
|
||||
/* ascii '125' (}) */ 29, 27, 27, 23, 27, 27, 29,
|
||||
/* ascii '126' (~) */ 31, 27, 23, 0, 23, 27, 31
|
||||
};
|
||||
|
||||
|
||||
|
||||
// <start user definable!!!>
|
||||
#define SVGALIB_FONT_VER 10 /* vertical spacing between lines (pixels) */
|
||||
#define SVGALIB_Y_OFFSET 40 /* distance from the top of the screen (pixels) */
|
||||
#define SVGALIB_FONT_VER 10 /* vertical spacing between lines (pixels) */
|
||||
#define SVGALIB_Y_OFFSET 40 /* distance from the top of the screen (pixels) */
|
||||
// <end user defineable!!!>
|
||||
|
||||
|
||||
@@ -186,12 +186,12 @@ const unsigned char simple_font5x7[] = {
|
||||
|
||||
lcd_logical_driver *svgalib_drv;
|
||||
|
||||
int SVGALIB_PAD=255;
|
||||
int SVGALIB_ELLIPSIS=7;
|
||||
int SVGALIB_PAD = 255;
|
||||
int SVGALIB_ELLIPSIS = 7;
|
||||
|
||||
void* SVGALIB_font; /* normal font */
|
||||
void* SVGALIB_highfont; /* highlighted font (not used yet) */
|
||||
void* SVGALIB_warnfont; /* warning font (not used yet) */
|
||||
void *SVGALIB_font; /* normal font */
|
||||
void *SVGALIB_highfont; /* highlighted font (not used yet) */
|
||||
void *SVGALIB_warnfont; /* warning font (not used yet) */
|
||||
|
||||
|
||||
/*
|
||||
@@ -202,7 +202,7 @@ void* SVGALIB_warnfont; /* warning font (not used yet) */
|
||||
Ahem... don't do this unless you can get to another console to kill the
|
||||
process after.
|
||||
*/
|
||||
int SVGALIB_figure_mappings=0;
|
||||
int SVGALIB_figure_mappings = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// For Output on SVGALIB screen //////////////////////
|
||||
@@ -212,42 +212,43 @@ void* SVGALIB_warnfont; /* warning font (not used yet) */
|
||||
|
||||
|
||||
|
||||
void ExpandGroovyFont( int w, int ht, unsigned char col,
|
||||
const unsigned char* fnt, unsigned char* ptr )
|
||||
void
|
||||
ExpandGroovyFont (int w, int ht, unsigned char col, const unsigned char *fnt, unsigned char *ptr)
|
||||
// Expand groovy 5x7 font into an area of memory
|
||||
{
|
||||
int x,n,y;
|
||||
unsigned char mask;
|
||||
unsigned char base;
|
||||
unsigned char *p;
|
||||
p = ptr;
|
||||
for (n=0;n<127;n++) {
|
||||
for (y=0;y<ht;y++) {
|
||||
mask = 1;
|
||||
base = fnt[n*ht+y];
|
||||
for (x=0;x<w;x++) {
|
||||
if (base & mask) {
|
||||
*p = 0;
|
||||
} else {
|
||||
*p = col;
|
||||
int x, n, y;
|
||||
unsigned char mask;
|
||||
unsigned char base;
|
||||
unsigned char *p;
|
||||
p = ptr;
|
||||
for (n = 0; n < 127; n++) {
|
||||
for (y = 0; y < ht; y++) {
|
||||
mask = 1;
|
||||
base = fnt[n * ht + y];
|
||||
for (x = 0; x < w; x++) {
|
||||
if (base & mask) {
|
||||
*p = 0;
|
||||
} else {
|
||||
*p = col;
|
||||
}
|
||||
p++;
|
||||
mask *= 2;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
mask*=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void spaced_gl_writen( int x, int y, int count, char * text )
|
||||
void
|
||||
spaced_gl_writen (int x, int y, int count, char *text)
|
||||
//
|
||||
// Like gl_write but this one gets the spacing correct.
|
||||
//
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<count;i++) {
|
||||
gl_writen( 20+x+i*6, y,1, &text[i] );
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
gl_writen (20 + x + i * 6, y, 1, &text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,42 +256,43 @@ int i;
|
||||
static char icon_char = '@';
|
||||
|
||||
|
||||
int svgalib_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
svgalib_drv_init (struct lcd_logical_driver *driver, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
int i,j;
|
||||
int i, j;
|
||||
int VGAMODE;
|
||||
int fgtemp;
|
||||
char param[100];
|
||||
char buffer[1024];
|
||||
|
||||
|
||||
/* not used at the moment */
|
||||
argc = get_args(argv, args, 64 );
|
||||
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
svgalib_drv = driver;
|
||||
vga_init();
|
||||
VGAMODE = G320x200x256; /* Default mode. */
|
||||
vga_init ();
|
||||
VGAMODE = G320x200x256; /* Default mode. */
|
||||
|
||||
if (!vga_hasmode(VGAMODE)) {
|
||||
printf("320x200x256 Mode not available.\n");
|
||||
return -1;
|
||||
} else {
|
||||
vga_setmode(VGAMODE);
|
||||
gl_setcontextvga(VGAMODE); /* Physical screen context. */
|
||||
gl_setrgbpalette();
|
||||
|
||||
/* get the font */
|
||||
SVGALIB_font = malloc( 256*8*8*1 );
|
||||
ExpandGroovyFont( 5, 7, gl_rgbcolor(0,255,0), simple_font5x7, SVGALIB_font );
|
||||
gl_setfont( 5, 7, SVGALIB_font );
|
||||
|
||||
}
|
||||
if (!vga_hasmode (VGAMODE)) {
|
||||
printf ("320x200x256 Mode not available.\n");
|
||||
return -1;
|
||||
} else {
|
||||
vga_setmode (VGAMODE);
|
||||
gl_setcontextvga (VGAMODE); /* Physical screen context. */
|
||||
gl_setrgbpalette ();
|
||||
|
||||
gl_clearscreen(gl_rgbcolor(0,0,0));
|
||||
/* get the font */
|
||||
SVGALIB_font = malloc (256 * 8 * 8 * 1);
|
||||
ExpandGroovyFont (5, 7, gl_rgbcolor (0, 255, 0), simple_font5x7, SVGALIB_font);
|
||||
gl_setfont (5, 7, SVGALIB_font);
|
||||
|
||||
}
|
||||
|
||||
gl_clearscreen (gl_rgbcolor (0, 0, 0));
|
||||
|
||||
|
||||
// Override output functions...
|
||||
// Override output functions...
|
||||
driver->clear = svgalib_drv_clear;
|
||||
driver->string = svgalib_drv_string;
|
||||
driver->chr = svgalib_drv_chr;
|
||||
@@ -300,7 +302,7 @@ int svgalib_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
driver->init_hbar = NULL;
|
||||
driver->num = svgalib_drv_num;
|
||||
driver->init_num = svgalib_drv_init_num;
|
||||
|
||||
|
||||
driver->init = svgalib_drv_init;
|
||||
driver->close = svgalib_drv_close;
|
||||
driver->flush = svgalib_drv_flush;
|
||||
@@ -317,20 +319,22 @@ int svgalib_drv_init(struct lcd_logical_driver *driver, char *args)
|
||||
SVGALIB_PAD = '#';
|
||||
// Change the character used for "..."
|
||||
SVGALIB_ELLIPSIS = '~';
|
||||
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void svgalib_drv_close()
|
||||
void
|
||||
svgalib_drv_close ()
|
||||
{
|
||||
vga_setmode(TEXT);
|
||||
drv_base_close();
|
||||
vga_setmode (TEXT);
|
||||
drv_base_close ();
|
||||
}
|
||||
|
||||
void svgalib_drv_clear()
|
||||
void
|
||||
svgalib_drv_clear ()
|
||||
{
|
||||
vga_waitretrace();
|
||||
gl_clearscreen(gl_rgbcolor(0,0,0));
|
||||
vga_waitretrace ();
|
||||
gl_clearscreen (gl_rgbcolor (0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -338,75 +342,88 @@ void svgalib_drv_clear()
|
||||
// Prints a string on the lcd display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void svgalib_drv_string(int x, int y, char string[])
|
||||
void
|
||||
svgalib_drv_string (int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
unsigned char *c;
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
for (i = 0; string[i]; i++) {
|
||||
c = &string[i];
|
||||
switch(*c) {
|
||||
case 0: *c = icon_char; break;
|
||||
case 255: *c = '#'; break;
|
||||
switch (*c) {
|
||||
case 0:
|
||||
*c = icon_char;
|
||||
break;
|
||||
case 255:
|
||||
*c = '#';
|
||||
break;
|
||||
}
|
||||
}
|
||||
gl_setfont( 5,7,SVGALIB_font );
|
||||
spaced_gl_writen( x*8,y*SVGALIB_FONT_VER+SVGALIB_Y_OFFSET, i, string );
|
||||
gl_setfont (5, 7, SVGALIB_font);
|
||||
spaced_gl_writen (x * 8, y * SVGALIB_FONT_VER + SVGALIB_Y_OFFSET, i, string);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void svgalib_drv_chr(int x, int y, char c)
|
||||
void
|
||||
svgalib_drv_chr (int x, int y, char c)
|
||||
{
|
||||
char buffer[2];
|
||||
switch(c) {
|
||||
case 0: c=icon_char; break;
|
||||
case -1: c = '#'; break;
|
||||
char buffer[2];
|
||||
switch (c) {
|
||||
case 0:
|
||||
c = icon_char;
|
||||
break;
|
||||
case -1:
|
||||
c = '#';
|
||||
break;
|
||||
}
|
||||
buffer[0] = c;
|
||||
buffer[1] = 0;
|
||||
gl_setfont( 5,7,SVGALIB_font );
|
||||
spaced_gl_writen( x*8,y*SVGALIB_FONT_VER+SVGALIB_Y_OFFSET, 1, buffer );
|
||||
gl_setfont (5, 7, SVGALIB_font);
|
||||
spaced_gl_writen (x * 8, y * SVGALIB_FONT_VER + SVGALIB_Y_OFFSET, 1, buffer);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets up for big numbers.
|
||||
//
|
||||
void svgalib_drv_init_num()
|
||||
void
|
||||
svgalib_drv_init_num ()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Writes a big number, but not. A bit like the curses driver.
|
||||
//
|
||||
void svgalib_drv_num(int x, int num)
|
||||
void
|
||||
svgalib_drv_num (int x, int num)
|
||||
{
|
||||
char c;
|
||||
int y, dx;
|
||||
|
||||
c='0'+num;
|
||||
c = '0' + num;
|
||||
|
||||
for(y=1; y<5; y++)
|
||||
for(dx=0; dx<3; dx++)
|
||||
svgalib_drv_chr(x+dx, y, c);
|
||||
for (y = 1; y < 5; y++)
|
||||
for (dx = 0; dx < 3; dx++)
|
||||
svgalib_drv_chr (x + dx, y, c);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void svgalib_drv_vbar(int x, int len)
|
||||
void
|
||||
svgalib_drv_vbar (int x, int len)
|
||||
{
|
||||
char map[]="_.,,ooO8";
|
||||
|
||||
char map[] = "_.,,ooO8";
|
||||
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
if(len >= lcd.cellhgt) svgalib_drv_chr(x, y, '8');
|
||||
else svgalib_drv_chr(x, y, map[len-1]);
|
||||
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
if (len >= lcd.cellhgt)
|
||||
svgalib_drv_chr (x, y, '8');
|
||||
else
|
||||
svgalib_drv_chr (x, y, map[len - 1]);
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
}
|
||||
@@ -414,15 +431,15 @@ void svgalib_drv_vbar(int x, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void svgalib_drv_hbar(int x, int y, int len)
|
||||
void
|
||||
svgalib_drv_hbar (int x, int y, int len)
|
||||
{
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
if(len>=lcd.cellwid)
|
||||
svgalib_drv_chr(x, y, '=');
|
||||
for (; x <= lcd.wid && len > 0; x++) {
|
||||
if (len >= lcd.cellwid)
|
||||
svgalib_drv_chr (x, y, '=');
|
||||
else
|
||||
svgalib_drv_chr(x, y, '-');
|
||||
|
||||
svgalib_drv_chr (x, y, '-');
|
||||
|
||||
len -= lcd.cellwid;
|
||||
}
|
||||
}
|
||||
@@ -431,89 +448,136 @@ void svgalib_drv_hbar(int x, int y, int len)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Sets character 0 to an icon...
|
||||
//
|
||||
void svgalib_drv_icon(int which, char dest)
|
||||
void
|
||||
svgalib_drv_icon (int which, char dest)
|
||||
{
|
||||
if(dest == 0)
|
||||
switch(which)
|
||||
{
|
||||
case 0: icon_char = '+'; break;
|
||||
case 1: icon_char = '*'; break;
|
||||
default: icon_char = '#'; break;
|
||||
}
|
||||
if (dest == 0)
|
||||
switch (which) {
|
||||
case 0:
|
||||
icon_char = '+';
|
||||
break;
|
||||
case 1:
|
||||
icon_char = '*';
|
||||
break;
|
||||
default:
|
||||
icon_char = '#';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void svgalib_drv_flush()
|
||||
void
|
||||
svgalib_drv_flush ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void svgalib_drv_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
svgalib_drv_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void svgalib_drv_draw_frame(char *dat)
|
||||
void
|
||||
svgalib_drv_draw_frame (char *dat)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
char svgalib_drv_getkey()
|
||||
char
|
||||
svgalib_drv_getkey ()
|
||||
{
|
||||
int i;
|
||||
int loop;
|
||||
FILE* fd;
|
||||
i = vga_getkey();
|
||||
int i;
|
||||
int loop;
|
||||
FILE *fd;
|
||||
i = vga_getkey ();
|
||||
if (i) {
|
||||
switch (i) {
|
||||
/* map the cursor keys to something sensible. */
|
||||
case 27 :
|
||||
i = vga_getkey();
|
||||
if (i==91) {
|
||||
i = vga_getkey();
|
||||
switch (i) {
|
||||
case VGAKEY_LEFT: i= 'D';break;
|
||||
case VGAKEY_UP: i= 'B';break;
|
||||
case VGAKEY_DOWN: i= 'C';break;
|
||||
case VGAKEY_RIGHT: i= 'A';break;
|
||||
default:
|
||||
i=0; /* key not recognised */
|
||||
}
|
||||
} else {
|
||||
i=0;
|
||||
}
|
||||
break;
|
||||
switch (i) {
|
||||
/* map the cursor keys to something sensible. */
|
||||
case 27:
|
||||
i = vga_getkey ();
|
||||
if (i == 91) {
|
||||
i = vga_getkey ();
|
||||
switch (i) {
|
||||
case VGAKEY_LEFT:
|
||||
i = 'D';
|
||||
break;
|
||||
case VGAKEY_UP:
|
||||
i = 'B';
|
||||
break;
|
||||
case VGAKEY_DOWN:
|
||||
i = 'C';
|
||||
break;
|
||||
case VGAKEY_RIGHT:
|
||||
i = 'A';
|
||||
break;
|
||||
default:
|
||||
i = 0; /* key not recognised */
|
||||
}
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
Change this bit to your liking. I only set these values because
|
||||
they tie in with my keypads use of the keyboard controller chip
|
||||
see http://www.gofree.co.uk/home/smh/mp3 for details.
|
||||
Having said that try to make sure four keys map to D,B,C,A so you'll
|
||||
be able to quit LCDproc from the emulation.
|
||||
|
||||
*/
|
||||
case 'j' : i= 'D';break; /* left */
|
||||
case 'm' : i= 'B';break; /* up */
|
||||
case '7' : i= 'C';break; /* down */
|
||||
case 'u' : i= 'A';break; /* right */
|
||||
|
||||
case 'v':i='Q';break; /* one */
|
||||
case 'c':i='W';break; /* two */
|
||||
case 'z':i='E';break; /* three */
|
||||
case '4':i='R';break; /* four */
|
||||
case '3':i='T';break; /* five */
|
||||
case '1':i='Y';break; /* six */
|
||||
case 'f':i='U';break; /* seven */
|
||||
case 'd':i='I';break; /* eight */
|
||||
case 'a':i='O';break; /* nine */
|
||||
case 'e':i='P';break; /* zero */
|
||||
case 'r':i='L';break; /* 'C' key */
|
||||
default :
|
||||
i = 0;
|
||||
}
|
||||
} /* if (i) */
|
||||
/*
|
||||
Change this bit to your liking. I only set these values because
|
||||
they tie in with my keypads use of the keyboard controller chip
|
||||
see http://www.gofree.co.uk/home/smh/mp3 for details.
|
||||
Having said that try to make sure four keys map to D,B,C,A so you'll
|
||||
be able to quit LCDproc from the emulation.
|
||||
|
||||
*/
|
||||
case 'j':
|
||||
i = 'D';
|
||||
break; /* left */
|
||||
case 'm':
|
||||
i = 'B';
|
||||
break; /* up */
|
||||
case '7':
|
||||
i = 'C';
|
||||
break; /* down */
|
||||
case 'u':
|
||||
i = 'A';
|
||||
break; /* right */
|
||||
|
||||
case 'v':
|
||||
i = 'Q';
|
||||
break; /* one */
|
||||
case 'c':
|
||||
i = 'W';
|
||||
break; /* two */
|
||||
case 'z':
|
||||
i = 'E';
|
||||
break; /* three */
|
||||
case '4':
|
||||
i = 'R';
|
||||
break; /* four */
|
||||
case '3':
|
||||
i = 'T';
|
||||
break; /* five */
|
||||
case '1':
|
||||
i = 'Y';
|
||||
break; /* six */
|
||||
case 'f':
|
||||
i = 'U';
|
||||
break; /* seven */
|
||||
case 'd':
|
||||
i = 'I';
|
||||
break; /* eight */
|
||||
case 'a':
|
||||
i = 'O';
|
||||
break; /* nine */
|
||||
case 'e':
|
||||
i = 'P';
|
||||
break; /* zero */
|
||||
case 'r':
|
||||
i = 'L';
|
||||
break; /* 'C' key */
|
||||
default:
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
/* if (i) */
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,21 +4,21 @@
|
||||
|
||||
extern lcd_logical_driver *vgalib_drv;
|
||||
|
||||
int svgalib_drv_init(struct lcd_logical_driver *driver, char *args);
|
||||
void svgalib_drv_close();
|
||||
void svgalib_drv_clear();
|
||||
void svgalib_drv_flush();
|
||||
void svgalib_drv_string(int x, int y, char string[]);
|
||||
void svgalib_drv_chr(int x, int y, char c);
|
||||
void svgalib_drv_vbar(int x, int len);
|
||||
void svgalib_drv_hbar(int x, int y, int len);
|
||||
void svgalib_drv_icon(int which, char dest);
|
||||
void svgalib_drv_flush();
|
||||
void svgalib_drv_flush_box(int lft, int top, int rgt, int bot);
|
||||
void svgalib_drv_draw_frame(char *dat);
|
||||
char svgalib_drv_getkey();
|
||||
void svgalib_drv_init_num();
|
||||
void svgalib_drv_num(int x, int num);
|
||||
int svgalib_drv_init (struct lcd_logical_driver *driver, char *args);
|
||||
void svgalib_drv_close ();
|
||||
void svgalib_drv_clear ();
|
||||
void svgalib_drv_flush ();
|
||||
void svgalib_drv_string (int x, int y, char string[]);
|
||||
void svgalib_drv_chr (int x, int y, char c);
|
||||
void svgalib_drv_vbar (int x, int len);
|
||||
void svgalib_drv_hbar (int x, int y, int len);
|
||||
void svgalib_drv_icon (int which, char dest);
|
||||
void svgalib_drv_flush ();
|
||||
void svgalib_drv_flush_box (int lft, int top, int rgt, int bot);
|
||||
void svgalib_drv_draw_frame (char *dat);
|
||||
char svgalib_drv_getkey ();
|
||||
void svgalib_drv_init_num ();
|
||||
void svgalib_drv_num (int x, int num);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+116
-107
@@ -17,69 +17,72 @@ lcd_logical_driver *text;
|
||||
////////////////////// For Text-Mode Output //////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int text_init(lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
text_init (lcd_logical_driver * driver, char *args)
|
||||
{
|
||||
text = driver;
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
driver->close();
|
||||
|
||||
if (!driver->framebuf) {
|
||||
driver->close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
driver->clear = (void *)-1;
|
||||
driver->string = (void *)-1;
|
||||
driver->chr = (void *)-1;
|
||||
driver->vbar = text_vbar;
|
||||
driver->init_vbar = NULL;
|
||||
driver->hbar = text_hbar;
|
||||
driver->init_hbar = NULL;
|
||||
driver->num = (void *)-1;
|
||||
driver->init_num = NULL;
|
||||
|
||||
driver->init = text_init;
|
||||
driver->close = text_close;
|
||||
driver->flush = text_flush;
|
||||
driver->flush_box = NULL;
|
||||
driver->contrast = NULL;
|
||||
driver->backlight = NULL;
|
||||
driver->set_char = NULL;
|
||||
driver->icon = NULL;
|
||||
driver->draw_frame = text_draw_frame;
|
||||
|
||||
driver->getkey = NULL;
|
||||
}
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
driver->wid = 20;
|
||||
driver->hgt = 4;
|
||||
driver->cellwid = 5;
|
||||
driver->cellhgt = 8;
|
||||
|
||||
driver->clear = (void *) -1;
|
||||
driver->string = (void *) -1;
|
||||
driver->chr = (void *) -1;
|
||||
driver->vbar = text_vbar;
|
||||
driver->init_vbar = NULL;
|
||||
driver->hbar = text_hbar;
|
||||
driver->init_hbar = NULL;
|
||||
driver->num = (void *) -1;
|
||||
driver->init_num = NULL;
|
||||
|
||||
driver->init = text_init;
|
||||
driver->close = text_close;
|
||||
driver->flush = text_flush;
|
||||
driver->flush_box = NULL;
|
||||
driver->contrast = NULL;
|
||||
driver->backlight = NULL;
|
||||
driver->set_char = NULL;
|
||||
driver->icon = NULL;
|
||||
driver->draw_frame = text_draw_frame;
|
||||
|
||||
driver->getkey = NULL;
|
||||
|
||||
|
||||
return 200; // 200 is arbitrary. (must be 1 or more)
|
||||
}
|
||||
|
||||
void text_close()
|
||||
void
|
||||
text_close ()
|
||||
{
|
||||
drv_base_close();
|
||||
drv_base_close ();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Clears the LCD screen
|
||||
//
|
||||
void text_clear()
|
||||
void
|
||||
text_clear ()
|
||||
{
|
||||
memset(lcd.framebuf, ' ', lcd.wid*lcd.hgt);
|
||||
|
||||
memset (lcd.framebuf, ' ', lcd.wid * lcd.hgt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Flushes all output to the lcd...
|
||||
//
|
||||
void text_flush()
|
||||
void
|
||||
text_flush ()
|
||||
{
|
||||
text_draw_frame(lcd.framebuf);
|
||||
text_draw_frame (lcd.framebuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,40 +90,43 @@ void text_flush()
|
||||
// Prints a string on the lcd display, at position (x,y). The
|
||||
// upper-left is (1,1), and the lower right should be (20,4).
|
||||
//
|
||||
void text_string(int x, int y, char string[])
|
||||
void
|
||||
text_string (int x, int y, char string[])
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for(i=0; string[i]; i++)
|
||||
{
|
||||
lcd.framebuf[(y*lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
x -= 1; // Convert 1-based coords to 0-based...
|
||||
y -= 1;
|
||||
|
||||
for (i = 0; string[i]; i++) {
|
||||
lcd.framebuf[(y * lcd.wid) + x + i] = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void text_chr(int x, int y, char c)
|
||||
void
|
||||
text_chr (int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y*lcd.wid) + x] = c;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y * lcd.wid) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int text_contrast(int contrast)
|
||||
int
|
||||
text_contrast (int contrast)
|
||||
{
|
||||
// printf("Contrast: %i\n", contrast);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void text_backlight(int on)
|
||||
void
|
||||
text_backlight (int on)
|
||||
{
|
||||
/*
|
||||
if(on)
|
||||
@@ -134,27 +140,32 @@ void text_backlight(int on)
|
||||
*/
|
||||
}
|
||||
|
||||
void text_init_vbar()
|
||||
void
|
||||
text_init_vbar ()
|
||||
{
|
||||
// printf("Vertical bars.\n");
|
||||
}
|
||||
|
||||
void text_init_hbar()
|
||||
void
|
||||
text_init_hbar ()
|
||||
{
|
||||
// printf("Horizontal bars.\n");
|
||||
}
|
||||
|
||||
void text_init_num()
|
||||
void
|
||||
text_init_num ()
|
||||
{
|
||||
// printf("Big Numbers.\n");
|
||||
}
|
||||
|
||||
void text_num(int x, int num)
|
||||
void
|
||||
text_num (int x, int num)
|
||||
{
|
||||
// printf("BigNum(%i, %i)\n", x, num);
|
||||
}
|
||||
|
||||
void text_set_char(int n, char *dat)
|
||||
void
|
||||
text_set_char (int n, char *dat)
|
||||
{
|
||||
// printf("Set Character %i\n", n);
|
||||
}
|
||||
@@ -162,75 +173,73 @@ void text_set_char(int n, char *dat)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a vertical bar; erases entire column onscreen.
|
||||
//
|
||||
void text_vbar(int x, int len)
|
||||
void
|
||||
text_vbar (int x, int len)
|
||||
{
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
text_chr(x, y, '|');
|
||||
int y;
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
text_chr (x, y, '|');
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void text_hbar(int x, int y, int len)
|
||||
void
|
||||
text_hbar (int x, int y, int len)
|
||||
{
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
text_chr(x,y,'-');
|
||||
|
||||
for (; x <= lcd.wid && len > 0; x++) {
|
||||
text_chr (x, y, '-');
|
||||
|
||||
len -= lcd.cellwid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void text_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
text_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
text_flush();
|
||||
|
||||
text_flush ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void text_draw_frame(char *dat)
|
||||
void
|
||||
text_draw_frame (char *dat)
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
char out[LCD_MAX_WIDTH];
|
||||
char out[LCD_MAX_WIDTH];
|
||||
|
||||
if(!dat) return;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
// printf("Frame (%ix%i): \n%s\n", lcd.wid, lcd.hgt, dat);
|
||||
|
||||
for(i=0; i<lcd.wid; i++)
|
||||
{
|
||||
for (i = 0; i < lcd.wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("+%s+\n", out);
|
||||
|
||||
|
||||
for(i=0; i<lcd.hgt; i++)
|
||||
{
|
||||
for(j=0; j<lcd.wid; j++)
|
||||
{
|
||||
out[j] = dat[j+(i*lcd.wid)];
|
||||
}
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
|
||||
for (i = 0; i < lcd.hgt; i++) {
|
||||
for (j = 0; j < lcd.wid; j++) {
|
||||
out[j] = dat[j + (i * lcd.wid)];
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for(i=0; i<lcd.wid; i++)
|
||||
{
|
||||
printf ("|%s|\n", out);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < lcd.wid; i++) {
|
||||
out[i] = '-';
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf("+%s+\n", out);
|
||||
}
|
||||
out[lcd.wid] = 0;
|
||||
printf ("+%s+\n", out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -3,23 +3,23 @@
|
||||
|
||||
extern lcd_logical_driver *text;
|
||||
|
||||
int text_init(struct lcd_logical_driver *driver, char *args);
|
||||
void text_close();
|
||||
void text_clear();
|
||||
void text_flush();
|
||||
void text_string(int x, int y, char string[]);
|
||||
void text_chr(int x, int y, char c);
|
||||
int text_contrast(int contrast);
|
||||
void text_backlight(int on);
|
||||
void text_init_vbar();
|
||||
void text_init_hbar();
|
||||
void text_init_num();
|
||||
void text_vbar(int x, int len);
|
||||
void text_hbar(int x, int y, int len);
|
||||
void text_num(int x, int num);
|
||||
void text_set_char(int n, char *dat);
|
||||
void text_flush_box(int lft, int top, int rgt, int bot);
|
||||
void text_draw_frame(char *dat);
|
||||
int text_init (struct lcd_logical_driver *driver, char *args);
|
||||
void text_close ();
|
||||
void text_clear ();
|
||||
void text_flush ();
|
||||
void text_string (int x, int y, char string[]);
|
||||
void text_chr (int x, int y, char c);
|
||||
int text_contrast (int contrast);
|
||||
void text_backlight (int on);
|
||||
void text_init_vbar ();
|
||||
void text_init_hbar ();
|
||||
void text_init_num ();
|
||||
void text_vbar (int x, int len);
|
||||
void text_hbar (int x, int y, int len);
|
||||
void text_num (int x, int num);
|
||||
void text_set_char (int n, char *dat);
|
||||
void text_flush_box (int lft, int top, int rgt, int bot);
|
||||
void text_draw_frame (char *dat);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+370
-366
@@ -18,12 +18,13 @@
|
||||
#include "../../shared/debug.h"
|
||||
#include "../../shared/str.h"
|
||||
|
||||
static int custom=0;
|
||||
static int custom = 0;
|
||||
typedef enum {
|
||||
hbar = 1,
|
||||
vbar = 2,
|
||||
bign = 4,
|
||||
beat = 8 } custom_type;
|
||||
hbar = 1,
|
||||
vbar = 2,
|
||||
bign = 4,
|
||||
beat = 8
|
||||
} custom_type;
|
||||
|
||||
static int fd;
|
||||
static char lastframe[32];
|
||||
@@ -33,7 +34,8 @@ lcd_logical_driver *sli;
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Opens com port and sets baud correctly...
|
||||
//
|
||||
int sli_init(lcd_logical_driver *driver, char *args)
|
||||
int
|
||||
sli_init (lcd_logical_driver * driver, char *args)
|
||||
{
|
||||
char *argv[64];
|
||||
int argc;
|
||||
@@ -43,108 +45,95 @@ int sli_init(lcd_logical_driver *driver, char *args)
|
||||
char out[2];
|
||||
|
||||
char device[256] = "/dev/lcd";
|
||||
int speed=B19200;
|
||||
|
||||
int speed = B19200;
|
||||
|
||||
sli = driver;
|
||||
|
||||
//debug("sli_init: Args(all): %s\n", args);
|
||||
|
||||
argc = get_args(argv, args, 64);
|
||||
|
||||
argc = get_args (argv, args, 64);
|
||||
|
||||
/*
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
printf("Arg(%i): %s\n", i, argv[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
for(i=0; i<argc; i++)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
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, "sli_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
if (0 == strcmp (argv[i], "-d") || 0 == strcmp (argv[i], "--device")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "sli_init: %s requires an argument\n", argv[i]);
|
||||
return -1;
|
||||
}
|
||||
strcpy(device, argv[++i]);
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-s") ||
|
||||
0 == strcmp(argv[i], "--speed"))
|
||||
{
|
||||
if(i + 1 > argc) {
|
||||
fprintf(stderr, "sli_init: %s requires an argument\n",
|
||||
argv[i]);
|
||||
strcpy (device, argv[++i]);
|
||||
} else if (0 == strcmp (argv[i], "-s") || 0 == strcmp (argv[i], "--speed")) {
|
||||
if (i + 1 > argc) {
|
||||
fprintf (stderr, "sli_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 if(tmp==38400) speed=B38400;
|
||||
else if(tmp==57600) speed=B57600;
|
||||
else if(tmp==115200) speed=B115200;
|
||||
else {
|
||||
fprintf(stderr, "sli_init: %s argument must be 1200, 2400, 9600, 19200, 38400, 57600, or 115200. Using default value (19200).\n",
|
||||
argv[i]);
|
||||
}
|
||||
}
|
||||
else if(0 == strcmp(argv[i], "-h") ||
|
||||
0 == strcmp(argv[i], "--help"))
|
||||
{
|
||||
printf("LCDproc Wirz SLI LCD driver\n"
|
||||
"\t-d\t--device\tSelect the output device to use [/dev/lcd]\n"
|
||||
"\t-s\t--speed\t\tSet the communication speed [19200]\n"
|
||||
"\t-h\t--help\t\tShow this help information\n");
|
||||
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 if (tmp == 38400)
|
||||
speed = B38400;
|
||||
else if (tmp == 57600)
|
||||
speed = B57600;
|
||||
else if (tmp == 115200)
|
||||
speed = B115200;
|
||||
else {
|
||||
fprintf (stderr, "sli_init: %s argument must be 1200, 2400, 9600, 19200, 38400, 57600, or 115200. Using default value (19200).\n", argv[i]);
|
||||
}
|
||||
} else if (0 == strcmp (argv[i], "-h") || 0 == strcmp (argv[i], "--help")) {
|
||||
printf ("LCDproc Wirz SLI LCD driver\n" "\t-d\t--device\tSelect the output device to use [/dev/lcd]\n" "\t-s\t--speed\t\tSet the communication speed [19200]\n" "\t-h\t--help\t\tShow this help information\n");
|
||||
return -1;
|
||||
} else {
|
||||
printf ("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid parameter: %s\n", argv[i]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set up io port correctly, and open it...
|
||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1)
|
||||
{
|
||||
fprintf(stderr, "sli_init: failed (%s)\n", strerror(errno));
|
||||
fd = open (device, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
if (fd == -1) {
|
||||
fprintf (stderr, "sli_init: failed (%s)\n", strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
//else fprintf(stderr, "sli_init: opened device %s\n", device);
|
||||
tcgetattr(fd, &portset);
|
||||
tcgetattr (fd, &portset);
|
||||
// This is necessary in Linux, but does not exist in irix.
|
||||
#ifndef IRIX
|
||||
cfmakeraw(&portset);
|
||||
cfmakeraw (&portset);
|
||||
#endif
|
||||
cfsetospeed(&portset, speed);
|
||||
tcsetattr(fd, TCSANOW, &portset);
|
||||
cfsetospeed (&portset, speed);
|
||||
tcsetattr (fd, TCSANOW, &portset);
|
||||
|
||||
/* Initialize SLI using autobaud detection, and then turn off cursor
|
||||
and clear screen */
|
||||
usleep(150000); /* 150ms delay to allow SLI to power on */
|
||||
out[0]=13; /* CR for SLI autobaud */
|
||||
write(fd, out, 1);
|
||||
usleep(3000); /* 3ms delay.. wait for it to autobaud */
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x00C; /* No cursor */
|
||||
write(fd, out, 2);
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x001; /* Clear LCD, not sure if this belongs here */
|
||||
write(fd, out, 2);
|
||||
usleep (150000); /* 150ms delay to allow SLI to power on */
|
||||
out[0] = 13; /* CR for SLI autobaud */
|
||||
write (fd, out, 1);
|
||||
usleep (3000); /* 3ms delay.. wait for it to autobaud */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x00C; /* No cursor */
|
||||
write (fd, out, 2);
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x001; /* Clear LCD, not sure if this belongs here */
|
||||
write (fd, out, 2);
|
||||
|
||||
|
||||
if(!driver->framebuf)
|
||||
{
|
||||
fprintf(stderr, "sli_init: No frame buffer.\n");
|
||||
driver->close();
|
||||
|
||||
if (!driver->framebuf) {
|
||||
fprintf (stderr, "sli_init: No frame buffer.\n");
|
||||
driver->close ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set LCD parameters (I use a 16x2 LCD) -- small but still useful
|
||||
// Its also much cheaper than the higher quality Matrix Orbital modules
|
||||
// Currently, $30 for interface kit and 16x2 non-backlit LCD...
|
||||
@@ -154,46 +143,49 @@ int sli_init(lcd_logical_driver *driver, char *args)
|
||||
|
||||
// Set the functions the driver supports...
|
||||
|
||||
driver->clear = (void *)-1;
|
||||
driver->string = (void *)-1;
|
||||
driver->chr = (void *)-1;
|
||||
driver->vbar = sli_vbar;
|
||||
driver->init_vbar = sli_init_vbar;
|
||||
driver->hbar = sli_hbar;
|
||||
driver->init_hbar = sli_init_hbar;
|
||||
driver->num = (void *)-1;
|
||||
driver->init_num = (void *)-1;
|
||||
driver->clear = (void *) -1;
|
||||
driver->string = (void *) -1;
|
||||
driver->chr = (void *) -1;
|
||||
driver->vbar = sli_vbar;
|
||||
driver->init_vbar = sli_init_vbar;
|
||||
driver->hbar = sli_hbar;
|
||||
driver->init_hbar = sli_init_hbar;
|
||||
driver->num = (void *) -1;
|
||||
driver->init_num = (void *) -1;
|
||||
|
||||
driver->init = sli_init;
|
||||
driver->close = sli_close;
|
||||
driver->flush = sli_flush;
|
||||
driver->flush_box = sli_flush_box;
|
||||
driver->contrast = (void *)-1;
|
||||
driver->backlight = (void *)-1;
|
||||
driver->set_char = sli_set_char;
|
||||
driver->icon = sli_icon;
|
||||
driver->init = sli_init;
|
||||
driver->close = sli_close;
|
||||
driver->flush = sli_flush;
|
||||
driver->flush_box = sli_flush_box;
|
||||
driver->contrast = (void *) -1;
|
||||
driver->backlight = (void *) -1;
|
||||
driver->set_char = sli_set_char;
|
||||
driver->icon = sli_icon;
|
||||
driver->draw_frame = sli_draw_frame;
|
||||
|
||||
driver->getkey = (void *)-1;
|
||||
|
||||
driver->getkey = (void *) -1;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
/* Clean-up */
|
||||
void sli_close()
|
||||
void
|
||||
sli_close ()
|
||||
{
|
||||
close(fd);
|
||||
close (fd);
|
||||
|
||||
if(sli->framebuf) free(sli->framebuf);
|
||||
if (sli->framebuf)
|
||||
free (sli->framebuf);
|
||||
|
||||
sli->framebuf = NULL;
|
||||
sli->framebuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
void sli_flush()
|
||||
void
|
||||
sli_flush ()
|
||||
{
|
||||
sli_draw_frame(lcd.framebuf);
|
||||
sli_draw_frame (lcd.framebuf);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,44 +193,45 @@ void sli_flush()
|
||||
this is bad imho, so I added it.. may remove later
|
||||
speed is not a huge issue though, this isnt a
|
||||
device driver or anything ;) */
|
||||
void sli_flush_box(int lft, int top, int rgt, int bot)
|
||||
void
|
||||
sli_flush_box (int lft, int top, int rgt, int bot)
|
||||
{
|
||||
int y;
|
||||
char out[2]; /* Why does the matrix driver allocate so much here? */
|
||||
int y;
|
||||
char out[2]; /* Why does the matrix driver allocate so much here? */
|
||||
|
||||
/* simple bounds checking */
|
||||
if((top>lcd.hgt)|(bot>lcd.hgt))
|
||||
return;
|
||||
/* simple bounds checking */
|
||||
if ((top > lcd.hgt) | (bot > lcd.hgt))
|
||||
return;
|
||||
|
||||
if ((lft > lcd.wid) | (rgt > lcd.wid))
|
||||
return;
|
||||
|
||||
if((lft>lcd.wid)|(rgt>lcd.wid))
|
||||
return;
|
||||
|
||||
// printf("Flush (%i,%i)-(%i,%i)\n", lft, top, rgt, bot);
|
||||
|
||||
/* I like having hex, everywhere and all the time */
|
||||
for(y=top; y<=bot; y++)
|
||||
{
|
||||
if(y==1)
|
||||
sprintf(out, "%c%c", 0x0FE, 0x080+lft);
|
||||
if(y==2)
|
||||
sprintf(out, "%c%c", 0x0FE, 0x0C0+lft);
|
||||
write(fd, out, 0x002);
|
||||
write(fd, lcd.framebuf+(y*lcd.wid)+lft, rgt-lft+1);
|
||||
}
|
||||
|
||||
|
||||
for (y = top; y <= bot; y++) {
|
||||
if (y == 1)
|
||||
sprintf (out, "%c%c", 0x0FE, 0x080 + lft);
|
||||
if (y == 2)
|
||||
sprintf (out, "%c%c", 0x0FE, 0x0C0 + lft);
|
||||
write (fd, out, 0x002);
|
||||
write (fd, lcd.framebuf + (y * lcd.wid) + lft, rgt - lft + 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// 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).
|
||||
//
|
||||
void sli_chr(int x, int y, char c)
|
||||
void
|
||||
sli_chr (int x, int y, char c)
|
||||
{
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y*lcd.wid) + x] = c;
|
||||
y--;
|
||||
x--;
|
||||
|
||||
lcd.framebuf[(y * lcd.wid) + x] = c;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,145 +248,147 @@ void sli_chr(int x, int y, char c)
|
||||
characters, so that you can do both bar types at once.. maybe I
|
||||
will release a new version of the SLI driver that attempts this */
|
||||
|
||||
void sli_init_vbar()
|
||||
void
|
||||
sli_init_vbar ()
|
||||
{
|
||||
char a[] = {
|
||||
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,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char b[] = {
|
||||
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,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char c[] = {
|
||||
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,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char d[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char e[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char f[] = {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char g[] = {
|
||||
0,0,0,0,0,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
1,1,1,1,1,
|
||||
};
|
||||
char a[] = {
|
||||
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,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char b[] = {
|
||||
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, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char c[] = {
|
||||
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, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char d[] = {
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char e[] = {
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char f[] = {
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
char g[] = {
|
||||
0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1,
|
||||
};
|
||||
|
||||
if(custom!=vbar) {
|
||||
sli_set_char(1,a);
|
||||
sli_set_char(2,b);
|
||||
sli_set_char(3,c);
|
||||
sli_set_char(4,d);
|
||||
sli_set_char(5,e);
|
||||
sli_set_char(6,f);
|
||||
sli_set_char(7,g);
|
||||
custom=vbar;
|
||||
}
|
||||
if (custom != vbar) {
|
||||
sli_set_char (1, a);
|
||||
sli_set_char (2, b);
|
||||
sli_set_char (3, c);
|
||||
sli_set_char (4, d);
|
||||
sli_set_char (5, e);
|
||||
sli_set_char (6, f);
|
||||
sli_set_char (7, g);
|
||||
custom = vbar;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Inits horizontal bars...
|
||||
//
|
||||
void sli_init_hbar()
|
||||
void
|
||||
sli_init_hbar ()
|
||||
{
|
||||
|
||||
char a[] = {
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
1,0,0,0,0,
|
||||
};
|
||||
char b[] = {
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
1,1,0,0,0,
|
||||
};
|
||||
char c[] = {
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
1,1,1,0,0,
|
||||
};
|
||||
char d[] = {
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
1,1,1,1,0,
|
||||
};
|
||||
char a[] = {
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
};
|
||||
char b[] = {
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
};
|
||||
char c[] = {
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
};
|
||||
char d[] = {
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 0,
|
||||
};
|
||||
|
||||
if(custom!=hbar) {
|
||||
sli_set_char(1,a);
|
||||
sli_set_char(2,b);
|
||||
sli_set_char(3,c);
|
||||
sli_set_char(4,d);
|
||||
custom=hbar;
|
||||
}
|
||||
if (custom != hbar) {
|
||||
sli_set_char (1, a);
|
||||
sli_set_char (2, b);
|
||||
sli_set_char (3, c);
|
||||
sli_set_char (4, d);
|
||||
custom = hbar;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
@@ -405,37 +400,41 @@ void sli_init_hbar()
|
||||
since we only have 2 lines anyway this is rather pointless
|
||||
for me to add */
|
||||
|
||||
void sli_vbar(int x, int len)
|
||||
void
|
||||
sli_vbar (int x, int len)
|
||||
{
|
||||
char map[9] = {32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
char map[9] = { 32, 1, 2, 3, 4, 5, 6, 7, 255 };
|
||||
|
||||
int y;
|
||||
for(y=lcd.hgt; y > 0 && len>0; y--)
|
||||
{
|
||||
if(len >= lcd.cellhgt) sli_chr(x, y, 255);
|
||||
else sli_chr(x, y, map[len]);
|
||||
|
||||
int y;
|
||||
for (y = lcd.hgt; y > 0 && len > 0; y--) {
|
||||
if (len >= lcd.cellhgt)
|
||||
sli_chr (x, y, 255);
|
||||
else
|
||||
sli_chr (x, y, map[len]);
|
||||
|
||||
len -= lcd.cellhgt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Draws a horizontal bar to the right.
|
||||
//
|
||||
void sli_hbar(int x, int y, int len)
|
||||
void
|
||||
sli_hbar (int x, int y, int len)
|
||||
{
|
||||
char map[6] = { 32, 1, 2, 3, 4, 255 };
|
||||
char map[6] = { 32, 1, 2, 3, 4, 255 };
|
||||
|
||||
for (; x <= lcd.wid && len > 0; x++) {
|
||||
if (len >= lcd.cellwid)
|
||||
sli_chr (x, y, 255);
|
||||
else
|
||||
sli_chr (x, y, map[len]);
|
||||
|
||||
for(; x<=lcd.wid && len>0; x++)
|
||||
{
|
||||
if(len >= lcd.cellwid) sli_chr(x,y,255);
|
||||
else sli_chr(x, y, map[len]);
|
||||
|
||||
len -= lcd.cellwid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -447,80 +446,83 @@ void sli_hbar(int x, int y, int len)
|
||||
//
|
||||
// The input is just an array of characters...
|
||||
//
|
||||
void sli_set_char(int n, char *dat)
|
||||
void
|
||||
sli_set_char (int n, char *dat)
|
||||
{
|
||||
char out[2];
|
||||
int row, col;
|
||||
int letter;
|
||||
char out[2];
|
||||
int row, col;
|
||||
int letter;
|
||||
|
||||
/* SLI also has 8 user definable characters */
|
||||
if(n < 0 || n > 7) return;
|
||||
if(!dat) return;
|
||||
/* SLI also has 8 user definable characters */
|
||||
if (n < 0 || n > 7)
|
||||
return;
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
/* Move cursor to CGRAM */
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x040+8*n;
|
||||
write(fd, out, 2);
|
||||
/* Move cursor to CGRAM */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x040 + 8 * n;
|
||||
write (fd, out, 2);
|
||||
|
||||
for(row=0; row<lcd.cellhgt; row++)
|
||||
{
|
||||
letter = 0;
|
||||
for(col=0; col<lcd.cellwid; col++)
|
||||
{
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row*lcd.cellwid) + col] > 0);
|
||||
}
|
||||
letter|=0x020; /* SLI can't accept CR, LF, etc in this character! */
|
||||
write(fd, &letter, 1);
|
||||
}
|
||||
for (row = 0; row < lcd.cellhgt; row++) {
|
||||
letter = 0;
|
||||
for (col = 0; col < lcd.cellwid; col++) {
|
||||
letter <<= 1;
|
||||
letter |= (dat[(row * lcd.cellwid) + col] > 0);
|
||||
}
|
||||
letter |= 0x020; /* SLI can't accept CR, LF, etc in this character! */
|
||||
write (fd, &letter, 1);
|
||||
}
|
||||
|
||||
/* Move cursor back to DDRAM */
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x080;
|
||||
write(fd, out, 2);
|
||||
/* Move cursor back to DDRAM */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x080;
|
||||
write (fd, out, 2);
|
||||
}
|
||||
|
||||
|
||||
void sli_icon(int which, char dest)
|
||||
void
|
||||
sli_icon (int which, char dest)
|
||||
{
|
||||
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,
|
||||
},
|
||||
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,
|
||||
},
|
||||
|
||||
{
|
||||
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,
|
||||
},
|
||||
|
||||
{
|
||||
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,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
if(custom==bign) custom=beat;
|
||||
sli_set_char(dest, &icons[which][0]);
|
||||
{
|
||||
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,
|
||||
},
|
||||
|
||||
{
|
||||
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,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
if (custom == bign)
|
||||
custom = beat;
|
||||
sli_set_char (dest, &icons[which][0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -529,34 +531,36 @@ void sli_icon(int which, char dest)
|
||||
//
|
||||
// Input is a character array, sized lcd.wid*lcd.hgt
|
||||
//
|
||||
void sli_draw_frame(char *dat)
|
||||
void
|
||||
sli_draw_frame (char *dat)
|
||||
{
|
||||
char out[2]; /* Again, why does the Matrix driver allocate so much here? */
|
||||
int y;
|
||||
|
||||
if(!dat) return;
|
||||
char out[2]; /* Again, why does the Matrix driver allocate so much here? */
|
||||
int y;
|
||||
|
||||
/*
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x001;
|
||||
write(fd, out, 2);
|
||||
*/
|
||||
if (!dat)
|
||||
return;
|
||||
|
||||
/* Don't update if we have no new data
|
||||
this keeps me from getting a migraine
|
||||
(just like those copyleft penguin mints... mmmmmm) */
|
||||
/*
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x001;
|
||||
write(fd, out, 2);
|
||||
*/
|
||||
|
||||
// if (!strncmp(dat,lastframe,32)) /* Nothing has changed */
|
||||
// return;
|
||||
/* Don't update if we have no new data
|
||||
this keeps me from getting a migraine
|
||||
(just like those copyleft penguin mints... mmmmmm) */
|
||||
|
||||
/* Do the actual refresh */
|
||||
out[0]=0x0FE;
|
||||
out[1]=0x080;
|
||||
write(fd, out, 2);
|
||||
write(fd, &dat[0], 16);
|
||||
usleep(10);
|
||||
write(fd, &dat[16],15);
|
||||
// if (!strncmp(dat,lastframe,32)) /* Nothing has changed */
|
||||
// return;
|
||||
|
||||
// strncpy(lastframe,dat,32); // Update lastframe...
|
||||
/* Do the actual refresh */
|
||||
out[0] = 0x0FE;
|
||||
out[1] = 0x080;
|
||||
write (fd, out, 2);
|
||||
write (fd, &dat[0], 16);
|
||||
usleep (10);
|
||||
write (fd, &dat[16], 15);
|
||||
|
||||
// strncpy(lastframe,dat,32); // Update lastframe...
|
||||
|
||||
}
|
||||
|
||||
+17
-17
@@ -10,23 +10,23 @@
|
||||
|
||||
extern lcd_logical_driver *sli;
|
||||
|
||||
int sli_init(lcd_logical_driver *driver, char *device);
|
||||
void sli_close();
|
||||
void sli_flush();
|
||||
void sli_flush_box(int lft, int top, int rgt, int bot);
|
||||
void sli_chr(int x, int y, char c) ;
|
||||
int sli_contrast(int contrast);
|
||||
void sli_backlight(int on);
|
||||
void sli_init_vbar();
|
||||
void sli_init_hbar();
|
||||
void sli_vbar(int x, int len);
|
||||
void sli_hbar(int x, int y, int len);
|
||||
void sli_init_num();
|
||||
void sli_num(int x, int num);
|
||||
void sli_set_char(int n, char *dat);
|
||||
void sli_icon(int which, char dest);
|
||||
void sli_draw_frame(char *dat);
|
||||
char sli_getkey();
|
||||
int sli_init (lcd_logical_driver * driver, char *device);
|
||||
void sli_close ();
|
||||
void sli_flush ();
|
||||
void sli_flush_box (int lft, int top, int rgt, int bot);
|
||||
void sli_chr (int x, int y, char c);
|
||||
int sli_contrast (int contrast);
|
||||
void sli_backlight (int on);
|
||||
void sli_init_vbar ();
|
||||
void sli_init_hbar ();
|
||||
void sli_vbar (int x, int len);
|
||||
void sli_hbar (int x, int y, int len);
|
||||
void sli_init_num ();
|
||||
void sli_num (int x, int num);
|
||||
void sli_set_char (int n, char *dat);
|
||||
void sli_icon (int which, char dest);
|
||||
void sli_draw_frame (char *dat);
|
||||
char sli_getkey ();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user