From 108ff7e83d8a69ef209e269c1a836f47fb425799 Mon Sep 17 00:00:00 2001 From: reinelt Date: Fri, 24 Mar 2000 11:36:56 +0000 Subject: [lcd4linux @ 2000-03-24 11:36:56 by reinelt] new syntax for raster configuration changed XRES and YRES to be configurable PPM driver works nice git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@18 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Raster.c | 132 +++++++++++++++++++++++++++++--------------------- XWindow.c | 103 +++++++++++++++++++++++++++++++++------ fontmap.c | 12 +++-- lcd4linux.c | 9 +++- lcd4linux.conf.sample | 14 ++---- parser.c | 10 +++- pixmap.c | 49 +++++++++++-------- pixmap.h | 13 +++-- 8 files changed, 232 insertions(+), 110 deletions(-) diff --git a/Raster.c b/Raster.c index a7cac00..34c4cd9 100644 --- a/Raster.c +++ b/Raster.c @@ -1,4 +1,4 @@ -/* $Id: Raster.c,v 1.1 2000/03/23 07:24:48 reinelt Exp $ +/* $Id: Raster.c,v 1.2 2000/03/24 11:36:56 reinelt Exp $ * * driver for raster formats * @@ -20,6 +20,12 @@ * * * $Log: Raster.c,v $ + * Revision 1.2 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.1 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) @@ -36,6 +42,7 @@ #include #include +#include #include "cfg.h" #include "display.h" @@ -45,53 +52,62 @@ static DISPLAY Display; -static int pixelsize=-1; -static int pixelgap=0; -static int rowgap=0; -static int colgap=0; +static int pixel=-1; +static int pgap=0; +static int rgap=0; +static int cgap=0; static int border=0; static int foreground=0; static int halfground=0; static int background=0; -#define R(color) (0xff&((color)>>16)) -#define G(color) (0xff&((color)>>8)) -#define B(color) (0xff&((color))) - int Raster_flush (void) { - int xsize, ysize; - int x, y, pos; + int xsize, ysize, row, col; + unsigned char *buffer; + unsigned char R[3], G[3], B[3]; - xsize=2*border+Display.cols*Display.xres*(pixelsize+pixelgap); - ysize=2*border+Display.rows*Display.yres*(pixelsize+pixelgap); + 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); - printf ("P3\n"); - printf ("%d %d\n", xsize, ysize); - printf ("255\n"); + if ((buffer=malloc(xsize*ysize*sizeof(*buffer)))==NULL) + return -1; - pos=0; + memset (buffer, 0, xsize*ysize*sizeof(*buffer)); - for (y=0; y=xsize-border || - y=ysize-border || - (y-border)%(pixelsize+pixelgap)>=pixelsize || - (x-border)%(pixelsize+pixelgap)>=pixelsize) { - pos+=printf ("%d %d %d ", R(background), G(background), B(background)); - } else { - if (Pixmap[((y-border)/(pixelsize+pixelgap))*Display.cols*Display.xres+(x-border)/(pixelsize+pixelgap)]) - pos+=printf ("%d %d %d ", R(foreground), G(foreground), B(foreground)); - else - pos+=printf ("%d %d %d ", R(halfground), G(halfground), B(halfground)); - } - if (pos>80) { - pos=0; - printf ("\n"); - } + for (row=0; row>16; + G[0]=0xff&background>>8; + B[0]=0xff&background; + + R[1]=0xff&halfground>>16; + G[1]=0xff&halfground>>8; + B[1]=0xff&halfground; + + R[2]=0xff&foreground>>16; + G[2]=0xff&foreground>>8; + B[2]=0xff&foreground; + + for (row=0; rowrows=rows; Self->cols=cols; + Self->xres=xres; + Self->yres=yres; Display=*Self; pix_clear(); @@ -156,6 +178,6 @@ int Raster_bar (int type, int row, int col, int max, int len1, int len2) DISPLAY Raster[] = { - { "PPM", 0, 0, XRES, YRES, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, + { "PPM", 0, 0, 0, 0, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, { "" } }; diff --git a/XWindow.c b/XWindow.c index e332f0b..d3bbc22 100644 --- a/XWindow.c +++ b/XWindow.c @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.2 2000/03/23 07:24:48 reinelt Exp $ +/* $Id: XWindow.c,v 1.3 2000/03/24 11:36:56 reinelt Exp $ * * driver for X11 * @@ -20,6 +20,12 @@ * * * $Log: XWindow.c,v $ + * Revision 1.3 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.2 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) @@ -42,6 +48,7 @@ #include #include +#include #include "cfg.h" #include "display.h" @@ -49,19 +56,62 @@ #define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 ) +static int pixel=-1; +static int pgap=0; +static int rgap=0; +static int cgap=0; +static int border=0; + +static int foreground=0; +static int halfground=0; +static int background=0; + static DISPLAY Display; int X_flush (void) { - int r, c; + int xsize, ysize, row, col; + 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); + + if ((buffer=malloc(xsize*ysize*sizeof(*buffer)))==NULL) + return -1; - for (r=0; r>16; + G[0]=0xff&background>>8; + B[0]=0xff&background; + + R[1]=0xff&halfground>>16; + G[1]=0xff&halfground>>8; + B[1]=0xff&halfground; + + R[2]=0xff&foreground>>16; + G[2]=0xff&foreground>>8; + B[2]=0xff&foreground; + + for (row=0; rowrows=rows; Self->cols=cols; + Self->xres=xres; + Self->yres=yres; Display=*Self; pix_clear(); @@ -114,6 +185,6 @@ int X_bar (int type, int row, int col, int max, int len1, int len2) DISPLAY XWindow[] = { - { "X11", 0, 0, XRES, YRES, BARS, X_init, X_clear, X_put, X_bar, X_flush }, + { "X11", 0, 0, 0, 0, BARS, X_init, X_clear, X_put, X_bar, X_flush }, { "" } }; diff --git a/fontmap.c b/fontmap.c index e8494ae..3dc81e5 100644 --- a/fontmap.c +++ b/fontmap.c @@ -1,4 +1,4 @@ -/* $Id: fontmap.c,v 1.1 2000/03/22 15:36:21 reinelt Exp $ +/* $Id: fontmap.c,v 1.2 2000/03/24 11:36:56 reinelt Exp $ * * 5x8 font * @@ -20,6 +20,12 @@ * * * $Log: fontmap.c,v $ + * Revision 1.2 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.1 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) @@ -649,12 +655,12 @@ unsigned char Fontmap[256][8]={ b_O___O, b_O___O, b______ }, - [0x69] { b______, - b___O__, + [0x69] { b___O__, b______, b__OO__, b___O__, b___O__, + b___O__, b__OOO_, b______ }, [0x6a] { b____O_, diff --git a/lcd4linux.c b/lcd4linux.c index 668e3b1..c471843 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.10 2000/03/23 07:24:48 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.11 2000/03/24 11:36:56 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,12 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.11 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.10 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) @@ -143,6 +149,7 @@ void main (int argc, char *argv[]) lcd_put (2, 1, " (c) 2000 M.Reinelt"); lcd_flush(); + // FIXME: just debugging exit (0); sleep (3); diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index cb68fba..3a2be42 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -4,21 +4,17 @@ #Contrast 160 #Display X11 -#rows 2 -#columns 20 - DISPLAY PPM -rows 4 -columns 20 -pixelsize 5 -pixelgap 1 -rowgap 1 -colgap 1 +size 20x4 +font 5x8 +pixel 5+1 +gap 5x5 border 20 foreground 102000 halfground 70c000 background 80d000 + #Row1 "*** %o %v ***" #Row2 "%p CPU %r MB RAM" #Row3 "Busy %cu%% $r10cs+cb" diff --git a/parser.c b/parser.c index 4d9346d..f9ff7e1 100644 --- a/parser.c +++ b/parser.c @@ -1,4 +1,4 @@ -/* $Id: parser.c,v 1.4 2000/03/19 08:41:28 reinelt Exp $ +/* $Id: parser.c,v 1.5 2000/03/24 11:36:56 reinelt Exp $ * * row definition parser * @@ -20,6 +20,12 @@ * * * $Log: parser.c,v $ + * Revision 1.5 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.4 2000/03/19 08:41:28 reinelt * * documentation available! README, README.MatrixOrbital, README.Drivers @@ -225,7 +231,7 @@ char *parse (char *string, int supported_bars, int usage[]) break; default: - *p++=*s++; + if ((*p++=*s)!='\0') s++; } } while (*s); diff --git a/pixmap.c b/pixmap.c index 48343cb..24a65be 100644 --- a/pixmap.c +++ b/pixmap.c @@ -1,4 +1,4 @@ -/* $Id: pixmap.c,v 1.2 2000/03/23 07:24:48 reinelt Exp $ +/* $Id: pixmap.c,v 1.3 2000/03/24 11:36:56 reinelt Exp $ * * generic pixmap driver * @@ -20,6 +20,12 @@ * * * $Log: pixmap.c,v $ + * Revision 1.3 2000/03/24 11:36:56 reinelt + * + * new syntax for raster configuration + * changed XRES and YRES to be configurable + * PPM driver works nice + * * Revision 1.2 2000/03/23 07:24:48 reinelt * * PPM driver up and running (but slow!) @@ -38,8 +44,8 @@ * int pix_clear(void); * clears the pixmap * - * int pix_init (int r, int c); - * allocates & clear pixmap wit r rows and c columns + * int pix_init (int rows, int cols, int XRES, int YRES); + * allocates & clears pixmap * * int pix_put (int row, int col, char *text); * draws text into the pixmap @@ -56,33 +62,38 @@ #include "pixmap.h" #include "fontmap.h" -static int rows=0; -static int cols=0; +static int ROWS=0; +static int COLS=0; +static int XRES=0; +static int YRES=0; + unsigned char *Pixmap=NULL; int pix_clear(void) { int i; - for (i=0; i>=1; - Pixmap[(row+y)*cols+col+x]=Fontmap[c][y]&mask?1:0; + Pixmap[(row+y)*COLS+col+x]=Fontmap[c][y]&mask?1:0; } } col+=XRES; @@ -118,11 +129,11 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2) col*=XRES; if (type & BAR_H) { - if (max>cols-col) - max=cols-col; + if (max>COLS-col) + max=COLS-col; } else { - if (max>rows-row) - max=rows-row; + if (max>ROWS-row) + max=ROWS-row; } if (len1<1) len1=1; @@ -143,7 +154,7 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2) for (y=0; y