Updated text driver:

+ Uses syslog instead of printf's
+ No dependency on global lcd struct
+ Fixed bug which would've occured when no framebuffer found on init
This commit is contained in:
ddouthitt
2001-09-25 07:29:38 +00:00
parent ba630ec1d2
commit 4a75325042
+33 -32
View File
@@ -30,43 +30,46 @@ lcd_logical_driver *text;
#define LCD_DEFAULT_CELL_WIDTH 5 #define LCD_DEFAULT_CELL_WIDTH 5
#define LCD_DEFAULT_CELL_HEIGHT 8 #define LCD_DEFAULT_CELL_HEIGHT 8
// TODO: When using the text driver, ^C fails to interrupt!
// Why? Fix it...
int int
text_init (lcd_logical_driver * driver, char *args) text_init (lcd_logical_driver * driver, char *args)
{ {
text = driver; text = driver;
if (!driver->framebuf) { if (!text->framebuf) {
syslog(LOG_ERR, "text: no frame buffer!"); syslog(LOG_ERR, "text: no frame buffer!");
driver->close (); text_close ();
return -1; return -1;
} }
driver->wid = LCD_DEFAULT_WIDTH; text->wid = LCD_DEFAULT_WIDTH;
driver->hgt = LCD_DEFAULT_HEIGHT; text->hgt = LCD_DEFAULT_HEIGHT;
driver->cellwid = LCD_DEFAULT_CELL_WIDTH; text->cellwid = LCD_DEFAULT_CELL_WIDTH;
driver->cellhgt = LCD_DEFAULT_CELL_HEIGHT; text->cellhgt = LCD_DEFAULT_CELL_HEIGHT;
driver->clear = text_clear; text->clear = text_clear;
driver->string = text_string; text->string = text_string;
driver->chr = text_chr; text->chr = text_chr;
driver->vbar = text_vbar; text->vbar = text_vbar;
//driver->init_vbar = NULL; //text->init_vbar = NULL;
driver->hbar = text_hbar; text->hbar = text_hbar;
//driver->init_hbar = NULL; //text->init_hbar = NULL;
driver->num = text_num; text->num = text_num;
//driver->init_num = NULL; //text->init_num = NULL;
driver->init = text_init; text->init = text_init;
driver->close = text_close; text->close = text_close;
driver->flush = text_flush; text->flush = text_flush;
//driver->flush_box = NULL; //text->flush_box = NULL;
//driver->contrast = NULL; //text->contrast = NULL;
//driver->backlight = NULL; //text->backlight = NULL;
//driver->set_char = NULL; //text->set_char = NULL;
//driver->icon = NULL; //text->icon = NULL;
driver->draw_frame = text_draw_frame; text->draw_frame = text_draw_frame;
//driver->getkey = NULL; //text->getkey = NULL;
return 200; // 200 is arbitrary. (must be 1 or more) return 200; // 200 is arbitrary. (must be 1 or more)
} }
@@ -74,10 +77,10 @@ text_init (lcd_logical_driver * driver, char *args)
void void
text_close () text_close ()
{ {
if (lcd.framebuf != NULL) if (text->framebuf != NULL)
free (lcd.framebuf); free (text->framebuf);
lcd.framebuf = NULL; text->framebuf = NULL;
} }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -108,8 +111,7 @@ text_string (int x, int y, char string[])
{ {
int i; int i;
x -= 1; // Convert 1-based coords to 0-based... x--; y--; // Convert 1-based coords to 0-based...
y -= 1;
for (i = 0; string[i]; i++) { for (i = 0; string[i]; i++) {
text->framebuf[(y * text->wid) + x + i] = string[i]; text->framebuf[(y * text->wid) + x + i] = string[i];
@@ -123,8 +125,7 @@ text_string (int x, int y, char string[])
void void
text_chr (int x, int y, char c) text_chr (int x, int y, char c)
{ {
y--; y--; x--;
x--;
text->framebuf[(y * text->wid) + x] = c; text->framebuf[(y * text->wid) + x] = c;
} }