]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2003-09-09 05:30:33 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 9 Sep 2003 05:30:34 +0000 (05:30 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 9 Sep 2003 05:30:34 +0000 (05:30 +0000)
even more icons stuff

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

MatrixOrbital.c
TODO
USBLCD.c
bar.c
display.c
display.h
icon.c
icon.h
lcd4linux.c
processor.c
processor.h

index bf45282645444587aaf67821e1bd07d97f77544a..f27b04a0ca372e210580fe79dae0ec8f516ab96d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: MatrixOrbital.c,v 1.35 2003/09/01 04:09:34 reinelt Exp $
+/* $Id: MatrixOrbital.c,v 1.36 2003/09/09 05:30:33 reinelt Exp $
  *
  * driver for Matrix Orbital serial display modules
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: MatrixOrbital.c,v $
+ * Revision 1.36  2003/09/09 05:30:33  reinelt
+ * even more icons stuff
+ *
  * Revision 1.35  2003/09/01 04:09:34  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
@@ -274,6 +277,7 @@ static int MO_clear (int protocol)
   int gpo;
   
   memset (FrameBuffer1, ' ', Lcd.rows*Lcd.cols*sizeof(char));
+
   icon_clear();
   bar_clear();
   GPO=0;
@@ -365,18 +369,16 @@ static int MO_init (LCD *Self, int protocol)
   s=cfg_get("Icons", "0");
   Icons=strtol(s, &e, 0);
   if (*e!='\0' || Icons<0 || Icons>8) {
-    debug ("Icons=%d e=<%s>", Icons, e);
     error ("MatrixOrbital: bad Icons '%s' in %s, must be between 0 and 8", s, cfg_source());
     return -1;
   }    
   if (Icons>0) {
     info ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
+    icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MO_define_char);
     Self->icons=Icons;
     Lcd.icons=Icons;
   }
 
-  icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, MO_define_char);
-
   bar_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS-Icons);
   bar_add_segment(  0,  0,255, 32); // ASCII  32 = blank
   bar_add_segment(255,255,255,255); // ASCII 255 = block
@@ -446,9 +448,9 @@ int MO_icon_old (int num, int row, int col, unsigned char *bitmap)
 }
 
 
-int MO_icon (int num, int row, int col)
+int MO_icon (int num, int seq, int row, int col)
 {
-  return icon_draw (num, row, col);
+  return icon_draw (num, seq, row, col);
 }
 
 
diff --git a/TODO b/TODO
index 2ff0042d74e771d5659fd4d02f952ecb68fd9947..aead6e445d417976b1f8041efc8fdcd0de5829bd 100644 (file)
--- a/TODO
+++ b/TODO
@@ -58,10 +58,11 @@ will be done with the big config-rework
 // at least try to....
 // done 2001-03-14 -mr
 
-2001-03-09 Leo Tötsch <lt@toetsch.at>
-read configuration file earlier (before forking) so that specific drivers
-(especially 'Text') would not fork.
-There's a reason for forking that early, but I forgot...
+// 2001-03-09 Leo Tötsch <lt@toetsch.at>
+// read configuration file earlier (before forking) so that specific drivers
+// (especially 'Text') would not fork.
+// There's a reason for forking that early, but I forgot...
+// done somewhere in mid 2003 MR
 
 2001-03-12 Michael Reinelt <reinelt@eunet.at>
 remove USE_OLD_UDELAY after wide testing of new udelay code
@@ -89,10 +90,11 @@ change network clients to support different devices
 at the moment the sum of all eth* devices is calculated
 %n* should be extended tokens
 
-2001-03-24 Brian Cleven <lcleven@home.com>
-support 40x4 displays with two HD44780 chips on it
-we need another 'Enable' line for this
-this way one could connect two displays to one parallel port, too
+// 2001-03-24 Brian Cleven <lcleven@home.com>
+// support 40x4 displays with two HD44780 chips on it
+// we need another 'Enable' line for this
+// this way one could connect two displays to one parallel port, too
+// done with 0.9.11 MR
 
 // 2001-05-25 Jens Garthe <outline@xslan.de>
 // detect wether curses.h and libncurses is installed, and
@@ -126,3 +128,8 @@ should resume
 2002-02-15 Udo Altmann (udo.altmann@web.de)
 support for inversed/blinking text
 don't know if displays support this feature...
+
+2003-09-08 Michael Reinelt (reinelt@eunet.at>
+at least one of my HD44780 displays use an inverted "P" instead of 
+a full block. Therefore a bar my look strange. Make the ASCII code
+of the full block configurable...
index a3871aa7959daad02636be8fa4946f46cd9b8b89..54a0c02ff36fb2d3daa8f38797c28746562136b4 100644 (file)
--- a/USBLCD.c
+++ b/USBLCD.c
@@ -1,4 +1,4 @@
-/* $Id: USBLCD.c,v 1.12 2003/08/24 05:17:58 reinelt Exp $
+/* $Id: USBLCD.c,v 1.13 2003/09/09 05:30:34 reinelt Exp $
  *
  * Driver for USBLCD ( see http://www.usblcd.de )
  * This Driver is based on HD44780.c
@@ -22,6 +22,9 @@
  *
  *
  * $Log: USBLCD.c,v $
+ * Revision 1.13  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.12  2003/08/24 05:17:58  reinelt
  * liblcd4linux patch from Patrick Schemitz
  *
@@ -90,6 +93,7 @@
 #include "debug.h"
 #include "cfg.h"
 #include "display.h"
+#include "icon.h"
 #include "bar.h"
 
 #define GET_HARD_VERSION       1
 static LCD Lcd;
 static char *Port=NULL;
 static int usblcd_file;
+static int Icons;
 
 static char *FrameBuffer1=NULL;
 static char *FrameBuffer2=NULL;
@@ -203,6 +208,8 @@ int USBLCD_clear (int full)
 {
 
   memset (FrameBuffer1, ' ', Lcd.rows*Lcd.cols*sizeof(char));
+
+  icon_clear();
   bar_clear();
   
   if (full) {
@@ -217,7 +224,7 @@ int USBLCD_clear (int full)
 int USBLCD_init (LCD *Self)
 {
   int rows=-1, cols=-1 ;
-  char *port,*s ;
+  char *port, *s, *e;
 
   if (Port) {
     free(Port);
@@ -268,7 +275,21 @@ int USBLCD_init (LCD *Self)
   if (USBLCD_open()!=0)
     return -1;
   
-  bar_init(rows, cols, XRES, YRES, CHARS);
+  s=cfg_get("Icons", "0");
+  Icons=strtol(s, &e, 0);
+  if (*e!='\0' || Icons<0 || Icons>8) {
+    debug ("Icons=%d e=<%s>", Icons, e);
+    error ("USBLCD: bad Icons '%s' in %s, must be between 0 and 8", s, cfg_source());
+    return -1;
+  }    
+  if (Icons>0) {
+    info ("reserving %d of %d user-defined characters for icons", Icons, CHARS);
+    icon_init(Lcd.rows, Lcd.cols, XRES, YRES, CHARS, Icons, USBLCD_define_char);
+    Self->icons=Icons;
+    Lcd.icons=Icons;
+  }
+  
+  bar_init(rows, cols, XRES, YRES, CHARS-Icons);
   bar_add_segment(  0,  0,255, 32); // ASCII  32 = blank
   bar_add_segment(255,255,255,255); // ASCII 255 = block
 
@@ -304,11 +325,18 @@ int USBLCD_bar (int type, int row, int col, int max, int len1, int len2)
 }
 
 
+int USBLCD_icon (int num, int seq, int row, int col)
+{
+  return icon_draw (num, seq, row, col);
+}
+
+
 int USBLCD_flush (void)
 {
   int row, col, pos1, pos2;
   int c, equal;
-  
+  static int junk=0; //Fixme
+
   bar_process(USBLCD_define_char);
 
   for (row=0; row<Lcd.rows; row++) {
@@ -316,6 +344,11 @@ int USBLCD_flush (void)
       c=bar_peek(row, col);
       if (c!=-1) {
        FrameBuffer1[row*Lcd.cols+col]=(char)c;
+      } else {
+       c=icon_peek(row, col);
+       if (c!=-1) {
+         FrameBuffer1[row*Lcd.cols+col]=(char)c;
+       }
       }
     }
     for (col=0; col<Lcd.cols; col++) {
@@ -377,11 +410,13 @@ LCD USBLCD[] = {
     xres:  XRES,
     yres:  YRES,
     bars:  BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2,
+    icons: 0,
     gpos:  0,
     init:  USBLCD_init,
     clear: USBLCD_clear,
     put:   USBLCD_put,
     bar:   USBLCD_bar,
+    icon:  USBLCD_icon,
     gpo:   NULL,
     flush: USBLCD_flush,
     quit:  USBLCD_quit 
diff --git a/bar.c b/bar.c
index 9b3f826f81f3bbf5d1b5e51662228439f9f5d4ff..f6e96bfa932711dba62f3040e3d5500560fe5c6e 100644 (file)
--- a/bar.c
+++ b/bar.c
@@ -1,4 +1,4 @@
-/* $Id: bar.c,v 1.7 2003/09/01 04:09:34 reinelt Exp $
+/* $Id: bar.c,v 1.8 2003/09/09 05:30:34 reinelt Exp $
  *
  * generic bar handling
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: bar.c,v $
+ * Revision 1.8  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.7  2003/09/01 04:09:34  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
@@ -211,8 +214,10 @@ int bar_draw (int type, int row, int col, int max, int len1, int len2)
 
 static void create_segments (void)
 {
+  int RES;
   int i, j, n;
-  
+  int l1, l2;
+
   /* find first unused segment */
   for (i=fSegment; i<nSegment && Segment[i].used; i++);
 
@@ -226,10 +231,13 @@ static void create_segments (void)
   /* create needed segments */
   for (n=0; n<ROWS*COLS; n++) {
     if (Bar[n].type==0) continue;
+    RES=Bar[n].type & BAR_H ? XRES:YRES;
     for (i=0; i<nSegment; i++) {
-      if (Segment[i].type & Bar[n].type &&
-         Segment[i].len1== Bar[n].len1 &&
-         Segment[i].len2== Bar[n].len2) break;
+      if (Segment[i].type & Bar[n].type) {
+       l1=Segment[i].len1; if (l1>RES) l1=RES;
+       l2=Segment[i].len2; if (l2>RES) l2=RES;
+       if (l1 == Bar[n].len1 && l2 == Bar[n].len2) break;
+      }
     }
     if (i==nSegment) {
       nSegment++;
index 5028b0271838f841a9e6c87aafee6de973ac6c79..ecc58a50ff927b2c70a2dc4f0c5c48d41000680e 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.40 2003/09/01 04:09:34 reinelt Exp $
+/* $Id: display.c,v 1.41 2003/09/09 05:30:34 reinelt Exp $
  *
  * framework for device drivers
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: display.c,v $
+ * Revision 1.41  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.40  2003/09/01 04:09:34  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
  * int lcd_bar (int type, int row, int col, int max, int len1, int len2)
  *    draws a specified bar at row, col with len
  *
+ * int lcd_icon (int num, int seq, int row, int col)
+ *    draws icon #num sequence #seq at row, col
+ *
  * int lcd_gpo (int num, int val)
  *    sets GPO #num to val
  *
@@ -290,6 +296,7 @@ FAMILY Driver[] = {
 
 static LCD *Lcd = NULL;
 
+
 int lcd_list (void)
 {
   int i, j;
@@ -306,6 +313,7 @@ int lcd_list (void)
   return 0;
 }
 
+
 int lcd_init (char *driver)
 {
   int i, j;
@@ -322,6 +330,7 @@ int lcd_init (char *driver)
   return -1;
 }
 
+
 int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *icons, int *gpos)
 {
   if (Lcd==NULL)
@@ -338,6 +347,7 @@ int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *icons
   return 0;
 }
 
+
 int lcd_clear (int full)
 {
   if (Lcd->clear==NULL) return 0;
@@ -352,8 +362,10 @@ int lcd_put (int row, int col, char *text)
   return Lcd->put(row-1, col-1, text);
 }
 
+
 int lcd_bar (int type, int row, int col, int max, int len1, int len2)
 {
+  if (Lcd->bar==NULL) return 0;
   if (row<1 || row>Lcd->rows) return -1;
   if (col<1 || col>Lcd->cols) return -1;
   if (!(type & (BAR_H2 | BAR_V2 | BAR_T))) len2=len1;
@@ -362,32 +374,36 @@ int lcd_bar (int type, int row, int col, int max, int len1, int len2)
     if (!(type & BAR_T))
       len2=(double)max*log(len2+1)/log(max); 
   }
-  if (Lcd->bar==NULL) return 0;
   return Lcd->bar (type & BAR_HV, row-1, col-1, max, len1, len2);
 }
 
-int lcd_icon (int num, int row, int col)
+
+int lcd_icon (int num, int seq, int row, int col)
 {
+  if (Lcd->icon==NULL)         return  0;
   if (num<1 || num>Lcd->icons) return -1;
+  if (seq<1)                   return -1;
   if (row<1 || row>Lcd->rows)  return -1;
   if (col<1 || col>Lcd->cols)  return -1;
-  if (Lcd->icon==NULL)         return  0;
-  return Lcd->icon(num-1, row-1, col-1);
+  return Lcd->icon(num-1, seq-1, row-1, col-1);
 }
 
+
 int lcd_gpo (int num, int val)
 {
-  if (num<1 || num>Lcd->gpos) return -1;
   if (Lcd->gpo==NULL) return 0;
+  if (num<1 || num>Lcd->gpos) return -1;
   return Lcd->gpo(num-1, val);
 }
 
+
 int lcd_flush (void)
 {
   if (Lcd->flush==NULL) return 0;
   return Lcd->flush();
 }
 
+
 int lcd_quit (void)
 {
   if (Lcd->quit==NULL) return 0;
index 11510aa25771913169a7f345d776362a13b542fd..748f8e609f3b234ff851d66ace979ed9af341202 100644 (file)
--- a/display.h
+++ b/display.h
@@ -1,4 +1,4 @@
-/* $Id: display.h,v 1.20 2003/09/01 04:09:34 reinelt Exp $
+/* $Id: display.h,v 1.21 2003/09/09 05:30:34 reinelt Exp $
  *
  * framework for device drivers
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: display.h,v $
+ * Revision 1.21  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.20  2003/09/01 04:09:34  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
@@ -115,7 +118,7 @@ typedef struct LCD {
   int (*clear) (int full);
   int (*put)   (int x, int y, char *text);
   int (*bar)   (int type, int x, int y, int max, int len1, int len2);
-  int (*icon)  (int num, int row, int col);
+  int (*icon)  (int num, int seq, int row, int col);
   int (*gpo)   (int num, int val);
   int (*flush) (void);
   int (*quit)  (void);
@@ -138,7 +141,7 @@ int lcd_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *icons
 int lcd_clear (int full);
 int lcd_put   (int row, int col, char *text);
 int lcd_bar   (int type, int row, int col, int max, int len1, int le2);
-int lcd_icon  (int num, int row, int col);
+int lcd_icon  (int num, int seq, int row, int col);
 int lcd_gpo   (int num, int val);
 int lcd_flush (void);
 int lcd_quit  (void);
diff --git a/icon.c b/icon.c
index ae5e33210bcd8006f8c81608176d211a496181a2..12e5a226540a1dbbc52263e9ab3fef60e9e6fcb7 100644 (file)
--- a/icon.c
+++ b/icon.c
@@ -1,4 +1,4 @@
-/* $Id: icon.c,v 1.3 2003/09/01 04:09:34 reinelt Exp $
+/* $Id: icon.c,v 1.4 2003/09/09 05:30:34 reinelt Exp $
  *
  * generic icon and heartbeat handling
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: icon.c,v $
+ * Revision 1.4  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.3  2003/09/01 04:09:34  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
  *
  */
 
+/* 
+ * exported functions:
+ *
+ * int icon_init (int rows, int cols, int xres, int yres, int chars, int icons, 
+ *                void(*defchar)(int ascii, char *bitmap))
+ *   initializes all icons stuff and reads the bitmaps from config file.
+ *
+ * void icon_clear(void)
+ *   clears the icon framebuffer
+ *
+ * int icon_draw (int num, int seq, int row, int col)
+ *   puts icon #num sequence #seq at position row, col in the icon framebuffer
+ *
+ * int icon_peek (int row, int col)
+ *   returns icon# or -1 if none from position row, col 
+ *
+ */
+
 
 #include <stdlib.h>
 #include <stdio.h>
 #include "icon.h"
 
 
+typedef struct BITMAP {
+  int  nData;
+  int  lData;
+  char *Data;
+} BITMAP;
+
 static int ROWS=0;
 static int COLS=0;
 static int XRES=0;
@@ -49,35 +76,49 @@ static int YRES=0;
 static int CHARS;
 static int ICONS=0;
 
-static int *Screen=NULL;
-static char *Bitmap=NULL;
+static int  *Screen=NULL;
+static struct BITMAP *Bitmap=NULL;
+static void(*Defchar)(int ascii, char *bitmap);
+
 
-static int icon_read_bitmap (int num, char *bitmap)
+static int icon_read_bitmap (int num)
 {
-  int row, col, len;
+  struct BITMAP *bm = Bitmap+num;
+  int row, n;
   char  key[15];
-  char *val;
-  char map;
+  char *val, *v;
+  char *map;
   
   for (row=0; row<YRES; row++) {
     snprintf (key, sizeof(key), "Icon%d.Bitmap%d", num+1, row+1);
-    val=cfg_get(key, "");
-    len=strlen(val);
-    map=0;
-    debug ("read_bitmap: num=%d row=%d val=<%s> len=%d", num, row, val, len);
-    for (col=0; col<XRES; col++) {
-      map<<=1;
-      if (col<len && val[col]=='*') {
-       map|=1;
+    val=cfg_get(key, ""); 
+    map=bm->Data+row;
+    n=0;
+    for (v=val; *v!='\0'; v++) {
+      if (n>=bm->nData) {
+       bm->nData++;
+       bm->Data=realloc(bm->Data, bm->nData*YRES*sizeof(char));
+       memset (bm->Data+n*YRES, 0, YRES*sizeof(char));
+       map=bm->Data+n*YRES+row;
+      }
+      switch (*v) {
+      case '|':
+       n++;
+       map+=YRES;
+       break;
+      case '*':
+       (*map)<<=1;
+       (*map)|=1;
+       break;
+      default:
+       (*map)<<=1;
       }
     }
-    *(bitmap+row-1)=map;
   }
   return 0;
 }
 
 
-
 int icon_init (int rows, int cols, int xres, int yres, int chars, int icons, 
                void(*defchar)(int ascii, char *bitmap))
 {
@@ -108,19 +149,23 @@ int icon_init (int rows, int cols, int xres, int yres, int chars, int icons,
     free (Bitmap);
   }
 
-  if ((Bitmap=malloc(YRES*icons*sizeof(*Bitmap)))==NULL) {
-    error ("icon bitmap allocation failed: out of memory");
+  if ((Bitmap=malloc(icons*sizeof(*Bitmap)))==NULL) {
+    error ("icon allocation failed: out of memory");
     return -1;
   }
-
-  memset (Bitmap, 0, YRES*icons*sizeof(*Bitmap));
+  
+  Defchar=defchar;
   
   for (n=0; n<icons; n++) {
-    icon_read_bitmap(n, Bitmap+YRES*n);
+    Bitmap[n].nData=1;
+    Bitmap[n].lData=0;
+    Bitmap[n].Data=malloc(YRES*sizeof(char));
+    memset (Bitmap[n].Data, 0, YRES*sizeof(char));
+    icon_read_bitmap(n);
     // icons use last ascii codes from userdef chars
-    defchar (CHARS-n-1, Bitmap+YRES*n);
+    Defchar (CHARS-n-1, Bitmap[n].Data);
   }
-
+  
   return 0;
 }
 
@@ -136,10 +181,24 @@ void icon_clear(void)
 }
 
 
-int icon_draw (int num, int row, int col)
+int icon_draw (int num, int seq, int row, int col)
 {
+  if (num>=ICONS) return -1;
+  if (row>=ROWS)  return -1;
+  if (col>=COLS)  return -1;
+
+  seq%=Bitmap[num].nData;
+  if (seq!=Bitmap[num].lData) {
+    Bitmap[num].lData=seq;
+    Defchar (CHARS-num-1, Bitmap[num].Data+seq*YRES);
+  }
+  
+  // just redefine icon?
+  if (row<0 || col<0) return 0;
+  
   // icons use last ascii codes from userdef chars
   Screen[row*COLS+col]=CHARS-num-1;
+
   return 0;
 }
 
diff --git a/icon.h b/icon.h
index caa3edbc95a89028a3fe44c8ef22cf2d0a4b37c0..348d63da99b3401c08c08a03a816055be3259212 100644 (file)
--- a/icon.h
+++ b/icon.h
@@ -1,4 +1,4 @@
-/* $Id: icon.h,v 1.2 2003/09/01 04:09:35 reinelt Exp $
+/* $Id: icon.h,v 1.3 2003/09/09 05:30:34 reinelt Exp $
  *
  * generic icon and heartbeat handling
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: icon.h,v $
+ * Revision 1.3  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.2  2003/09/01 04:09:35  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
@@ -35,7 +38,7 @@
 int  icon_init (int rows, int cols, int xres, int yres, int chars, int icons, 
                void(*defchar)(int ascii, char *bitmap));
 void icon_clear(void);
-int  icon_draw (int num, int row, int col);
+int  icon_draw (int num, int seq, int row, int col);
 int  icon_peek (int row, int col);
 
 #endif
index f4e5b2886f8335e8b23c814fde2ea1dab5122eb6..400fdd0411930296f6884575882a93c5a8c13c90 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.44 2003/08/24 05:17:58 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.45 2003/09/09 05:30:34 reinelt Exp $
  *
  * LCD4Linux
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: lcd4linux.c,v $
+ * Revision 1.45  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.44  2003/08/24 05:17:58  reinelt
  * liblcd4linux patch from Patrick Schemitz
  *
 char *release="LCD4Linux " VERSION " (c) 2003 Michael Reinelt <reinelt@eunet.at>";
 char **my_argv;
 int got_signal=0;
-int tick, tack;
 
 extern char* output;
 
@@ -319,7 +321,9 @@ int main (int argc, char *argv[])
 {
   char *cfg="/etc/lcd4linux.conf";
   char *driver;
-  int c, smooth;
+  char *s, *e;
+  int c;
+  int tick;
   int quiet=0;
   
   // save arguments for restart
@@ -462,27 +466,29 @@ int main (int argc, char *argv[])
   signal(SIGQUIT, handler);
   signal(SIGTERM, handler);
   
-  tick=atoi(cfg_get("tick","100"));
-  tack=atoi(cfg_get("tack","500"));
-
+  s=cfg_get("tick", "100");
+  tick=strtol(s, &e, 0);
+  if (*e!='\0' || tick<0) {
+    error ("bad tick entry '%s' in %s", s, cfg_source());
+    pid_exit(PIDFILE);
+    exit (1);
+  }
+  
   process_init();
   lcd_clear(1);
-
+  
   if (!quiet && hello()) {
     sleep (3);
     lcd_clear(1);
   }
   
   debug ("starting main loop");
-
-  smooth=0;
+  
   while (got_signal==0) {
-    process (smooth);
-    smooth+=tick;
-    if (smooth>tack) smooth=0;
+    process ();
     usleep(tick*1000);
   }
-
+  
   debug ("leaving main loop");
   
   lcd_clear(1);
index 1ca308a5e8e2785f240a339c0c47a2928311952c..67e1129b1b17773d192eec0c8db54f9daa7f2b11 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.38 2003/09/01 04:09:35 reinelt Exp $
+/* $Id: processor.c,v 1.39 2003/09/09 05:30:34 reinelt Exp $
  *
  * main data processing
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: processor.c,v $
+ * Revision 1.39  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.38  2003/09/01 04:09:35  reinelt
  * icons nearly finished, but MatrixOrbital only
  *
  * void process_init (void);
  *   does all necessary initializations
  *
- * void process (int smooth);
+ * void process ();
  *   processes a whole screen
- *   bars will always be processed
- *   texts only if smooth=0
  *
  */
 
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -224,6 +226,7 @@ static struct { int num, unseen;} mail[MAILBOXES+1];
 static struct { double val, min, max; } sensor[SENSORS+1];
 static struct { double strength, snr; } dvb;
 
+
 static double query (int token)
 {
   switch (token&255) {
@@ -332,6 +335,7 @@ static double query (int token)
   return 0.0;
 }
 
+
 /* return a value 0..1 */
 static double query_bar (int token)
 {
@@ -401,6 +405,7 @@ static double query_bar (int token)
   return value;
 }
 
+
 static void print_token (int token, char **p, char *start)
 {
   double val;
@@ -513,12 +518,12 @@ static void print_token (int token, char **p, char *start)
     break;
   case T_BATT_STAT:  
     { int ival = (int) query(token);
-      switch (ival) {
-        case 0: **p = '='; break;
-        case 1: **p = '+'; break;
-        case 2: **p = '-'; break;
-        default: **p = '?'; break;
-      }
+    switch (ival) {
+    case 0: **p = '='; break;
+    case 1: **p = '+'; break;
+    case 2: **p = '-'; break;
+    default: **p = '?'; break;
+    }
     }
     (*p)++;
     break;
@@ -553,10 +558,11 @@ static void print_token (int token, char **p, char *start)
     break;
     
   default:
-      *p+=sprintf (*p, "%5.0f", query(token));
+    *p+=sprintf (*p, "%5.0f", query(token));
   }
 }
 
+
 static void collect_data (void) 
 {
   int i;
@@ -635,6 +641,7 @@ static void collect_data (void)
 
 }
 
+
 static char *process_row (char *data, int row, int len)
 {
   static char buffer[256];
@@ -674,14 +681,14 @@ static char *process_row (char *data, int row, int len)
       
       if (type & BAR_H) {
        for (i=0; i<len && p-buffer<cols; i++)
-         *p++='\t';
+         *p++=' ';
       } else {
-       *p++='\t';
+       *p++=' ';
       }
       
     } else if (*s=='&') {
-      lcd_icon(*(++s)-'0', row, p-buffer+1);
-      *p++='\t';
+      lcd_icon(*(++s)-'0', 1, row, p-buffer+1);
+      *p++=' ';
       
     } else {
       *p++=*s;
@@ -698,6 +705,7 @@ static char *process_row (char *data, int row, int len)
   return buffer;
 }
 
+
 static int process_gpo (int n)
 {
   int token;
@@ -709,6 +717,7 @@ static int process_gpo (int n)
   return (val > 0.0);
 }
 
+
 static int Turn (void)
 {
   static struct timeval old = {tv_sec:0, tv_usec:0};
@@ -736,6 +745,7 @@ static int Turn (void)
   return 0;
 }
 
+
 void process_init (void)
 {
   int i;
@@ -809,7 +819,8 @@ void process_init (void)
   }
 }
 
-void process (int smooth)
+
+void process (void)
 {
   int i, j, val;
   char *txt;
index eb489a4f353e117c48fecaa22807a2c5f99d51fc..6554590ffd0333024ab3bf5d516c666827779ca7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: processor.h,v 1.1 2000/03/22 07:33:50 reinelt Exp $
+/* $Id: processor.h,v 1.2 2003/09/09 05:30:34 reinelt Exp $
  *
  * main data processing
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: processor.h,v $
+ * Revision 1.2  2003/09/09 05:30:34  reinelt
+ * even more icons stuff
+ *
  * Revision 1.1  2000/03/22 07:33:50  reinelt
  *
  * FAQ added
@@ -31,6 +34,6 @@
 #define _PROCESSOR_H_
 
 void process_init (void);
-void process (int smooth);
+void process (void);
 
 #endif