aboutsummaryrefslogtreecommitdiffstats
path: root/pixmap.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pixmap.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/pixmap.c b/pixmap.c
index c266a65..b63fcd7 100644
--- 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
@@ -67,10 +70,12 @@
#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;
}
ghlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* $Id: system.h,v 1.5 2000/03/17 09:21:42 reinelt Exp $
 *
 * system status retreivement
 *
 * 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: system.h,v $
 * Revision 1.5  2000/03/17 09:21:42  reinelt
 *
 * various memory statistics added
 *
 * Revision 1.4  2000/03/10 17:36:02  reinelt
 *
 * first unstable but running release
 *
 * Revision 1.3  2000/03/07 11:01:34  reinelt
 *
 * system.c cleanup
 *
 * Revision 1.2  2000/03/06 06:04:06  reinelt
 *
 * minor cleanups
 *
 */

#ifndef _SYSTEM_H_
#define _SYSTEM_H_

#define SENSORS 9

char *System (void);
char *Release (void);
char *Processor (void);
int   Memory (void);
int   Ram (int *total, int *free, int *shared, int *buffered, int *cached);
int   Load (double *load1, double *load2, double *load3);
int   Busy (double *user, double *nice, double *system, double *idle);
int   Disk (int *r, int *w);
int   Net (int *rx, int *tx);
int   Sensor (int index, double *val, double *min, double *max);

#endif