-/* $Id: drv_MatrixOrbital.c,v 1.11 2004/01/20 05:36:59 reinelt Exp $
+/* $Id: drv_MatrixOrbital.c,v 1.12 2004/01/20 12:45:47 reinelt Exp $
*
* new style driver for Matrix Orbital serial display modules
*
*
*
* $Log: drv_MatrixOrbital.c,v $
+ * Revision 1.12 2004/01/20 12:45:47 reinelt
+ * "Default screen" working with MatrixOrbital
+ *
* Revision 1.11 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
}
-// start display
static int drv_MO_start (char *section)
{
int i;
GPOS = Models[Model].gpos;
PROTOCOL = Models[Model].protocol;
- // init Bars
- // Fixme
- // bar_init(DROWS, DCOLS, XRES, YRES, CHARS-ICONS);
- // bar_add_segment( 0, 0,255, 32); // ASCII 32 = blank
- // bar_add_segment(255,255,255,255); // ASCII 255 = block
-
-
if (PROTOCOL==2)
drv_generic_serial_write ("\376\130", 2); // Clear Screen
else
// 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
-
+
// register text widget
wc=Widget_Text;
wc.draw=drv_MO_draw_text;
-/* $Id: drv_generic_text.c,v 1.1 2004/01/20 05:36:59 reinelt Exp $
+/* $Id: drv_generic_text.c,v 1.2 2004/01/20 12:45:47 reinelt Exp $
*
* generic driver helper for text-based displays
*
*
*
* $Log: drv_generic_text.c,v $
+ * Revision 1.2 2004/01/20 12:45:47 reinelt
+ * "Default screen" working with MatrixOrbital
+ *
* 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
static int fSegment=0;
static SEGMENT Segment[128];
-// Fixme: get rid of me!
-static int RES;
// ****************************************
res=Bar[n].dir & (DIR_EAST|DIR_WEST) ? XRES:YRES;
for (i=0; i<nSegment; i++) {
if (Segment[i].dir & Bar[n].dir) {
- l1 = Segment[i].val1; if (l1>RES) l1=RES;
- l2 = Segment[i].val2; if (l2>RES) l2=RES;
+ l1 = Segment[i].val1; if (l1>res) l1=res;
+ l2 = Segment[i].val2; if (l2>res) l2=res;
if (l1 == Bar[n].val1 && l2 == Bar[n].val2) break;
}
}
void (*drv_write)(char *buffer, int len))
{
WIDGET_BAR *B = W->data;
- int row, col, len, max, val1, val2;
+ int row, col, len, res, max, val1, val2;
int c, n, s;
DIRECTION dir;
// maybe grow layout framebuffer
// bars *always* grow heading North or East!
- if (dir==DIR_EAST || dir==DIR_WEST) {
+ if (dir & (DIR_EAST|DIR_WEST)) {
drv_generic_text_resizeFB (row, col+len-1);
- RES = XRES;
} else {
drv_generic_text_resizeFB (row, col);
- RES = YRES;
}
- max = len * RES;
+
+ res = dir & (DIR_EAST|DIR_WEST)?XRES:YRES;
+ max = len * res;
val1 = B->val1 * (double)(max);
val2 = B->val2 * (double)(max);
}
memcpy (DisplayFB+row*DCOLS+pos1, LayoutFB+row*LCOLS+pos1, pos2-pos1+1);
drv_write (DisplayFB+row*DCOLS+pos1, pos2-pos1+1);
- debug ("Michi: bar(%d,%d) len=%d", row, pos1, pos2-pos1+1);
}
}
Widget BusyBar {
class 'Bar'
- expression cpu('busy', 500)
+ expression cpu('busy', 500)
+ expression2 cpu('system', 500)
length 10
direction 'E'
update tack
update tick
}
+Widget LoadBar {
+ class 'Bar'
+ expression loadavg(1)
+ max 2.0
+ length 10
+ direction 'E'
+ update tack
+}
+
Layout Default {
Row1 {
}
Row4 {
Col1 'Load'
+ Col11 'LoadBar'
}
}
-/* $Id: plugin_proc_stat.c,v 1.5 2004/01/18 09:01:45 reinelt Exp $
+/* $Id: plugin_proc_stat.c,v 1.6 2004/01/20 12:45:47 reinelt Exp $
*
* plugin for /proc/stat parsing
*
*
*
* $Log: plugin_proc_stat.c,v $
+ * Revision 1.6 2004/01/20 12:45:47 reinelt
+ * "Default screen" working with MatrixOrbital
+ *
* Revision 1.5 2004/01/18 09:01:45 reinelt
* /proc/stat parsing finished
*
else if (strcasecmp(key, "idle" )==0) value=cpu_idle;
else if (strcasecmp(key, "busy" )==0) value=cpu_total-cpu_idle;
- value = 100*value/cpu_total;
-
+ if (cpu_total>0.0)
+ value = 100*value/cpu_total;
+ else
+ value=0.0;
+
SetResult(&result, R_NUMBER, &value);
}
-/* $Id: widget_bar.c,v 1.2 2004/01/20 04:51:39 reinelt Exp $
+/* $Id: widget_bar.c,v 1.3 2004/01/20 12:45:47 reinelt Exp $
*
* bar widget handling
*
*
*
* $Log: widget_bar.c,v $
+ * Revision 1.3 2004/01/20 12:45:47 reinelt
+ * "Default screen" working with MatrixOrbital
+ *
* Revision 1.2 2004/01/20 04:51:39 reinelt
* moved generic stuff from drv_MatrixOrbital to drv_generic
* implemented new-stylish bars which are nearly finished
double min, max;
// evaluate expressions
- val1=0.0;
+ val1 = 0.0;
if (T->expression1!=NULL && *T->expression1!='\0') {
Eval(T->expression1, &result);
val1 = R2N(&result);
DelResult(&result);
}
- val2=0.0;
+ val2 = val1;
if (T->expression2!=NULL && *T->expression2!='\0') {
Eval(T->expression2, &result);
val2 = R2N(&result);
if (val2 > max) max = val2;
}
-
// calculate bar values
T->min=min;
T->max=max;
B->expression1 = cfg_get_raw (section, "expression", NULL);
B->expression2 = cfg_get_raw (section, "expression2", NULL);
+ // sanity check
+ if (B->expression1==NULL || *B->expression1=='\0') {
+ error ("widget %s has no expression, using '0.0'", Self->name, c);
+ B->expression1="0";
+ }
+
// minimum and maximum value
B->expr_min = cfg_get_raw (section, "min", NULL);
B->expr_max = cfg_get_raw (section, "max", NULL);
B->direction=DIR_SOUTH;
break;
default:
- error ("widget %s has unknown direction '%s', using 'East'", section, c);
+ error ("widget %s has unknown direction '%s', using 'East'", Self->name, c);
B->direction=DIR_EAST;
}
free (c);
free (section);
Self->data=B;
- debug ("Michi: widget_bar added...");
-
timer_add (widget_bar_update, Self, B->update, 0);
return 0;