1999-12-09 23:15:14 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <termios.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
1999-12-11 19:21:29 +00:00
|
|
|
#include "lcd.h"
|
1999-12-09 23:15:14 +00:00
|
|
|
#include "debug.h"
|
2001-12-30 00:15:25 +00:00
|
|
|
#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_";
|
|
|
|
|
|
|
|
|
|
|
1999-12-09 23:15:14 +00:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
////////////////////// For Debugging Output //////////////////////////////
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// TODO: somehow allow access to the driver->framebuffer to each
|
|
|
|
|
// function...
|
|
|
|
|
|
2002-02-21 22:50:12 +00:00
|
|
|
MODULE_EXPORT int
|
2005-07-02 13:38:51 +00:00
|
|
|
debug_init (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "debug_init()");
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
framebuf = malloc (width * height);
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
debug_clear (drvthis);
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
return 0;
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Closes the driver
|
|
|
|
|
//
|
|
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_close (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "debug_close()");
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
if(framebuf) free (framebuf);
|
|
|
|
|
framebuf = NULL;
|
|
|
|
|
}
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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;
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Clears the LCD screen
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_clear (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "clear()");
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
memset (framebuf, ' ', width * height);
|
2000-03-30 20:20:41 +00:00
|
|
|
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
// Flushes all output to the lcd...
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_flush (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-12-30 00:15:25 +00:00
|
|
|
int i, j;
|
|
|
|
|
char out[LCD_MAX_WIDTH];
|
|
|
|
|
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "flush()");
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
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);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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).
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_string (Driver *drvthis, int x, int y, char string[])
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
|
|
|
|
|
2000-04-03 22:13:57 +00:00
|
|
|
int i;
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-11-29 14:09:13 +00:00
|
|
|
report(RPT_INFO, "string(%i,%i,%.40s)", x, y, string);
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2001-09-25 07:19:08 +00:00
|
|
|
y --; x --; // Convert 1-based coords to 0-based...
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2000-04-03 22:13:57 +00:00
|
|
|
for (i = 0; string[i]; i++) {
|
2001-12-30 00:15:25 +00:00
|
|
|
framebuf[(y * width) + x + i] = string[i];
|
2000-04-03 22:13:57 +00:00
|
|
|
}
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Prints a character on the lcd display, at position (x,y). The
|
|
|
|
|
// upper-left is (1,1), and the lower right should be (20,4).
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_chr (Driver *drvthis, int x, int y, char c)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_DEBUG, "char(%i,%i,%c)", x, y, c);
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2001-09-25 07:19:08 +00:00
|
|
|
x--; y--;
|
2001-12-30 00:15:25 +00:00
|
|
|
framebuf[(y * width) + x] = c;
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_set_contrast (Driver *drvthis, int promille)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-12-30 00:15:25 +00:00
|
|
|
report (RPT_INFO, "set_contrast(%i)", promille);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_backlight (Driver *drvthis, int on)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "backlight(%i)", on);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_init_vbar (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-12-30 00:15:25 +00:00
|
|
|
report (RPT_INFO, "init_vbar()");
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_init_hbar (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "init_hbar()");
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_init_num (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "init_bignum()");
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_num (Driver *drvthis, int x, int num)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "big number(%i,%i)", x, num);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
|
|
|
|
debug_set_char (Driver *drvthis, int n, char *dat)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2001-11-29 14:09:13 +00:00
|
|
|
report (RPT_INFO, "set_char(%i,data)", n);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Draws a vertical bar; erases entire column onscreen.
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
2002-02-08 00:15:50 +00:00
|
|
|
debug_vbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2002-02-08 00:15:50 +00:00
|
|
|
int pos;
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2002-02-08 00:15:50 +00:00
|
|
|
report (RPT_INFO, "vbar(%i,%i,%i,%i,%i)", x, y, len, promille, options);
|
1999-12-09 23:15:14 +00:00
|
|
|
|
2002-02-08 00:15:50 +00:00
|
|
|
for ( pos=0; pos<len; pos++ ) {
|
|
|
|
|
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
|
|
|
|
debug_chr (drvthis, x, y-pos, '|');
|
|
|
|
|
} else {
|
|
|
|
|
; /* print nothing */
|
|
|
|
|
}
|
2000-04-03 22:13:57 +00:00
|
|
|
}
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Draws a horizontal bar to the right.
|
|
|
|
|
//
|
2001-12-30 00:15:25 +00:00
|
|
|
MODULE_EXPORT void
|
2002-02-08 00:15:50 +00:00
|
|
|
debug_hbar (Driver *drvthis, int x, int y, int len, int promille, int options)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2002-02-08 00:15:50 +00:00
|
|
|
int pos;
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2002-02-08 00:15:50 +00:00
|
|
|
report (RPT_INFO, "hbar(%i,%i,%i,%i,%i)", x, y, len, promille, options);
|
2000-03-30 20:20:41 +00:00
|
|
|
|
2002-02-08 00:15:50 +00:00
|
|
|
for ( pos=0; pos<len; pos++ ) {
|
|
|
|
|
if( 2 * pos < ((long) promille * len / 500 + 1) ) {
|
|
|
|
|
debug_chr (drvthis, x+pos, y, '-');
|
|
|
|
|
} else {
|
|
|
|
|
; /* print nothing */
|
|
|
|
|
}
|
2000-04-03 22:13:57 +00:00
|
|
|
}
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Sets character 0 to an icon...
|
|
|
|
|
//
|
2002-05-23 18:03:36 +00:00
|
|
|
MODULE_EXPORT int
|
2002-02-08 00:15:50 +00:00
|
|
|
debug_icon (Driver *drvthis, int x, int y, int icon)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2002-02-08 00:15:50 +00:00
|
|
|
report (RPT_INFO, "icon(%i,%i,%i)", x, y, icon);
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
2001-12-30 00:15:25 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// Return a keypress
|
|
|
|
|
//
|
2002-02-08 00:15:50 +00:00
|
|
|
MODULE_EXPORT char *
|
|
|
|
|
debug_get_key (Driver *drvthis)
|
1999-12-09 23:15:14 +00:00
|
|
|
{
|
2002-02-08 00:15:50 +00:00
|
|
|
report (RPT_INFO, "get_key()");
|
|
|
|
|
return NULL;
|
1999-12-09 23:15:14 +00:00
|
|
|
}
|