v0.5 kick-off

This commit is contained in:
robijn
2001-12-30 00:15:25 +00:00
parent c28d25b795
commit 71056ec551
88 changed files with 6638 additions and 5469 deletions
+139 -122
View File
@@ -6,9 +6,28 @@
#include <string.h>
#include <sys/errno.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "lcd.h"
#include "debug.h"
#include "shared/report.h"
#include "report.h"
// Variables
static char *framebuf = NULL;
static int width = LCD_DEFAULT_WIDTH;
static int height = LCD_DEFAULT_HEIGHT;
// Vars for the server core
MODULE_EXPORT char *api_version = API_VERSION;
MODULE_EXPORT int stay_in_foreground = 1;
MODULE_EXPORT int supports_multiple = 0;
MODULE_EXPORT char *symbol_prefix = "debug_";
//////////////////////////////////////////////////////////////////////////
////////////////////// For Debugging Output //////////////////////////////
@@ -17,86 +36,127 @@
// TODO: somehow allow access to the driver->framebuffer to each
// function...
static lcd_logical_driver *debug_drv;
int
debug_init (struct lcd_logical_driver *driver, char *args)
debug_init (Driver *drvthis, char *args)
{
report (RPT_INFO, "debug_init()");
debug_drv = driver;
framebuf = malloc (width * height);
debug_clear ();
debug_clear (drvthis);
driver->daemonize = 0;
// Set variables for server
drvthis->api_version = api_version;
drvthis->stay_in_foreground = &stay_in_foreground;
drvthis->supports_multiple = &supports_multiple;
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;
// Set the functions the driver supports
drvthis->clear = debug_clear;
drvthis->string = debug_string;
drvthis->chr = debug_chr;
drvthis->old_vbar = debug_vbar;
drvthis->old_hbar = debug_hbar;
drvthis->init_num = debug_init_num;
drvthis->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;
drvthis->init = debug_init;
drvthis->close = debug_close;
drvthis->width = debug_width;
drvthis->height = debug_height;
drvthis->flush = debug_flush;
drvthis->set_contrast = debug_set_contrast;
drvthis->backlight = debug_backlight;
drvthis->set_char = debug_set_char;
drvthis->old_icon = debug_icon;
drvthis->init_vbar = debug_init_vbar;
drvthis->init_hbar = debug_init_hbar;
driver->getkey = debug_getkey;
drvthis->getkey = debug_getkey;
return 200; // 200 is arbitrary. (must be 1 or more)
return 0;
}
void
debug_close ()
/////////////////////////////////////////////////////////////////
// Closes the driver
//
MODULE_EXPORT void
debug_close (Driver *drvthis)
{
report (RPT_INFO, "debug_close()");
if (debug_drv->framebuf) {
report (RPT_DEBUG, "frame buffer: %010X", (int) debug_drv->framebuf);
free (debug_drv->framebuf);
}
if(framebuf) free (framebuf);
framebuf = NULL;
}
debug_drv->framebuf = NULL;
/////////////////////////////////////////////////////////////////
// Returns the display width
//
MODULE_EXPORT int
debug_width (Driver *drvthis)
{
return width;
}
/////////////////////////////////////////////////////////////////
// Returns the display height
//
MODULE_EXPORT int
debug_height (Driver *drvthis)
{
return height;
}
/////////////////////////////////////////////////////////////////
// Clears the LCD screen
//
void
debug_clear ()
MODULE_EXPORT void
debug_clear (Driver *drvthis)
{
report (RPT_INFO, "clear()");
memset (debug_drv->framebuf, ' ', debug_drv->wid * debug_drv->hgt);
memset (framebuf, ' ', width * height);
}
//////////////////////////////////////////////////////////////////
// Flushes all output to the lcd...
//
void
debug_flush ()
MODULE_EXPORT void
debug_flush (Driver *drvthis)
{
int i, j;
char out[LCD_MAX_WIDTH];
report (RPT_INFO, "flush()");
debug_drv->draw_frame ();
for (i = 0; i < width; i++) {
out[i] = '-';
}
out[width] = 0;
//report (RPT_DEBUG, "+%s+", out);
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
out[j] = framebuf[j + (i * width)];
}
out[width] = 0;
//report (RPT_DEBUG, "|%s|", out);
}
for (i = 0; i < width; i++) {
out[i] = '-';
}
out[width] = 0;
//report (RPT_DEBUG, "+%s+", out);
}
/////////////////////////////////////////////////////////////////
// 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[])
MODULE_EXPORT void
debug_string (Driver *drvthis, int x, int y, char string[])
{
int i;
@@ -106,7 +166,7 @@ debug_string (int x, int y, char string[])
y --; x --; // Convert 1-based coords to 0-based...
for (i = 0; string[i]; i++) {
debug_drv->framebuf[(y * debug_drv->wid) + x + i] = string[i];
framebuf[(y * width) + x + i] = string[i];
}
}
@@ -114,54 +174,53 @@ debug_string (int x, int y, char 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
debug_chr (int x, int y, char c)
MODULE_EXPORT void
debug_chr (Driver *drvthis, int x, int y, char c)
{
report (RPT_DEBUG, "char(%i,%i,%c)", x, y, c);
x--; y--;
debug_drv->framebuf[(y * debug_drv->wid) + x] = c;
framebuf[(y * width) + x] = c;
}
int
debug_contrast (int contrast)
MODULE_EXPORT void
debug_set_contrast (Driver *drvthis, int promille)
{
report (RPT_INFO, "contrast(%i)", contrast);
return 0;
report (RPT_INFO, "set_contrast(%i)", promille);
}
void
debug_backlight (int on)
MODULE_EXPORT void
debug_backlight (Driver *drvthis, int on)
{
report (RPT_INFO, "backlight(%i)", on);
}
void
debug_init_vbar ()
MODULE_EXPORT void
debug_init_vbar (Driver *drvthis)
{
report (LOG_INFO, "init_vbar()");
report (RPT_INFO, "init_vbar()");
}
void
debug_init_hbar ()
MODULE_EXPORT void
debug_init_hbar (Driver *drvthis)
{
report (RPT_INFO, "init_hbar()");
}
void
debug_init_num ()
MODULE_EXPORT void
debug_init_num (Driver *drvthis)
{
report (RPT_INFO, "init_bignum()");
}
void
debug_num (int x, int num)
MODULE_EXPORT void
debug_num (Driver *drvthis, int x, int num)
{
report (RPT_INFO, "big number(%i,%i)", x, num);
}
void
debug_set_char (int n, char *dat)
MODULE_EXPORT void
debug_set_char (Driver *drvthis, int n, char *dat)
{
report (RPT_INFO, "set_char(%i,data)", n);
}
@@ -169,17 +228,17 @@ debug_set_char (int n, char *dat)
/////////////////////////////////////////////////////////////////
// Draws a vertical bar; erases entire column onscreen.
//
void
debug_vbar (int x, int len)
MODULE_EXPORT void
debug_vbar (Driver *drvthis, int x, int len)
{
int y;
report (RPT_INFO, "vbar(%i,%i)", x, len);
for (y = debug_drv->hgt; y > 0 && len > 0; y--) {
debug_chr (x, y, '|');
for (y = height; y > 0 && len > 0; y--) {
debug_chr (drvthis, x, y, '|');
len -= debug_drv->cellhgt;
len -= LCD_DEFAULT_CELLHEIGHT;
}
}
@@ -187,15 +246,15 @@ debug_vbar (int x, int len)
/////////////////////////////////////////////////////////////////
// Draws a horizontal bar to the right.
//
void
debug_hbar (int x, int y, int len)
MODULE_EXPORT void
debug_hbar (Driver *drvthis, int x, int y, int len)
{
report (RPT_INFO, "hbar(%i,%i,%i)", x, y, len);
for (; x < debug_drv->wid && len > 0; x++) {
debug_chr (x, y, '-');
for (; x < width && len > 0; x++) {
debug_chr (drvthis, x, y, '-');
len -= debug_drv->cellwid;
len -= LCD_DEFAULT_CELLWIDTH;
}
}
@@ -203,59 +262,17 @@ debug_hbar (int x, int y, int len)
/////////////////////////////////////////////////////////////////
// Sets character 0 to an icon...
//
void
debug_icon (int which, char dest)
MODULE_EXPORT void
debug_icon (Driver *drvthis, int which, char dest)
{
report (RPT_INFO, "icon(%i,%i", which, dest);
}
void
debug_flush_box (int lft, int top, int rgt, int bot)
{
report (RPT_INFO, "flush_box(%i,%i,%i,%i)", lft, top, rgt, bot);
debug_flush ();
}
void
debug_draw_frame (char *dat)
{
int i, j;
char out[LCD_MAX_WIDTH];
report (RPT_INFO, "draw_frame(data)");
if (!dat)
return;
// report (RPT_DEBUG, "Frame (%ix%i): %s", debug_drv->wid, debug_drv->hgt, dat);
for (i = 0; i < debug_drv->wid; i++) {
out[i] = '-';
}
out[debug_drv->wid] = 0;
//report (RPT_DEBUG, "+%s+", out);
for (i = 0; i < debug_drv->hgt; i++) {
for (j = 0; j < debug_drv->wid; j++) {
out[j] = dat[j + (i * debug_drv->wid)];
}
out[debug_drv->wid] = 0;
//report (RPT_DEBUG, "|%s|", out);
}
for (i = 0; i < debug_drv->wid; i++) {
out[i] = '-';
}
out[debug_drv->wid] = 0;
//report (RPT_DEBUG, "+%s+", out);
}
char
debug_getkey ()
/////////////////////////////////////////////////////////////////
// Return a keypress
//
MODULE_EXPORT char
debug_getkey (Driver *drvthis)
{
report (RPT_INFO, "getkey()");
return 0;