aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cfg.c8
-rw-r--r--drv_Crystalfontz.c19
-rw-r--r--drv_HD44780.c13
-rw-r--r--drv_MatrixOrbital.c13
-rw-r--r--drv_generic_text.c89
-rw-r--r--drv_generic_text.h8
-rw-r--r--hash.c9
-rw-r--r--lcd4linux.conf.sample32
-rw-r--r--widget_text.c8
9 files changed, 141 insertions, 58 deletions
diff --git a/cfg.c b/cfg.c
index 6fbef65..1a565e4 100644
--- 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
*
@@ -23,6 +23,10 @@
*
*
* $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;
diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c
index 5c3bf1b..bff3ccd 100644
--- a/drv_Crystalfontz.c
+++ b/drv_Crystalfontz.c
@@ -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
*
@@ -23,6 +23,10 @@
*
*
* $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;
diff --git a/drv_HD44780.c b/drv_HD44780.c
index 8432057..3201a55 100644
--- a/drv_HD44780.c
+++ b/drv_HD44780.c
@@ -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
*
@@ -29,6 +29,10 @@
*
*
* $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)
diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c
index 3a20bfb..d7adab1 100644
--- a/drv_MatrixOrbital.c
+++ b/drv_MatrixOrbital.c
@@ -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
*
@@ -23,6 +23,10 @@
*
*
* $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)
diff --git a/drv_generic_text.c b/drv_generic_text.c
index 0ba2f10..87e22ae 100644
--- a/drv_generic_text.c
+++ b/drv_generic_text.c
@@ -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
*
@@ -23,6 +23,10 @@
*
*
* $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;
}
diff --git a/drv_generic_text.h b/drv_generic_text.h
index f742427..e1468f5 100644
--- a/drv_generic_text.h
+++ b/drv_generic_text.h
@@ -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
*
@@ -23,6 +23,10 @@
*
*
* $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 3d7a6e3..20e574d 100644
--- 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)
*
@@ -23,6 +23,10 @@
*
*
* $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);
}
}
diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample
index 5e08557..d228c3e 100644
--- a/lcd4linux.conf.sample
+++ b/lcd4linux.conf.sample
@@ -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
diff --git a/widget_text.c b/widget_text.c
index aa30eec..f20105c 100644
--- a/widget_text.c
+++ b/widget_text.c
@@ -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
*
@@ -21,6 +21,10 @@
*
*
* $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);