Reporting patch.

This commit is contained in:
robijn
2001-11-29 14:09:13 +00:00
parent 3dc439e2c4
commit 285d29edf3
23 changed files with 534 additions and 477 deletions
+25 -36
View File
@@ -5,10 +5,10 @@
#include <fcntl.h>
#include <string.h>
#include <sys/errno.h>
#include <syslog.h>
#include "lcd.h"
#include "debug.h"
#include "shared/report.h"
//////////////////////////////////////////////////////////////////////////
////////////////////// For Debugging Output //////////////////////////////
@@ -22,7 +22,7 @@ static lcd_logical_driver *debug_drv;
int
debug_init (struct lcd_logical_driver *driver, char *args)
{
syslog(LOG_DEBUG, "debug_init");
report (RPT_INFO, "debug_init()");
debug_drv = driver;
@@ -58,10 +58,10 @@ debug_init (struct lcd_logical_driver *driver, char *args)
void
debug_close ()
{
syslog(LOG_DEBUG, "debug_close()");
report (RPT_INFO, "debug_close()");
if (debug_drv->framebuf) {
printf ("frame buffer: %010X", (int) debug_drv->framebuf);
report (RPT_DEBUG, "frame buffer: %010X", (int) debug_drv->framebuf);
free (debug_drv->framebuf);
}
@@ -74,7 +74,7 @@ debug_close ()
void
debug_clear ()
{
syslog(LOG_DEBUG, "clear()");
report (RPT_INFO, "clear()");
memset (debug_drv->framebuf, ' ', debug_drv->wid * debug_drv->hgt);
@@ -86,7 +86,7 @@ debug_clear ()
void
debug_flush ()
{
syslog(LOG_DEBUG, "flush()");
report (RPT_INFO, "flush()");
debug_drv->draw_frame ();
}
@@ -100,10 +100,8 @@ debug_string (int x, int y, char string[])
{
int i;
char buf[64];
snprintf(buf, sizeof(buf), "string(%i,%i): %s", x, y, string);
syslog (LOG_DEBUG, buf);
report(RPT_INFO, "string(%i,%i,%.40s)", x, y, string);
y --; x --; // Convert 1-based coords to 0-based...
@@ -119,10 +117,7 @@ debug_string (int x, int y, char string[])
void
debug_chr (int x, int y, char c)
{
char buf[64];
snprintf(buf, sizeof(buf), "character(%i,%i): %c", x, y, c);
syslog (LOG_DEBUG, buf);
report (RPT_DEBUG, "char(%i,%i,%c)", x, y, c);
x--; y--;
debug_drv->framebuf[(y * debug_drv->wid) + x] = c;
@@ -131,50 +126,44 @@ debug_chr (int x, int y, char c)
int
debug_contrast (int contrast)
{
syslog(LOG_DEBUG, "contrast: %i", contrast);
report (RPT_INFO, "contrast(%i)", contrast);
return 0;
}
void
debug_backlight (int on)
{
if (on)
syslog(LOG_DEBUG, "backlight turned on");
else
syslog(LOG_DEBUG, "backlight turned off");
report (RPT_INFO, "backlight(%i)", on);
}
void
debug_init_vbar ()
{
syslog(LOG_DEBUG, "Init vertical bars");
report (LOG_INFO, "init_vbar()");
}
void
debug_init_hbar ()
{
syslog(LOG_DEBUG, "Init horizontal bars");
report (RPT_INFO, "init_hbar()");
}
void
debug_init_num ()
{
syslog(LOG_DEBUG, "Big numbers");
report (RPT_INFO, "init_bignum()");
}
void
debug_num (int x, int num)
{
char buf[64];
snprintf(buf, sizeof(buf), "big number(%i): %i", x, num);
syslog (LOG_DEBUG, buf);
report (RPT_INFO, "big number(%i,%i)", x, num);
}
void
debug_set_char (int n, char *dat)
{
syslog(LOG_DEBUG, "set character %i", n);
report (RPT_INFO, "set_char(%i,data)", n);
}
/////////////////////////////////////////////////////////////////
@@ -185,7 +174,7 @@ debug_vbar (int x, int len)
{
int y;
syslog (LOG_DEBUG, "vbar(%i): len = %i", x, len);
report (RPT_INFO, "vbar(%i,%i)", x, len);
for (y = debug_drv->hgt; y > 0 && len > 0; y--) {
debug_chr (x, y, '|');
@@ -201,7 +190,7 @@ debug_vbar (int x, int len)
void
debug_hbar (int x, int y, int len)
{
syslog(LOG_DEBUG, "hbar(%i,%i): len = %i", x, y, len);
report (RPT_INFO, "hbar(%i,%i,%i)", x, y, len);
for (; x < debug_drv->wid && len > 0; x++) {
debug_chr (x, y, '-');
@@ -217,13 +206,13 @@ debug_hbar (int x, int y, int len)
void
debug_icon (int which, char dest)
{
syslog (LOG_DEBUG, "char %i = icon %i", dest, which);
report (RPT_INFO, "icon(%i,%i", which, dest);
}
void
debug_flush_box (int lft, int top, int rgt, int bot)
{
syslog (LOG_DEBUG, "flush_box(%i,%i) - (%i,%i)", lft, top, rgt, bot);
report (RPT_INFO, "flush_box(%i,%i,%i,%i)", lft, top, rgt, bot);
debug_flush ();
}
@@ -235,25 +224,25 @@ debug_draw_frame (char *dat)
char out[LCD_MAX_WIDTH];
syslog (LOG_DEBUG, "draw_frame()");
report (RPT_INFO, "draw_frame(data)");
if (!dat)
return;
// printf("Frame (%ix%i): \n%s\n", debug_drv->wid, debug_drv->hgt, dat);
// 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;
//printf ("+%s+\n", out);
//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;
//printf ("|%s|\n", out);
//report (RPT_DEBUG, "|%s|", out);
}
@@ -261,13 +250,13 @@ debug_draw_frame (char *dat)
out[i] = '-';
}
out[debug_drv->wid] = 0;
//printf ("+%s+\n", out);
//report (RPT_DEBUG, "+%s+", out);
}
char
debug_getkey ()
{
syslog(LOG_DEBUG, "getkey");
report (RPT_INFO, "getkey()");
return 0;
}
+1 -1
View File
@@ -32,7 +32,7 @@
#endif
#include "shared/LL.h"
#include "shared/debug.h"
#include "shared/report.h"
#include "lcd.h"
+36 -23
View File
@@ -165,7 +165,9 @@
#include "lpt-port.h"
#include "lcd.h"
#include "shared/str.h"
#include <stdio.h>
#include "shared/report.h"
#include "configfile.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
@@ -274,6 +276,9 @@ sed1330_init( lcd_logical_driver * driver, char *args )
sed1330 = driver;
debug( RPT_INFO, "SED1330: init(%p,%s)", driver, args );
// TODO: replace DriverName with driver->name when that field exists.
#define DriverName "sed1330"
@@ -291,13 +296,13 @@ sed1330_init( lcd_logical_driver * driver, char *args )
// READ THE CONFIG FILE
// Port
port = driver->config_get_int( DriverName, "port", 0, 0x278 );
port = config_get_int( DriverName, "port", 0, 0x278 );
data->port = port;
// Type
s = driver->config_get_string( DriverName, "type", 0, NULL );
if( !s ) {
printf( "SED1330: you need to specify the display type\n" );
report( RPT_ERR, "SED1330: you need to specify the display type" );
} else if( strcmp( s, "G321D" ) == 0 ) {
data->type = TYPE_G321D;
data->graph_width = 320;
@@ -311,14 +316,17 @@ sed1330_init( lcd_logical_driver * driver, char *args )
data->graph_width = 240;
data->graph_height = 128;
} else {
printf( "SED1330: Unknown display type: %s\n", s );
report( RPT_ERR, "SED1330: Unknown display type: %s", s );
return -1;
}
driver->wid = data->graph_width / CHARWIDTH;
driver->hgt = data->graph_height / CHARHEIGHT;
data->bytesperline = (data->graph_width - 1 ) / CHARWIDTH + 1;
report( RPT_INFO, "SED1330: Using LCD type: %s", s );
report( RPT_INFO, "SED1330: Text size: %dx%d", driver->wid, driver->hgt );
// Keymap
for( i=0; i<MAXKEYS; i++ ) {
char buf[8];
@@ -327,6 +335,8 @@ sed1330_init( lcd_logical_driver * driver, char *args )
if( s ) {
data->keymap[i] = (char *) malloc( strlen(s)+1 );
strcpy( data->keymap[i], s );
report( RPT_INFO, "SED1330: Key %d: \"%s\"", i, s );
} else {
data->keymap[i] = ""; // Pointing to an constant empty string
}
@@ -360,6 +370,7 @@ sed1330_init( lcd_logical_driver * driver, char *args )
// Arrange for access to port
debug( RPT_DEBUG, "SED1330: getting port access" );
port_access(data->port);
port_access(data->port+1);
port_access(data->port+2);
@@ -372,7 +383,7 @@ sed1330_init( lcd_logical_driver * driver, char *args )
struct sched_param param;
param.sched_priority=1;
if (( sched_setscheduler(0, SCHED_RR, &param)) == -1) {
fprintf (stderr, "HD44780_init: failed (%s)\n", strerror (errno));
report( RPT_ERR, "HD44780_init: failed (%s)", strerror (errno));
return -1;
}
}
@@ -404,6 +415,7 @@ sed1330_init( lcd_logical_driver * driver, char *args )
// INITIALIZE THE LCD
// End reset-state
debug( RPT_DEBUG, "SED1330: initializing LCD" );
port_out( port+2, (nWR) ^ OUTMASK ); // raise ^RD and ^WR
port_out( port+2, (nRESET|nWR) ^ OUTMASK ); // lower RESET
uPause( 200 );
@@ -495,7 +507,7 @@ sed1330_command( char command, int datacount, char * data )
int i;
int port = private_data->port;
printf( "sed1330_command %x #data=%d\n", command, datacount );
debug( RPT_INFO, "sed1330_command %x #data=%d", command, datacount );
port_out( port+2, (nRESET|nWR|A0) ^ OUTMASK ); // set A0 to indicate command
port_out( port, command ); // set up data
@@ -531,7 +543,7 @@ void sed1330_update_cursor()
char disp_en;
char fc; // named after CF register in SED1330
printf( "sed1330_update_cursor\n" );
debug( RPT_INFO, "sed1330_update_cursor" );
cursor_pos = (data->cursor_y-1) * data->bytesperline + (data->cursor_x-1) + 256 * SCR1_H + SCR1_L;
csrloc[0] = cursor_pos % 256;
@@ -568,7 +580,7 @@ void sed1330_update_cursor()
void
sed1330_close()
{
printf( "sed1330_close\n" );
debug( RPT_INFO, "sed1330_close" );
//sed1330_command( CMD_DISP_DIS, 0, NULL ); // display off
//port_out( port+2, (nWR) ^ OUTMASK ); // give LCD reset signal
@@ -586,7 +598,7 @@ sed1330_clear()
{
private_data * data = sed1330->private_data;
printf( "sed1330_clear\n" );
debug( RPT_INFO, "sed1330_clear" );
memset( data->framebuf_text, ' ', data->bytesperline * sed1330->hgt);
memset( data->framebuf_graph, 0, data->bytesperline * data->graph_height );
@@ -603,7 +615,8 @@ sed1330_string( int x, int y, char *str )
char * start;
int len;
printf( "sed1330_string x=%d y=%d s=\"%s\"\n", x, y, str );
debug( RPT_INFO, "sed1330_string x=%d y=%d s=\"%s\"", x, y, str );
if( y > sed1330->hgt ) {
return; // outside framebuf_textfer
}
@@ -626,7 +639,7 @@ sed1330_chr( int x, int y, char c )
{
private_data * data = sed1330->private_data;
printf( "sed1330_chr x=%d y=%d c='%c'\n", x, y, c );
debug( RPT_INFO, "sed1330_chr x=%d y=%d c='%c'", x, y, c );
if( y > sed1330->hgt || x > sed1330->wid ) {
return; // outside framebuf_textfer
@@ -645,7 +658,7 @@ sed1330_flush()
unsigned int pos, start_pos, nr_equal, fblen, len, cursor_pos;
char csrloc[2];
printf( "sed1330_flush\n" );
debug( RPT_INFO, "sed1330_flush" );
sed1330_command( CMD_DISP_EN, 1, ((char[1]) {0x16}) ); // cursor off
@@ -703,7 +716,7 @@ void sed1330_cursor( int x, int y, char state )
{
private_data * data = sed1330->private_data;
printf( "sed1330_cursor x=%d y=%d state='%c'\n", x, y, state );
debug( RPT_INFO, "sed1330_cursor x=%d y=%d state='%c'", x, y, state );
data->cursor_x = x;
data->cursor_y = y;
@@ -721,7 +734,7 @@ sed1330_backlight( int on )
{
//private_data * data = sed1330->private_data;
printf( "sed1330_backlight on='%c'\n", on );
debug( RPT_INFO, "sed1330_backlight on='%c'", on );
// unimplemented
}
@@ -737,7 +750,7 @@ sed1330_rect ( int x1, int y1, int x2, int y2, char pattern )
//private_data * data = sed1330->private_data;
int x, y;
printf( "sed1330_rect x1=%d y1=%d x2=%d y2=%d pattern=%d\n", x1, y1, x2, y2, (int) pattern );
debug( RPT_INFO, "sed1330_rect x1=%d y1=%d x2=%d y2=%d pattern=%d", x1, y1, x2, y2, (int) pattern );
// Swap coordinates if needed
if( x1>x2 ) {
@@ -771,7 +784,7 @@ sed1330_line ( int x1, int y1, int x2, int y2, char pattern )
//private_data * data = sed1330->private_data;
int x, y;
printf( "sed1330_rect x1=%d y1=%d x2=%d y2=%d pattern=%d\n", x1, y1, x2, y2, (int) pattern );
debug( RPT_INFO, "sed1330_rect x1=%d y1=%d x2=%d y2=%d pattern=%d", x1, y1, x2, y2, (int) pattern );
// Swap coordinates if needed
if( x1>x2 ) {
@@ -830,7 +843,7 @@ sed1330_set_pixel( int x, int y )
unsigned int bytepos;
char bitmask;
//printf( "sed1330_set_pixel x=%d y=%d\n", x, y );
//debug( RPT_INFO, "sed1330_set_pixel x=%d y=%d", x, y );
bytepos = y*data->bytesperline + x/PIXELSPERBYTE;
bitmask = 0x80 >> (x % PIXELSPERBYTE);
@@ -850,7 +863,7 @@ sed1330_clear_pixel( int x, int y )
int bytepos;
char bitmask;
//printf( "sed1330_clear_pixel x=%d y=%d\n", x, y );
//debug( RPT_INFO, "sed1330_clear_pixel x=%d y=%d", x, y );
bytepos = y*data->bytesperline + x/PIXELSPERBYTE;
bitmask = 0x80 >> (x % PIXELSPERBYTE);
@@ -866,7 +879,7 @@ sed1330_vbar( int x, int len )
{
private_data * data = sed1330->private_data;
printf( "sed1330_hbar x=%d len=%d\n", x, len );
debug( RPT_INFO, "sed1330_hbar x=%d len=%d", x, len );
sed1330_rect ( (x-1) * CHARWIDTH, data->graph_height-1, x * CHARWIDTH - 1, data->graph_height-1 - ((long) len * CHARHEIGHT / sed1330->cellhgt ), 1 );
}
@@ -881,7 +894,7 @@ sed1330_hbar( int x, int y, int len )
{
//private_data * data = sed1330->private_data;
printf( "sed1330_hbar x=%d y=%d len=%d\n", x, y, len );
debug( RPT_INFO, "sed1330_hbar x=%d y=%d len=%d", x, y, len );
sed1330_rect ( (x-1) * CHARWIDTH, (y-1) * CHARHEIGHT, x * CHARWIDTH + len, y * CHARHEIGHT - 1, 1 );
}
@@ -895,7 +908,7 @@ sed1330_num( int x, int num )
{
//private_data * data = sed1330->private_data;
printf( "sed1330_bignum x=%d num=%d\n", x, num );
debug( RPT_INFO, "sed1330_bignum x=%d num=%d", x, num );
}
@@ -918,7 +931,7 @@ sed1330_heartbeat( int type )
{ 0xFF, 0xAF, 0x07, 0x07, 0x07, 0x8F, 0xDF, 0xFF, 0x00, 0x00 }
};
printf( "sed1330_heartbeat type=%d\n", type );
report( RPT_INFO, "sed1330_heartbeat type=%d", type );
data->framebuf_text[sed1330->wid-1] = ' ';
whichIcon = (! ((timer + 4) & 5));