From 5a05b3642ff261a09dc5d969e06c7fcad52eb193 Mon Sep 17 00:00:00 2001 From: reinelt Date: Tue, 20 Jan 2004 12:45:47 +0000 Subject: [lcd4linux @ 2004-01-20 12:45:47 by reinelt] "Default screen" working with MatrixOrbital git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@323 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- drv_MatrixOrbital.c | 15 +++++---------- drv_generic_text.c | 22 +++++++++++----------- lcd4linux.conf.sample | 13 ++++++++++++- plugin_proc_stat.c | 12 +++++++++--- widget_bar.c | 20 +++++++++++++------- 5 files changed, 50 insertions(+), 32 deletions(-) diff --git a/drv_MatrixOrbital.c b/drv_MatrixOrbital.c index a937ce6..706dda9 100644 --- a/drv_MatrixOrbital.c +++ b/drv_MatrixOrbital.c @@ -1,4 +1,4 @@ -/* $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 * @@ -23,6 +23,9 @@ * * * $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 @@ -175,7 +178,6 @@ static void drv_MO_goto (int row, int col) } -// start display static int drv_MO_start (char *section) { int i; @@ -273,13 +275,6 @@ static int drv_MO_start (char *section) 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 @@ -492,7 +487,7 @@ int drv_MO_init (char *section) // 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; diff --git a/drv_generic_text.c b/drv_generic_text.c index d9353fd..2de0c29 100644 --- a/drv_generic_text.c +++ b/drv_generic_text.c @@ -1,4 +1,4 @@ -/* $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 * @@ -23,6 +23,9 @@ * * * $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 @@ -88,8 +91,6 @@ static int nSegment=0; static int fSegment=0; static SEGMENT Segment[128]; -// Fixme: get rid of me! -static int RES; // **************************************** @@ -281,8 +282,8 @@ static void drv_generic_text_bar_create_segments (void) res=Bar[n].dir & (DIR_EAST|DIR_WEST) ? XRES:YRES; for (i=0; iRES) 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; } } @@ -448,7 +449,7 @@ int drv_generic_text_draw_bar (WIDGET *W, int goto_len, 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; @@ -459,14 +460,14 @@ 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==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); @@ -522,7 +523,6 @@ int drv_generic_text_draw_bar (WIDGET *W, int goto_len, } 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); } } diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 67afb9c..029e94c 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -48,7 +48,8 @@ Widget Busy { Widget BusyBar { class 'Bar' - expression cpu('busy', 500) + expression cpu('busy', 500) + expression2 cpu('system', 500) length 10 direction 'E' update tack @@ -65,6 +66,15 @@ Widget Load { update tick } +Widget LoadBar { + class 'Bar' + expression loadavg(1) + max 2.0 + length 10 + direction 'E' + update tack +} + Layout Default { Row1 { @@ -80,6 +90,7 @@ Layout Default { } Row4 { Col1 'Load' + Col11 'LoadBar' } } diff --git a/plugin_proc_stat.c b/plugin_proc_stat.c index 3857995..52c0ad6 100644 --- a/plugin_proc_stat.c +++ b/plugin_proc_stat.c @@ -1,4 +1,4 @@ -/* $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 * @@ -23,6 +23,9 @@ * * * $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 * @@ -248,8 +251,11 @@ static void my_cpu (RESULT *result, RESULT *arg1, RESULT *arg2) 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); } diff --git a/widget_bar.c b/widget_bar.c index f28c95c..65cb748 100644 --- a/widget_bar.c +++ b/widget_bar.c @@ -1,4 +1,4 @@ -/* $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 * @@ -21,6 +21,9 @@ * * * $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 @@ -62,14 +65,14 @@ void widget_bar_update (void *Self) 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); @@ -98,7 +101,6 @@ void widget_bar_update (void *Self) if (val2 > max) max = val2; } - // calculate bar values T->min=min; T->max=max; @@ -136,6 +138,12 @@ int widget_bar_init (WIDGET *Self) 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); @@ -159,7 +167,7 @@ int widget_bar_init (WIDGET *Self) 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); @@ -173,8 +181,6 @@ int widget_bar_init (WIDGET *Self) free (section); Self->data=B; - debug ("Michi: widget_bar added..."); - timer_add (widget_bar_update, Self, B->update, 0); return 0; -- cgit v1.2.3