]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2000-03-23 07:24:48 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 23 Mar 2000 07:24:48 +0000 (07:24 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 23 Mar 2000 07:24:48 +0000 (07:24 +0000)
PPM driver up and running (but slow!)

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@17 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

12 files changed:
Makefile.am
Makefile.in
MatrixOrbital.c
Raster.c [new file with mode: 0644]
XWindow.c
display.c
filter.c
lcd4linux.c
lcd4linux.conf.sample
pixmap.c
processor.c
system.c

index 443f5274431e345286d52c767ccf6cf2e33dfedc..1d50bf1bf9d77762f2703e2610305fb5c2ebd3a5 100644 (file)
@@ -19,6 +19,7 @@ lcd4linux_SOURCES = \
        fontmap.c fontmap.h \
        Skeleton.c \
        MatrixOrbital.c \
+       Raster.c \
        XWindow.c
 
 
index 0bb31439050a30996a080a37c0ed1e32d1b9aa16..c6949c3f0895a3e13eb2d1ed5807d243c5431b2f 100644 (file)
@@ -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)
 
index e4618589029ae3f2da01cbe4e655b955da3b6b01..c188663af0b1b3b99a19d179537a0f8aa70272cf 100644 (file)
@@ -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
  *
  *
  *
  * $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 (file)
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 },
+  { "" }
+};
index 259caf899651ea01a83a9571215c4372256a239e..e332f0bec7d35546891dd2af06681ba4ac637d45 100644 (file)
--- a/XWindow.c
+++ b/XWindow.c
@@ -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
  *
  *
  *
  * $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");
index c06f36ae086877081bff8bace2fd9cfcf690b28e..ec9a8012261630bef0e057d55051244f00094be8 100644 (file)
--- a/display.c
+++ b/display.c
@@ -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
  *
  *
  *
  * $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)
 
 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 },
   { "" }
 };
index 1fbf9c2a73b068cb13fc938b9df2edb572316bcf..93d7a221254a7633b1102fb34d7f0ca74974e715 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -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
  *
  *
  *
  * $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;
index b9fd02445eacfcc6a389d82b349a548573c84a50..668e3b143ad5b425022d208668eb625068154009 100644 (file)
@@ -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
  *
  *
  *
  * $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();
 
index f00c93e2df91bb4a3b644b8e5c0f88381eae1641..cb68fba3129ae307e91b7cd76e036d24692ec1e7 100644 (file)
@@ -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"
index ceaa1f22e22db8569dfde9932b6b2e2ee78f2918..48343cbe610becf6e12d2da83038d49545d0b601 100644 (file)
--- a/pixmap.c
+++ b/pixmap.c
@@ -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
  *
  *
  *
  * $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;
index 6c95208e4fb0493e49335a37f2d6c08e351a320d..c381e72f41bc65f9aa47722d17816d5107d27ed1 100644 (file)
@@ -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
  *
  *
  *
  * $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++) {
index a666e6000d69bcaf0cfe00260e5c5a8de8a0eeb2..b8c71b62bcb11bbe9b90a81bb943873f02bb4839 100644 (file)
--- a/system.c
+++ b/system.c
@@ -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
  *
  *
  *
  * $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) {