diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | Makefile.in | 12 | ||||
-rw-r--r-- | MatrixOrbital.c | 12 | ||||
-rw-r--r-- | Raster.c | 161 | ||||
-rw-r--r-- | XWindow.c | 10 | ||||
-rw-r--r-- | display.c | 8 | ||||
-rw-r--r-- | filter.c | 8 | ||||
-rw-r--r-- | lcd4linux.c | 21 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 18 | ||||
-rw-r--r-- | pixmap.c | 9 | ||||
-rw-r--r-- | processor.c | 8 | ||||
-rw-r--r-- | system.c | 11 |
12 files changed, 239 insertions, 40 deletions
diff --git a/Makefile.am b/Makefile.am index 443f527..1d50bf1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,7 @@ lcd4linux_SOURCES = \ fontmap.c fontmap.h \ Skeleton.c \ MatrixOrbital.c \ + Raster.c \ XWindow.c diff --git a/Makefile.in b/Makefile.in index 0bb3143..c6949c3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -68,7 +68,7 @@ CLEANFILES = *~ AM_CFLAGS = -Wall bin_PROGRAMS = lcd4linux -lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h filter.c filter.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h Skeleton.c MatrixOrbital.c XWindow.c +lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h parser.c parser.h processor.c processor.h system.c system.h isdn.c isdn.h filter.c filter.h display.c display.h pixmap.c pixmap.h fontmap.c fontmap.h Skeleton.c MatrixOrbital.c Raster.c XWindow.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -82,7 +82,7 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ lcd4linux_OBJECTS = lcd4linux.o cfg.o parser.o processor.o system.o \ isdn.o filter.o display.o pixmap.o fontmap.o Skeleton.o MatrixOrbital.o \ -XWindow.o +Raster.o XWindow.o lcd4linux_LDADD = $(LDADD) lcd4linux_DEPENDENCIES = lcd4linux_LDFLAGS = @@ -98,10 +98,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/MatrixOrbital.P .deps/Skeleton.P .deps/XWindow.P \ -.deps/cfg.P .deps/display.P .deps/filter.P .deps/fontmap.P .deps/isdn.P \ -.deps/lcd4linux.P .deps/parser.P .deps/pixmap.P .deps/processor.P \ -.deps/system.P +DEP_FILES = .deps/MatrixOrbital.P .deps/Raster.P .deps/Skeleton.P \ +.deps/XWindow.P .deps/cfg.P .deps/display.P .deps/filter.P \ +.deps/fontmap.P .deps/isdn.P .deps/lcd4linux.P .deps/parser.P \ +.deps/pixmap.P .deps/processor.P .deps/system.P SOURCES = $(lcd4linux_SOURCES) OBJECTS = $(lcd4linux_OBJECTS) diff --git a/MatrixOrbital.c b/MatrixOrbital.c index e461858..c188663 100644 --- a/MatrixOrbital.c +++ b/MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $Id: MatrixOrbital.c,v 1.9 2000/03/22 07:33:50 reinelt Exp $ +/* $Id: MatrixOrbital.c,v 1.10 2000/03/23 07:24:48 reinelt Exp $ * * driver for Matrix Orbital serial display modules * @@ -20,6 +20,10 @@ * * * $Log: MatrixOrbital.c,v $ + * Revision 1.10 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.9 2000/03/22 07:33:50 reinelt * * FAQ added @@ -145,8 +149,7 @@ static int MO_contrast (void) char buffer[4]; int contrast; - contrast=atoi(cfg_get("Contrast")); - if (contrast==0) contrast=160; + contrast=atoi(cfg_get("Contrast")?:"160"); snprintf (buffer, 4, "\376P%c", contrast); MO_write (buffer, 3); return 0; @@ -355,8 +358,7 @@ int MO_init (DISPLAY *Self) } Port=strdup(port); - speed=cfg_get("Speed"); - if (speed==NULL) speed="19200"; + speed=cfg_get("Speed")?:"19200"; switch (atoi(speed)) { case 1200: diff --git a/Raster.c b/Raster.c new file mode 100644 index 0000000..a7cac00 --- /dev/null +++ b/Raster.c @@ -0,0 +1,161 @@ +/* $Id: Raster.c,v 1.1 2000/03/23 07:24:48 reinelt Exp $ + * + * driver for raster formats + * + * Copyright 1999, 2000 by Michael Reinelt (reinelt@eunet.at) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: Raster.c,v $ + * Revision 1.1 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * + */ + +/* + * + * exported fuctions: + * + * struct DISPLAY Raster[] + * + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "cfg.h" +#include "display.h" +#include "pixmap.h" + +#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 ) + +static DISPLAY Display; + +static int pixelsize=-1; +static int pixelgap=0; +static int rowgap=0; +static int colgap=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; + + xsize=2*border+Display.cols*Display.xres*(pixelsize+pixelgap); + ysize=2*border+Display.rows*Display.yres*(pixelsize+pixelgap); + + printf ("P3\n"); + printf ("%d %d\n", xsize, ysize); + printf ("255\n"); + + pos=0; + + for (y=0; y<ysize; y++) { + for (x=0; x<xsize; x++) { + if (x<border || x>=xsize-border || + y<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"); + } + } + } + return 0; +} + +int Raster_clear (void) +{ + if (pix_clear()!=0) + return -1; + + return 0; +} + +int Raster_init (DISPLAY *Self) +{ + int rows=-1; + int cols=-1; + + rows=atoi(cfg_get("rows")?:"4"); + cols=atoi(cfg_get("columns")?:"20"); + + pixelsize=atoi(cfg_get("pixelsize")?:"1"); + pixelgap=atoi(cfg_get("pixelgap")?:"0"); + rowgap=atoi(cfg_get("rowgap")?:"0"); + colgap=atoi(cfg_get("colgap")?:"0"); + border=atoi(cfg_get("border")?:"0"); + + foreground=strtol(cfg_get("foreground")?:"000000", NULL, 16); + halfground=strtol(cfg_get("halfground")?:"ffffff", NULL, 16); + background=strtol(cfg_get("background")?:"ffffff", NULL, 16); + + if (rows<1 || cols<1) { + fprintf (stderr, "Raster: incorrect number of rows or columns\n"); + return -1; + } + + if (pixelsize<1) { + fprintf (stderr, "Raster: incorrect pixel size\n"); + return -1; + } + + if (pix_init (rows, cols)!=0) { + fprintf (stderr, "Raster: pix_init(%d, %d) failed\n", rows, cols); + return -1; + } + + Self->rows=rows; + Self->cols=cols; + Display=*Self; + + pix_clear(); + return 0; +} + +int Raster_put (int row, int col, char *text) +{ + return pix_put (row, col, text); +} + +int Raster_bar (int type, int row, int col, int max, int len1, int len2) +{ + return pix_bar (type, row, col, max, len1, len2); +} + + +DISPLAY Raster[] = { + { "PPM", 0, 0, XRES, YRES, BARS, Raster_init, Raster_clear, Raster_put, Raster_bar, Raster_flush }, + { "" } +}; @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.1 2000/03/22 15:36:21 reinelt Exp $ +/* $Id: XWindow.c,v 1.2 2000/03/23 07:24:48 reinelt Exp $ * * driver for X11 * @@ -20,6 +20,10 @@ * * * $Log: XWindow.c,v $ + * Revision 1.2 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.1 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) @@ -77,8 +81,8 @@ int X_init (DISPLAY *Self) int rows=-1; int cols=-1; - rows=atoi(cfg_get("rows")); - cols=atoi(cfg_get("columns")); + rows=atoi(cfg_get("rows")?:"4"); + cols=atoi(cfg_get("columns")?:"20"); if (rows<1 || cols<1) { fprintf (stderr, "X11: incorrect number of rows or columns\n"); @@ -1,4 +1,4 @@ -/* $Id: display.c,v 1.9 2000/03/22 15:36:21 reinelt Exp $ +/* $Id: display.c,v 1.10 2000/03/23 07:24:48 reinelt Exp $ * * framework for device drivers * @@ -20,6 +20,10 @@ * * * $Log: display.c,v $ + * Revision 1.10 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.9 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) @@ -96,11 +100,13 @@ extern DISPLAY Skeleton[]; extern DISPLAY MatrixOrbital[]; +extern DISPLAY Raster[]; extern DISPLAY XWindow[]; FAMILY Driver[] = { { "Skeleton", Skeleton }, { "Matrix Orbital", MatrixOrbital }, + { "Raster", Raster }, { "X Window System", XWindow }, { "" } }; @@ -1,4 +1,4 @@ -/* $Id: filter.c,v 1.3 2000/03/22 07:33:50 reinelt Exp $ +/* $Id: filter.c,v 1.4 2000/03/23 07:24:48 reinelt Exp $ * * smooth and damp functions * @@ -20,6 +20,10 @@ * * * $Log: filter.c,v $ + * Revision 1.4 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.3 2000/03/22 07:33:50 reinelt * * FAQ added @@ -127,7 +131,7 @@ double damp(char *name, double value) int i, j; if (tau==-1) - tau=atoi(cfg_get("tau")); + tau=atoi(cfg_get("tau")?:"500"); if (tau==0.0) return value; diff --git a/lcd4linux.c b/lcd4linux.c index b9fd024..668e3b1 100644 --- a/lcd4linux.c +++ b/lcd4linux.c @@ -1,4 +1,4 @@ -/* $Id: lcd4linux.c,v 1.9 2000/03/22 15:36:21 reinelt Exp $ +/* $Id: lcd4linux.c,v 1.10 2000/03/23 07:24:48 reinelt Exp $ * * LCD4Linux * @@ -20,6 +20,10 @@ * * * $Log: lcd4linux.c,v $ + * Revision 1.10 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.9 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) @@ -117,13 +121,6 @@ void main (int argc, char *argv[]) cfg_set ("row3", "Busy %cu%% $r10cu"); cfg_set ("row4", "Load %l1%L$r10l1"); - cfg_set ("tick", "100"); - cfg_set ("tack", "500"); - cfg_set ("tau", "500"); - - cfg_set ("fifo", "/var/run/LCD4Linux"); - cfg_set ("overload", "2.0"); - if (cfg_read (cfg)==-1) exit (1); @@ -136,8 +133,8 @@ void main (int argc, char *argv[]) exit (1); } - tick=atoi(cfg_get("tick")); - tack=atoi(cfg_get("tack")); + tick=atoi(cfg_get("tick")?:"100"); + tack=atoi(cfg_get("tack")?:"500"); process_init(); @@ -145,7 +142,9 @@ void main (int argc, char *argv[]) lcd_put (1, 1, "* LCD4Linux V" VERSION " *"); lcd_put (2, 1, " (c) 2000 M.Reinelt"); lcd_flush(); - + + exit (0); + sleep (3); lcd_clear(); diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index f00c93e..cb68fba 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -3,10 +3,22 @@ #Speed 19200 #Contrast 160 -Display X11 -rows 2 -columns 20 +#Display X11 +#rows 2 +#columns 20 +DISPLAY PPM +rows 4 +columns 20 +pixelsize 5 +pixelgap 1 +rowgap 1 +colgap 1 +border 20 +foreground 102000 +halfground 70c000 +background 80d000 + #Row1 "*** %o %v ***" #Row2 "%p CPU %r MB RAM" #Row3 "Busy %cu%% $r10cs+cb" @@ -1,4 +1,4 @@ -/* $Id: pixmap.c,v 1.1 2000/03/22 15:36:21 reinelt Exp $ +/* $Id: pixmap.c,v 1.2 2000/03/23 07:24:48 reinelt Exp $ * * generic pixmap driver * @@ -20,6 +20,10 @@ * * * $Log: pixmap.c,v $ + * Revision 1.2 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.1 2000/03/22 15:36:21 reinelt * * added '-l' switch (list drivers) @@ -108,8 +112,7 @@ int pix_put (int row, int col, char *text) int pix_bar (int type, int row, int col, int max, int len1, int len2) { - int i, x, y, len, rev; - unsigned char *p; + int x, y, len, rev; row*=YRES; col*=XRES; diff --git a/processor.c b/processor.c index 6c95208..c381e72 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.1 2000/03/22 07:33:50 reinelt Exp $ +/* $Id: processor.c,v 1.2 2000/03/23 07:24:48 reinelt Exp $ * * main data processing * @@ -20,6 +20,10 @@ * * * $Log: processor.c,v $ + * Revision 1.2 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.1 2000/03/22 07:33:50 reinelt * * FAQ added @@ -369,7 +373,7 @@ void process_init (void) int i; char buffer[8]; - load.overload=atof(cfg_get("overload")); + load.overload=atof(cfg_get("overload")?:"2.0"); lcd_query (&rows, &cols, &xres, &yres, &supported_bars); for (i=1; i<=rows; i++) { @@ -1,4 +1,4 @@ -/* $Id: system.c,v 1.7 2000/03/18 08:07:04 reinelt Exp $ +/* $Id: system.c,v 1.8 2000/03/23 07:24:48 reinelt Exp $ * * system status retreivement * @@ -20,6 +20,10 @@ * * * $Log: system.c,v $ + * Revision 1.8 2000/03/23 07:24:48 reinelt + * + * PPM driver up and running (but slow!) + * * Revision 1.7 2000/03/18 08:07:04 reinelt * * vertical bars implemented @@ -503,10 +507,9 @@ int Sensor (int index, double *val, double *min, double *max) } snprintf(buffer, 32, "Sensor%d_min", index); - min_buf[index]=atof(cfg_get(buffer)); + min_buf[index]=atof(cfg_get(buffer)?:"0"); snprintf(buffer, 32, "Sensor%d_max", index); - max_buf[index]=atof(cfg_get(buffer)); - if (max_buf[index]==0.0) max_buf[index]=100.0; + max_buf[index]=atof(cfg_get(buffer)?:"100"); fd[index]=open(sensor[index], O_RDONLY); if (fd[index]==-1) { |