From c028ba39da4ad240a79d50ca39e6fc2bf0590e2c Mon Sep 17 00:00:00 2001 From: reinelt Date: Sun, 26 Mar 2000 18:46:28 +0000 Subject: [lcd4linux @ 2000-03-26 18:46:28 by reinelt] bug in pixmap.c that leaded to empty bars fixed name conflicts with X11 resolved git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@22 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- MatrixOrbital.c | 43 +++++++++++++++++++--------------- README.Drivers | 10 ++++---- Raster.c | 31 +++++++++++++----------- Skeleton.c | 17 +++++++++----- XWindow.c | 31 +++++++++++++----------- display.c | 65 +++++++++++++++++++++++++++------------------------ display.h | 17 +++++++++----- lcd4linux.c | 15 ++++++++---- lcd4linux.conf.sample | 18 ++++++++------ pixmap.c | 33 +++++++++++++++----------- 10 files changed, 163 insertions(+), 117 deletions(-) diff --git a/MatrixOrbital.c b/MatrixOrbital.c index 1e9a5dc..833c794 100644 --- a/MatrixOrbital.c +++ b/MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: MatrixOrbital.c,v 1.11 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: MatrixOrbital.c,v 1.12 2000/03/26 18:46:28 reinelt Exp $ * * driver for Matrix Orbital serial display modules * @@ -20,6 +20,11 @@ * * * $Log: MatrixOrbital.c,v $ + * Revision 1.12 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.11 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -65,7 +70,7 @@ * * exported fuctions: * - * struct DISPLAY MatrixOrbital[] + * struct LCD MatrixOrbital[] * */ @@ -86,7 +91,7 @@ #define CHARS 8 #define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 ) -static DISPLAY Display; +static LCD Lcd; static char *Port=NULL; static speed_t Speed; static int Device=-1; @@ -172,8 +177,8 @@ static void MO_process_bars (void) } nSegment=i; - for (row=0; row0 && col<=Display.cols) { + while (max>0 && col<=Lcd.cols) { Bar[row][col].type=type; Bar[row][col].segment=-1; if (len1>=XRES) { @@ -455,7 +460,7 @@ int MO_bar (int type, int row, int col, int max, int len1, int len2) rev=1; case BAR_D: - while (max>0 && row<=Display.rows) { + while (max>0 && row<=Lcd.rows) { Bar[row][col].type=type; Bar[row][col].segment=-1; if (len1>=YRES) { @@ -495,19 +500,19 @@ int MO_flush (void) Segment[s].used=0; } - for (row=0; rowcols=cols; Self->xres=xres; Self->yres=yres; - Display=*Self; + Lcd=*Self; pix_clear(); return 0; @@ -242,7 +247,7 @@ int Raster_bar (int type, int row, int col, int max, int len1, int len2) } -DISPLAY Raster[] = { +LCD Raster[] = { { "PPM", 0, 0, 0, 0, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, { NULL } }; diff --git a/Skeleton.c b/Skeleton.c index 8dcd8b1..b583913 100644 --- a/Skeleton.c +++ b/Skeleton.c @@ -1,4 +1,4 @@ -/* $Id: Skeleton.c,v 1.3 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: Skeleton.c,v 1.4 2000/03/26 18:46:28 reinelt Exp $ * * skeleton driver for new display modules * @@ -20,6 +20,11 @@ * * * $Log: Skeleton.c,v $ + * Revision 1.4 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.3 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -41,7 +46,7 @@ * * exported fuctions: * - * struct DISPLAY Skeleton[] + * struct LCD Skeleton[] * */ @@ -51,16 +56,16 @@ #include "cfg.h" #include "display.h" -static DISPLAY Display; +static LCD Lcd; int Skel_clear (void) { return 0; } -int Skel_init (DISPLAY *Self) +int Skel_init (LCD *Self) { - Display=*Self; + Lcd=*Self; fprintf (stderr, "Skeleton: This driver does not drive anything!"); return -1; @@ -85,7 +90,7 @@ int Skel_flush (void) } -DISPLAY Skeleton[] = { +LCD Skeleton[] = { { "Skeleton", 4, 20, 5, 8, BAR_L | BAR_R, Skel_init, Skel_clear, Skel_put, Skel_bar, Skel_flush }, { NULL } }; diff --git a/XWindow.c b/XWindow.c index 0072a94..d52c7ac 100644 --- a/XWindow.c +++ b/XWindow.c @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.4 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: XWindow.c,v 1.5 2000/03/26 18:46:28 reinelt Exp $ * * driver for X11 * @@ -20,6 +20,11 @@ * * * $Log: XWindow.c,v $ + * Revision 1.5 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.4 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -47,7 +52,7 @@ * * exported fuctions: * - * struct DISPLAY XWindow[] + * struct LCD XWindow[] * */ @@ -71,7 +76,7 @@ static int foreground=0; static int halfground=0; static int background=0; -static DISPLAY Display; +static LCD Lcd; int X_flush (void) { @@ -79,22 +84,22 @@ int X_flush (void) unsigned char *buffer; unsigned char R[3], G[3], B[3]; - xsize=2*border+(Display.cols-1)*cgap+Display.cols*Display.xres*(pixel+pgap); - ysize=2*border+(Display.rows-1)*rgap+Display.rows*Display.yres*(pixel+pgap); + xsize=2*border+(Lcd.cols-1)*cgap+Lcd.cols*Lcd.xres*(pixel+pgap); + ysize=2*border+(Lcd.rows-1)*rgap+Lcd.rows*Lcd.yres*(pixel+pgap); if ((buffer=malloc(xsize*ysize*sizeof(*buffer)))==NULL) return -1; memset (buffer, 0, xsize*ysize*sizeof(*buffer)); - for (row=0; rowcols=cols; Self->xres=xres; Self->yres=yres; - Display=*Self; + Lcd=*Self; pix_clear(); return 0; @@ -189,7 +194,7 @@ int X_bar (int type, int row, int col, int max, int len1, int len2) } -DISPLAY XWindow[] = { +LCD XWindow[] = { { "X11", 0, 0, 0, 0, BARS, X_init, X_clear, X_put, X_bar, X_flush }, { NULL } }; diff --git a/display.c b/display.c index c4f545b..58f333b 100644 --- a/display.c +++ b/display.c @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.11 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: display.c,v 1.12 2000/03/26 18:46:28 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,11 @@ * * * $Log: display.c,v $ + * Revision 1.12 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.11 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -76,7 +81,7 @@ * lcd_list (void) * lists all available drivers to stdout * - * lcd_init (char *display) + * lcd_init (char *driver) * initializes the named driver * * lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars) @@ -103,21 +108,21 @@ #include "cfg.h" #include "display.h" -extern DISPLAY Skeleton[]; -extern DISPLAY MatrixOrbital[]; -extern DISPLAY Raster[]; -extern DISPLAY XWindow[]; +extern LCD Skeleton[]; +extern LCD MatrixOrbital[]; +extern LCD Raster[]; +extern LCD XWindow[]; FAMILY Driver[] = { { "Skeleton", Skeleton }, { "Matrix Orbital", MatrixOrbital }, - { "Raster", Raster }, + { "Raster", Raster }, { "X Window System", XWindow }, { NULL } }; -static DISPLAY *Display = NULL; +static LCD *Lcd = NULL; int lcd_list (void) { @@ -127,68 +132,68 @@ int lcd_list (void) for (i=0; Driver[i].name; i++) { printf ("\n %-16s:", Driver[i].name); - for (j=0; Driver[i].Display[j].name; j++) { - printf (" %s", Driver[i].Display[j].name); + for (j=0; Driver[i].Model[j].name; j++) { + printf (" %s", Driver[i].Model[j].name); } } printf ("\n"); return 0; } -int lcd_init (char *display) +int lcd_init (char *driver) { int i, j; for (i=0; Driver[i].name; i++) { - for (j=0; Driver[i].Display[j].name; j++) { - if (strcmp (Driver[i].Display[j].name, display)==0) { - Display=&Driver[i].Display[j]; - return Display->init(Display); + for (j=0; Driver[i].Model[j].name; j++) { + if (strcmp (Driver[i].Model[j].name, driver)==0) { + Lcd=&Driver[i].Model[j]; + return Lcd->init(Lcd); } } } - fprintf (stderr, "lcd_init(%s) failed: no such display\n", display); + fprintf (stderr, "lcd_init(%s) failed: no such display\n", driver); return -1; } int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars) { - if (Display==NULL) + if (Lcd==NULL) return -1; - *rows=Display->rows; - *cols=Display->cols; - *xres=Display->xres; - *yres=Display->yres; - *bars=Display->bars; + *rows=Lcd->rows; + *cols=Lcd->cols; + *xres=Lcd->xres; + *yres=Lcd->yres; + *bars=Lcd->bars; return 0; } int lcd_clear (void) { - return Display->clear(); + return Lcd->clear(); } int lcd_put (int row, int col, char *text) { - if (row<1 || row>Display->rows) return -1; - if (col<1 || col>Display->cols) return -1; - return Display->put(row-1, col-1, text); + if (row<1 || row>Lcd->rows) return -1; + if (col<1 || col>Lcd->cols) return -1; + return Lcd->put(row-1, col-1, text); } int lcd_bar (int type, int row, int col, int max, int len1, int len2) { - if (row<1 || row>Display->rows) return -1; - if (col<1 || col>Display->cols) return -1; + if (row<1 || row>Lcd->rows) return -1; + if (col<1 || col>Lcd->cols) return -1; if (!(type & (BAR_H2 | BAR_V2))) len2=len1; if (type & BAR_LOG) { len1=(double)max*log(len1+1)/log(max); len2=(double)max*log(len2+1)/log(max); } - return Display->bar (type & BAR_HV, row-1, col-1, max, len1, len2); + return Lcd->bar (type & BAR_HV, row-1, col-1, max, len1, len2); } int lcd_flush (void) { - return Display->flush(); + return Lcd->flush(); } diff --git a/display.h b/display.h index f519467..24184f9 100644 --- a/display.h +++ b/display.h @@ -1,4 +1,4 @@ -/* $Id: display.h,v 1.9 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: display.h,v 1.10 2000/03/26 18:46:28 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,11 @@ * * * $Log: display.h,v $ + * Revision 1.10 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.9 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -73,27 +78,27 @@ #define BAR_V (BAR_U | BAR_D) #define BAR_HV (BAR_H | BAR_V) -typedef struct DISPLAY { +typedef struct LCD { char *name; int rows; int cols; int xres; int yres; int bars; - int (*init) (struct DISPLAY *Self); + int (*init) (struct LCD *Self); int (*clear) (void); int (*put) (int x, int y, char *text); int (*bar) (int type, int x, int y, int max, int len1, int len2); int (*flush) (void); -} DISPLAY; +} LCD; typedef struct { char *name; - DISPLAY *Display; + LCD *Model; } FAMILY; int lcd_list (void); -int lcd_init (char *display); +int lcd_init (char *driver); int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars); int lcd_clear (void); int lcd_put (int row, int col, char *text); diff --git a/lcd4linux.c b/lcd4linux.c index 3d9d55b..88cbf6b 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.13 2000/03/26 12:55:03 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.14 2000/03/26 18:46:28 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,11 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.14 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.13 2000/03/26 12:55:03 reinelt * * enhancements to the PPM driver @@ -105,7 +110,7 @@ static void usage(void) void main (int argc, char *argv[]) { char *cfg="/etc/lcd4linux.conf"; - char *display; + char *driver; int c, smooth; while ((c=getopt (argc, argv, "hlf:o:"))!=EOF) { @@ -143,12 +148,12 @@ void main (int argc, char *argv[]) if (cfg_read (cfg)==-1) exit (1); - display=cfg_get("display"); - if (display==NULL || *display=='\0') { + driver=cfg_get("display"); + if (driver==NULL || *driver=='\0') { fprintf (stderr, "%s: missing 'display' entry!\n", cfg_file()); exit (1); } - if (lcd_init(display)==-1) { + if (lcd_init(driver)==-1) { exit (1); } diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index aad16c6..4c27373 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -3,16 +3,20 @@ #Speed 19200 #Contrast 160 -#Display X11 -DISPLAY PPM +Display xlcd +#Display PPM size 20x4 font 5x8 -pixel 3+1 -gap 4x4 +pixel 3+0 +gap 3x3 border 5 -foreground 102000 -halfground 70c000 -background 80d000 +foreground black +halfground gray +background wheat + +#foreground 102000 +#halfground 70c000 +#background 80d000 #Row1 "*** %o %v ***" diff --git a/pixmap.c b/pixmap.c index 3f20c9e..c266a65 100644 --- a/pixmap.c +++ b/pixmap.c @@ -1,4 +1,4 @@ -/* $Id: pixmap.c,v 1.4 2000/03/25 05:50:43 reinelt Exp $ +/* $Id: pixmap.c,v 1.5 2000/03/26 18:46:28 reinelt Exp $ * * generic pixmap driver * @@ -20,6 +20,11 @@ * * * $Log: pixmap.c,v $ + * Revision 1.5 2000/03/26 18:46:28 reinelt + * + * bug in pixmap.c that leaded to empty bars fixed + * name conflicts with X11 resolved + * * Revision 1.4 2000/03/25 05:50:43 reinelt * * memory leak in Raster_flush closed @@ -72,14 +77,14 @@ static int COLS=0; static int XRES=0; static int YRES=0; -unsigned char *Pixmap=NULL; +unsigned char *LCDpixmap=NULL; int pix_clear(void) { int i; for (i=0; i>=1; - Pixmap[(row+y)*COLS+col+x]=Fontmap[c][y]&mask?1:0; + if (c!='\t') { + for (y=0; y>=1; + LCDpixmap[(row+y)*COLS+col+x]=Fontmap[c][y]&mask?1:0; + } } } col+=XRES; @@ -159,7 +166,7 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2) for (y=0; y