]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-01-22 07:57:45 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 22 Jan 2004 07:57:45 +0000 (07:57 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 22 Jan 2004 07:57:45 +0000 (07:57 +0000)
several bugs fixed where segfaulting on layout>display
Crystalfontz driver optimized, 632 display already works

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

cfg.c
drv_Crystalfontz.c
drv_HD44780.c
drv_MatrixOrbital.c
drv_generic_text.c
drv_generic_text.h
hash.c
lcd4linux.conf.sample
widget_text.c

diff --git a/cfg.c b/cfg.c
index 6fbef65f4a01fcad9acd6fbf484cfd5c51958911..1a565e4239f991432c5e06365b77120d6eb32998 100644 (file)
--- a/cfg.c
+++ b/cfg.c
@@ -1,4 +1,4 @@
-/* $Id: cfg.c,v 1.29 2004/01/18 06:54:08 reinelt Exp $^
+/* $Id: cfg.c,v 1.30 2004/01/22 07:57:45 reinelt Exp $^
  *
  * config file stuff
  *
  *
  *
  * $Log: cfg.c,v $
+ * Revision 1.30  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.29  2004/01/18 06:54:08  reinelt
  * bug in expr.c fixed (thanks to Xavier)
  * some progress with /proc/stat parsing
@@ -289,7 +293,7 @@ static int validchars (char *string)
     // first and following chars
     if ((*c>='A' && *c<='Z') || (*c>='a' && *c<='z') || (*c=='_')) continue;
     // only following chars
-    if ((c>string) && ((*c>='0' && *c<='9') || (*c=='.'))) continue;
+    if ((c>string) && ((*c>='0' && *c<='9') || (*c=='.') || (*c=='-'))) continue;
     return 0;
   }
   return 1;
index 5c3bf1b09223c8c89f3b5793a880cb16f23aba46..bff3ccd2bc87c664bcbc9d5b772a2f2396c399bd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_Crystalfontz.c,v 1.1 2004/01/21 12:36:19 reinelt Exp $
+/* $Id: drv_Crystalfontz.c,v 1.2 2004/01/22 07:57:45 reinelt Exp $
  *
  * new style driver for Crystalfontz display modules
  *
  *
  *
  * $Log: drv_Crystalfontz.c,v $
+ * Revision 1.2  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.1  2004/01/21 12:36:19  reinelt
  * Crystalfontz NextGeneration driver added
  *
@@ -107,7 +111,8 @@ static void drv_CF_define_char (int ascii, char *buffer)
 {
   char cmd[2]="\031n"; // set custom char bitmap
 
-  cmd[1]=(char)ascii;
+  // user-defineable chars start at 128, but are defined at 0
+  cmd[1]=(char)(ascii-CHAR0); 
   drv_generic_serial_write (cmd, 2);
   drv_generic_serial_write (buffer, 8);
 }
@@ -234,9 +239,10 @@ int drv_CF_init (char *section)
   WIDGET_CLASS wc;
   int ret;  
   
-  XRES=5;
-  YRES=8;
-  CHARS=8;
+  XRES=6;    // pixel width  of one char 
+  YRES=8;    // pixel height of one char 
+  CHARS=8;   // number of user-defineable chars
+  CHAR0=128; // ascii of first user-defineable chars
   
   // start display
   if ((ret=drv_CF_start (section))!=0)
@@ -251,8 +257,7 @@ int drv_CF_init (char *section)
     return ret;
   
   // add fixed chars to the bar driver
-  drv_generic_text_bar_add_segment (  0,  0,255, 32); // ASCII  32 = blank
-  drv_generic_text_bar_add_segment (255,255,255,255); // ASCII 255 = block
+  drv_generic_text_bar_add_segment (0, 0, 255, 32); // ASCII 32 = blank
   
   // register text widget
   wc=Widget_Text;
index 8432057049aab5faf8fdeba30a9f0380f4deef44..3201a55849023105ac60110b533bf107e05bba07 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_HD44780.c,v 1.2 2004/01/21 06:39:27 reinelt Exp $
+/* $Id: drv_HD44780.c,v 1.3 2004/01/22 07:57:45 reinelt Exp $
  *
  * new style driver for HD44780-based displays
  *
  *
  *
  * $Log: drv_HD44780.c,v $
+ * Revision 1.3  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.2  2004/01/21 06:39:27  reinelt
  * HD44780 missed the "clear display' sequence
  * asc255bug handling added
@@ -434,9 +438,10 @@ int drv_HD_init (char *section)
   int asc255bug;
   int ret;  
   
-  XRES=5;
-  YRES=8;
-  CHARS=8;
+  XRES=5;  // pixel width  of one char 
+  YRES=8;  // pixel height of one char 
+  CHARS=8; // number of user-defineable chars
+  CHAR0=0; // ascii of first user-defineable chars
   
   // start display
   if ((ret=drv_HD_start (section))!=0)
index 3a20bfb0a4bec2f03c1d0ca24060ddf1e5eb26f6..d7adab160a8a8fc586e5ae4e35d67093db459cfc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_MatrixOrbital.c,v 1.15 2004/01/21 12:36:19 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.16 2004/01/22 07:57:45 reinelt Exp $
  *
  * new style driver for Matrix Orbital serial display modules
  *
  *
  *
  * $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.16  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.15  2004/01/21 12:36:19  reinelt
  * Crystalfontz NextGeneration driver added
  *
@@ -448,9 +452,10 @@ int drv_MO_init (char *section)
   WIDGET_CLASS wc;
   int ret;  
   
-  XRES=5;
-  YRES=8;
-  CHARS=8;
+  XRES=5;  // pixel width  of one char 
+  YRES=8;  // pixel height of one char 
+  CHARS=8; // number of user-defineable chars
+  CHAR0=0; // ascii of first user-defineable chars
   
   // start display
   if ((ret=drv_MO_start (section))!=0)
index 0ba2f108ab6979bb1b74bc926154caf0b08f0a64..87e22aea9f4fdb194fd4c93dca7be20a7294e5e1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.c,v 1.3 2004/01/20 14:25:12 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.4 2004/01/22 07:57:45 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.c,v $
+ * Revision 1.4  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.3  2004/01/20 14:25:12  reinelt
  * some reorganization
  * moved drv_generic to drv_generic_serial
@@ -84,11 +88,11 @@ static char   *Driver;
 int DROWS, DCOLS; // display size
 int LROWS, LCOLS; // layout size
 int XRES,  YRES;  // pixels of one char cell
-int CHARS;        // number of user-defineable characters
+int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char
 
 char *LayoutFB  = NULL;
 char *DisplayFB = NULL;
-static BAR  *Bar       = NULL;
+static BAR *Bar = NULL;
 
 static int nSegment=0;
 static int fSegment=0;
@@ -103,15 +107,17 @@ static SEGMENT Segment[128];
 void drv_generic_text_resizeFB (int rows, int cols)
 {
   char *newFB;
-  int row, col;
+  BAR *newBar;
+  int i, row, col;
   
-  // Fixme: resize Bar FB too!!!!
-
-
   // Layout FB is large enough
   if (rows<=LROWS && cols<=LCOLS)
     return;
   
+  // get maximum values
+  if (rows<LROWS) rows=LROWS;
+  if (cols<LCOLS) cols=LCOLS;
+  
   // allocate new Layout FB
   newFB=malloc(cols*rows*sizeof(char));
   memset (newFB, ' ', rows*cols*sizeof(char));
@@ -125,8 +131,32 @@ void drv_generic_text_resizeFB (int rows, int cols)
     }
     free (LayoutFB);
   }
-  
   LayoutFB = newFB;
+
+  
+  // resize Bar buffer
+  if (Bar) {
+
+    newBar=malloc (rows*cols*sizeof(BAR));
+
+    for (i=0; i<rows*cols; i++) {
+      newBar[i].val1    = -1;
+      newBar[i].val2    = -1;
+      newBar[i].dir     =  0;
+      newBar[i].segment = -1;
+    }
+    
+    // transfer contents
+    for (row=0; row<LROWS; row++) {
+      for (col=0; col<LCOLS; col++) {
+       newBar[row*cols+col]=Bar[row*LCOLS+col];
+      }
+    }
+
+    free (Bar);
+    Bar=newBar;
+  }
+  
   LCOLS    = cols;
   LROWS    = rows;
 }
@@ -148,7 +178,7 @@ int drv_generic_text_draw_text (WIDGET *W, int goto_len,
   end=col+len;
   
   // maybe grow layout framebuffer
-  drv_generic_text_resizeFB (row, col+len-1);
+  drv_generic_text_resizeFB (row+1, col+len);
 
   fb1 = LayoutFB  + row*LCOLS;
   fb2 = DisplayFB + row*DCOLS;
@@ -156,24 +186,26 @@ int drv_generic_text_draw_text (WIDGET *W, int goto_len,
   // transfer new text into layout buffer
   memcpy (fb1+col, txt, len);
   
-  for (; col<=end; col++) {
-    int pos1, pos2, equal;
-    if (fb1[col]==fb2[col]) continue;
-    drv_goto (row, col);
-    for (pos1=col, pos2=pos1, col++, equal=0; col<=end; col++) {
-      if (fb1[col]==fb2[col]) {
-       // If we find just one equal byte, we don't break, because this 
-       // would require a goto, which takes several bytes, too.
-       if (++equal>goto_len) break;
-      } else {
-       pos2=col;
-       equal=0;
+  if (row<DROWS) {
+    for (; col<=end && col<DCOLS; col++) {
+      int pos1, pos2, equal;
+      if (fb1[col]==fb2[col]) continue;
+      drv_goto (row, col);
+      for (pos1=col, pos2=pos1, col++, equal=0; col<=end && col<DCOLS; col++) {
+       if (fb1[col]==fb2[col]) {
+         // If we find just one equal byte, we don't break, because this 
+         // would require a goto, which takes several bytes, too.
+         if (++equal>goto_len) break;
+       } else {
+         pos2=col;
+         equal=0;
+       }
       }
+      memcpy    (fb2+pos1, fb1+pos1, pos2-pos1+1);
+      drv_write (fb2+pos1,           pos2-pos1+1);
     }
-    memcpy    (fb2+pos1, fb1+pos1, pos2-pos1+1);
-    drv_write (fb2+pos1,           pos2-pos1+1);
   }
-  
+
   return 0;
 }
 
@@ -202,7 +234,7 @@ static void drv_generic_text_bar_clear(void)
 static void drv_generic_text_bar_create_bar (int row, int col, DIRECTION dir, int len, int val1, int val2)
 {
   int rev=0;
-  
+
   switch (dir) {
   case DIR_WEST:
     val1 = len-val1;
@@ -441,7 +473,7 @@ static void drv_generic_text_bar_define_chars (void(*defchar)(int ascii, char *m
       }
       break;
     }
-    defchar(c, buffer);
+    defchar(CHAR0+c, buffer);
   }
 }
 
@@ -464,9 +496,9 @@ int drv_generic_text_draw_bar (WIDGET *W, int goto_len,
   // maybe grow layout framebuffer
   // bars *always* grow heading North or East!
   if (dir & (DIR_EAST|DIR_WEST)) {
-    drv_generic_text_resizeFB (row, col+len-1);
+    drv_generic_text_resizeFB (row+1, col+len);
   } else {
-    drv_generic_text_resizeFB (row, col);
+    drv_generic_text_resizeFB (row+1, col+1);
   }
 
   res  = dir & (DIR_EAST|DIR_WEST)?XRES:YRES;
@@ -504,6 +536,7 @@ int drv_generic_text_draw_bar (WIDGET *W, int goto_len,
     if (s==-1) continue;
     c=Segment[s].ascii;
     if (c==-1) continue;
+    if (s>=fSegment) c+=CHAR0; // ascii offset for user-defineable chars
     if(c==LayoutFB[n]) continue;
     LayoutFB[n]=c;
   }
index f742427c4d7ea0813b643c2b3744c5e1877e2871..e1468f547f4ba4936d37590bc673aca61977575e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: drv_generic_text.h,v 1.1 2004/01/20 05:36:59 reinelt Exp $
+/* $Id: drv_generic_text.h,v 1.2 2004/01/22 07:57:45 reinelt Exp $
  *
  * generic driver helper for text-based displays
  *
  *
  *
  * $Log: drv_generic_text.h,v $
+ * Revision 1.2  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.1  2004/01/20 05:36:59  reinelt
  * moved text-display-specific stuff to drv_generic_text
  * moved all the bar stuff from drv_generic_bar to generic_text
@@ -48,7 +52,7 @@
 extern int DROWS, DCOLS; // display size
 extern int LROWS, LCOLS; // layout size
 extern int XRES,  YRES;  // pixels of one char cell
-extern int CHARS;        // number of user-defineable characters
+extern int CHARS, CHAR0; // number of user-defineable characters, ASCII of first char
 
 
 extern char *LayoutFB;
diff --git a/hash.c b/hash.c
index 3d7a6e35dd1ea9cd1917a33d2aa846247cce32f8..20e574db44285926543daa001333c0e7e43ba07c 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.8 2004/01/21 14:29:03 reinelt Exp $
+/* $Id: hash.c,v 1.9 2004/01/22 07:57:45 reinelt Exp $
  *
  * hashes (associative arrays)
  *
  *
  *
  * $Log: hash.c,v $
+ * Revision 1.9  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.8  2004/01/21 14:29:03  reinelt
  * new helper 'hash_get_regex' which delivers the sum over regex matched items
  * new function 'disk()' which uses this regex matching
@@ -299,7 +303,6 @@ double hash_get_regex (HASH *Hash, char *key, int delay)
   regex_t preg;
   int i, err;
   
-  debug ("Michi: regex=<%s>", key);
   err=regcomp(&preg, key, REG_ICASE|REG_NOSUB);
   if (err!=0) {
     char buffer[32];
@@ -312,9 +315,7 @@ double hash_get_regex (HASH *Hash, char *key, int delay)
   hash_lookup(Hash, "", 1);
   
   for (i=0;i<Hash->nItems; i++) {
-    debug ("Michi: Testing <%s>", Hash->Items[i].key);
     if (regexec(&preg, Hash->Items[i].key, 0, NULL, 0)==0) {
-      debug ("Michi: MATCHED <%s>", Hash->Items[i].key);
       sum+=hash_get_delta(Hash, Hash->Items[i].key, delay);
     }
   }
index 5e085572f2b1b178814c0b2cedecfcd173be03a8..d228c3ebc8227fea154348634f049131e9235e63 100644 (file)
@@ -8,7 +8,14 @@ Display LK204 {
 }
 
 
-Display myHD44780 {
+Display CF632 {
+    Driver 'Crystalfontz'
+    Model '632'
+    Port '/dev/tts/0'
+    Speed 19200
+}
+
+Display HD44780-20x4 {
     Driver 'HD44780'
     Port '/dev/parports/0'     
 #   Port '0x378'
@@ -27,8 +34,9 @@ Display myHD44780 {
 Widget OS {
     class 'Text'
     expression '*** '.uname('sysname').' '.uname('release').' ***'
-    width 20
-    align 'C'
+    width 16
+    align 'M'
+    speed 100  
     update tick
 }
 
@@ -111,9 +119,23 @@ Layout Default {
     }
 }
 
+Layout L16x2 {
+    Row1 {
+       Col1  'Busy'
+       Col11 'BusyBar'
+    }
+    Row2 {
+       Col1 'Load'
+       Col11 'LoadBar'
+    }
+}
+
+#Display 'LK204'
+#Display 'HD44780-20x4'
+Display 'CF632'
 
-Display 'myHD44780'
-Layout  'Default'
+#Layout  'Default'
+Layout  'L16x2'
 
 Variables {
    tick 500
index aa30eecf45fdfa3640dde37af74ae3da4af17f84..f20105c25800411afaf3261d72c0240a50a9dc1c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: widget_text.c,v 1.7 2004/01/20 04:51:39 reinelt Exp $
+/* $Id: widget_text.c,v 1.8 2004/01/22 07:57:45 reinelt Exp $
  *
  * simple text widget handling
  *
  *
  *
  * $Log: widget_text.c,v $
+ * Revision 1.8  2004/01/22 07:57:45  reinelt
+ * several bugs fixed where segfaulting on layout>display
+ * Crystalfontz driver optimized, 632 display already works
+ *
  * Revision 1.7  2004/01/20 04:51:39  reinelt
  * moved generic stuff from drv_MatrixOrbital to drv_generic
  * implemented new-stylish bars which are nearly finished
@@ -178,7 +182,7 @@ void widget_text_update (void *Self)
   int update;
   
   // evaluate prefix
-  if (T->prefix!=NULL && strlen(T->prefix)>0) {
+  if (T->prefix!=NULL && *(T->prefix)!='\0') {
     Eval(T->prefix, &result);
     preval=strdup(R2S(&result));
     DelResult (&result);