]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2004-01-20 12:45:47 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 20 Jan 2004 12:45:47 +0000 (12:45 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Tue, 20 Jan 2004 12:45:47 +0000 (12:45 +0000)
"Default screen" working with MatrixOrbital

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

drv_MatrixOrbital.c
drv_generic_text.c
lcd4linux.conf.sample
plugin_proc_stat.c
widget_bar.c

index a937ce6cc70cf5ca6f3a611e067633955c75c0a1..706dda969f3e0b44560466e12e16c61b681a0905 100644 (file)
@@ -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;
index d9353fdd962c965692967e4be933c1b5c3ce7fbe..2de0c299e6e2123828096f196bd00bda944d5a26 100644 (file)
@@ -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; 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;
       }
     }
@@ -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);
     }
   }
   
index 67afb9ceea38f75dcba35fb2c4ccae2685529d19..029e94caa5e86bbb18a05bbcfdc2b842432f227a 100644 (file)
@@ -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'
     }
 }
 
index 385799526011106d1dae7067037a50d0ef053daf..52c0ad6d9d7c411b2a2bd881447a20bc5cbd2b5a 100644 (file)
@@ -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); 
 }
 
index f28c95cdfc1f908e8dc687ff976e3e1521ee8790..65cb7480684965c4a79756dae1126add5a366fc4 100644 (file)
@@ -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;