]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2001-03-16 16:40:17 by ltoetsch]
authorltoetsch <ltoetsch@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 16 Mar 2001 16:40:17 +0000 (16:40 +0000)
committerltoetsch <ltoetsch@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 16 Mar 2001 16:40:17 +0000 (16:40 +0000)
implemented time bar

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

12 files changed:
NEWS
PalmPilot.c
README
Raster.c
TODO
Text.c
XWindow.c
display.c
display.h
parser.c
pixmap.c
processor.c

diff --git a/NEWS b/NEWS
index 8cf0b70ecc6983d23b4f9072fdf489f37f43f0cb..a617d404e8d2bd452be5249c697a439e3d9f3462 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -49,3 +49,5 @@ lcd4linux-0.98
 - added another verbose level (-vvv) for debugging socket traffic
 
 - added nntp support for count of news/unread messages in subscribed NGs
+
+- implemented time series bar '$t'
index 44d7b864d9be2322eb39ab7eda9f8b570468beda..139d99c406e0127566935b21310d583c9bb372bd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: PalmPilot.c,v 1.4 2001/02/13 09:00:13 reinelt Exp $
+/* $Id: PalmPilot.c,v 1.5 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * driver for 3Com Palm Pilot
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: PalmPilot.c,v $
+ * Revision 1.5  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.4  2001/02/13 09:00:13  reinelt
  *
  * prepared framework for GPO's (general purpose outputs)
@@ -66,7 +69,7 @@
 #include "display.h"
 #include "pixmap.h"
 
-#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 )
+#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T)
 
 static LCD Lcd;
 static char *Port=NULL;
diff --git a/README b/README
index 2970b8645bce9023d4bdc0812a41c3f38d79a752..7bae392febd162539a9a52f079081a9cf29302c3 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 #
-# $Id: README,v 1.19 2001/03/15 14:25:05 ltoetsch Exp $
+# $Id: README,v 1.20 2001/03/16 16:40:17 ltoetsch Exp $
 #
 
 This is the README file for lcd4linux
@@ -207,6 +207,11 @@ Display options:
   (down). If you specify the direction in upper case, a logarithmic bar will
   be created. note that the space occupied by a bar always grows from left
   to right or from top to bottom, regardless of the direction!
+  
+  '$t<height><token>,<width> will create a time series bar. The data are 
+  displayed like '$u', but are shifted every second 1 pixel to the 
+  left. Currently only displays based on the pixel-driver support this 
+  bar type.
 
 Tokens:
 
index eabc3ece50dafe05f433d7e71b16425cc46fbb8b..4aad9d58ee1312da69a429b1323c7265d79d841e 100644 (file)
--- a/Raster.c
+++ b/Raster.c
@@ -1,4 +1,4 @@
-/* $Id: Raster.c,v 1.17 2001/03/12 12:39:36 reinelt Exp $
+/* $Id: Raster.c,v 1.18 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * driver for raster formats
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: Raster.c,v $
+ * Revision 1.18  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.17  2001/03/12 12:39:36  reinelt
  *
  * reworked autoconf a lot: drivers may be excluded, #define's went to config.h
 #include "display.h"
 #include "pixmap.h"
 
-#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 )
+#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T )
 
 static LCD Lcd;
 
diff --git a/TODO b/TODO
index e3528cdcd38c90d7d87a94158bef628411540532..3985ecd20a4b293b2e074b84ae09238b1c9247b1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,9 @@
 ToDo-List / Wishlist for lcd4linux
 
-2000-04-04 Michael Reinelt <reinelt@eunet.at>
-implement some sort of 'graphs', similar to bars, but with a time axis
-can be filled (made up of bars) or not (needs raster graphics)
+// 2000-04-04 Michael Reinelt <reinelt@eunet.at>
+// implement some sort of 'graphs', similar to bars, but with a time axis
+// can be filled (made up of bars) or not (needs raster graphics)
+// done 2001-03-16 -lt.
 
 // 2000-04-04 Michael Reinelt <reinelt@eunet.at>
 // write a driver for PNG. This should be the first step towards a WWW-driver.
diff --git a/Text.c b/Text.c
index 14689474a93707a5bfcd1ec240df94d617ca1daa..983af51e663ef9d8013dad8985e1bfc613b8c7ae 100644 (file)
--- a/Text.c
+++ b/Text.c
@@ -1,4 +1,4 @@
-/* $Id: Text.c,v 1.3 2001/03/16 09:28:08 ltoetsch Exp $
+/* $Id: Text.c,v 1.4 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * pure ncurses based text driver
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: Text.c,v $
+ * Revision 1.4  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.3  2001/03/16 09:28:08  ltoetsch
  * bugfixes
  *
@@ -77,7 +80,7 @@ extern int foreground;
 static LCD Lcd;
 static WINDOW *w;
 WINDOW *err_win;
-#define BARS ( BAR_R | BAR_H2 )
+#define BARS ( BAR_R | BAR_H2 | BAR_T )
 int err_rows;
 
 int Text_clear (void)
index 46b38f6b62c2876af24064cf15b0f8be871d1a3f..d288587a8e48db9a1aa848178eece4fddbd4e63b 100644 (file)
--- a/XWindow.c
+++ b/XWindow.c
@@ -1,4 +1,4 @@
-/* $Id: XWindow.c,v 1.24 2001/03/01 11:08:16 reinelt Exp $
+/* $Id: XWindow.c,v 1.25 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * X11 Driver for LCD4Linux 
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: XWindow.c,v $
+ * Revision 1.25  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.24  2001/03/01 11:08:16  reinelt
  *
  * reworked configure to allow selection of drivers
@@ -148,7 +151,7 @@ union semun {
 };
 #endif
 
-#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 )
+#define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 | BAR_T)
 
 static LCD Lcd;
 static Display *dp;
index 1e56e99b80404da3bdf9e29d88a34d3e0dbf349e..229da600adc4c0bf3cfb9610f9df58c9d709faca 100644 (file)
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.27 2001/03/15 14:25:05 ltoetsch Exp $
+/* $Id: display.c,v 1.28 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * framework for device drivers
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: display.c,v $
+ * Revision 1.28  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.27  2001/03/15 14:25:05  ltoetsch
  * added unread/total news
  *
@@ -291,10 +294,11 @@ int lcd_bar (int type, int row, int col, int max, int len1, int len2)
 {
   if (row<1 || row>Lcd->rows) return -1;
   if (col<1 || col>Lcd->cols) return -1;
-  if (!(type & (BAR_H2 | BAR_V2))) len2=len1;
+  if (!(type & (BAR_H2 | BAR_V2 | BAR_T))) len2=len1;
   if (type & BAR_LOG) {
     len1=(double)max*log(len1+1)/log(max); 
-    len2=(double)max*log(len2+1)/log(max); 
+    if (!(type & BAR_T))
+      len2=(double)max*log(len2+1)/log(max); 
   }
   if (Lcd->put==NULL) return 0;
   return Lcd->bar (type & BAR_HV, row-1, col-1, max, len1, len2);
index bf9915fcd4c451089a3dacb93bea52c37669e4db..3afc736736da23cc92308370bd0e588026fccf78 100644 (file)
--- a/display.h
+++ b/display.h
@@ -1,4 +1,4 @@
-/* $Id: display.h,v 1.13 2001/02/14 07:40:16 reinelt Exp $
+/* $Id: display.h,v 1.14 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * framework for device drivers
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: display.h,v $
+ * Revision 1.14  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.13  2001/02/14 07:40:16  reinelt
  *
  * first (incomplete) GPO implementation
 #define BAR_H2  (1<<4)
 #define BAR_V2  (1<<5)
 #define BAR_LOG (1<<6)
+#define BAR_T   (1<<7)
 
 #define BAR_H (BAR_L | BAR_R)
-#define BAR_V (BAR_U | BAR_D)
+#define BAR_V (BAR_U | BAR_D | BAR_T)
 #define BAR_HV (BAR_H | BAR_V)
 
 typedef struct LCD {
index 2e2f9a11c7c5c35ddddb07dc178ed65f52256616..246a6398e3eb7d72b19c336a5843883597322036 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1,4 +1,4 @@
-/* $Id: parser.c,v 1.15 2001/03/14 13:19:29 ltoetsch Exp $
+/* $Id: parser.c,v 1.16 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * row definition parser
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: parser.c,v $
+ * Revision 1.16  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.15  2001/03/14 13:19:29  ltoetsch
  * Added pop3/imap4 mail support
  *
@@ -181,6 +184,8 @@ static int bar_type (char tag)
     return BAR_U;
   case 'd':
     return BAR_D;
+  case 't':
+    return BAR_T;
   default:
     return 0;
   }
@@ -272,6 +277,8 @@ char *parse_row (char *string, int supported_bars, int usage[])
          break;
        }
       }
+      else if (*s == ',' && (type & BAR_T))
+        token2=strtol(++s, &s, 10); /* get horizontal length */
       *p++='$';
       *p++=type;
       *p++=len;
@@ -279,7 +286,7 @@ char *parse_row (char *string, int supported_bars, int usage[])
       if (token>256) *p++=token>>8;
       if (token2!=-1) {
        *p++=token2&255;
-       if (token>256) *p++=token2>>8;
+       if (token>256 && !(type & BAR_T)) *p++=token2>>8;
       }
       break;
       
index c266a65c3b1f5fb46d19842137498dfbaabba2fb..b63fcd7ed36cbc1f2c750e6ee253aad806a2c0ad 100644 (file)
--- a/pixmap.c
+++ b/pixmap.c
@@ -1,4 +1,4 @@
-/* $Id: pixmap.c,v 1.5 2000/03/26 18:46:28 reinelt Exp $
+/* $Id: pixmap.c,v 1.6 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * generic pixmap driver
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: pixmap.c,v $
+ * Revision 1.6  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.5  2000/03/26 18:46:28  reinelt
  *
  * bug in pixmap.c that leaded to empty bars fixed
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <time.h>
 
 #include "display.h"
 #include "pixmap.h"
 #include "fontmap.h"
+#include "debug.h"
 
 static int ROWS=0;
 static int COLS=0;
@@ -136,6 +141,10 @@ 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 x, y, len, rev;
+  static int *valbuf = NULL;
+  static int init = 0;
+  static time_t old;
+  time_t now;
   
   row*=YRES;
   col*=XRES;
@@ -150,9 +159,24 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2)
   
   if (len1<1) len1=1;
   else if (len1>max) len1=max;
-  
-  if (len2<1) len2=1;
-  else if (len2>max) len2=max;
+
+  if (type == BAR_T) {
+    if (init == 0 && valbuf == 0) {
+      valbuf = calloc(len2, sizeof(int));
+      if (valbuf == NULL) {
+       error("Couldn't allocte valbuf");
+       init = -1;
+        return -1;
+      }
+      init = 1;
+      debug("valbuf ok, len2=%d", len2);
+      time(&old);
+    }
+  }
+  else {
+    if (len2<1) len2=1;
+    else if (len2>max) len2=max;
+  }
   
   rev=0;
   
@@ -185,6 +209,28 @@ int pix_bar (int type, int row, int col, int max, int len1, int len2)
     }
     break;
 
+  case BAR_T:
+    len1=max-len1;
+    rev=1;
+    time(&now);
+    if (now == old) {
+      valbuf[len2-1] += len1;
+      valbuf[len2-1] /= 2;
+    }
+    else {  
+      for (; old < now; old++)
+        for (x=1; x<len2; x++)
+          valbuf[x-1]=valbuf[x];
+      valbuf[len2-1] = len1;
+    }
+    for (x=0; x<len2; x++) {
+      len = valbuf[x];
+      for (y=0; y<max; y++) {
+       LCDpixmap[(row+y)*COLS+col+x]=y<len?!rev:rev;
+      }
+    }
+    break;
+
   }
   return 0;
 }
index 76ff683336928231a7be4ab496d426d2602af324..75eb1924b9beba64ef74d930cd35f1ce28a2ed00 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.23 2001/03/16 09:28:08 ltoetsch Exp $
+/* $Id: processor.c,v 1.24 2001/03/16 16:40:17 ltoetsch Exp $
  *
  * main data processing
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: processor.c,v $
+ * Revision 1.24  2001/03/16 16:40:17  ltoetsch
+ * implemented time bar
+ *
  * Revision 1.23  2001/03/16 09:28:08  ltoetsch
  * bugfixes
  *
@@ -585,8 +588,12 @@ static char *process_row (int r)
        if (token>T_EXTENDED) token += (*(unsigned char*)++s)<<8;
        val2=query_bar(token);
       }
+      else if (type & BAR_T)
+       val2 = *(unsigned char*)++s; /* width */
       if (type & BAR_H)
        lcd_bar (type, r, p-buffer+1, len*xres, val1*len*xres, val2*len*xres);
+      else if (type & BAR_T)
+       lcd_bar (type, r, p-buffer+1, len*xres, val1*len*yres, val2*xres);
       else
        lcd_bar (type, r, p-buffer+1, len*yres, val1*len*yres, val2*len*yres);