]> git.webhop.me Git - lcd4linux.git/commitdiff
[lcd4linux @ 2002-12-05 19:12:47 by reinelt]
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 5 Dec 2002 19:12:47 +0000 (19:12 +0000)
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Thu, 5 Dec 2002 19:12:47 +0000 (19:12 +0000)
sensors factor and offset patch from Petri Damsten <petri.damsten@raketti.net>

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

system.c

index d62f87191c0888c0620d3960a56f3ef8f39cf0fb..a7fc9471476e3e619b0b7bd75ababbc7a739d6e8 100644 (file)
--- a/system.c
+++ b/system.c
@@ -1,4 +1,4 @@
-/* $Id: system.c,v 1.24 2001/08/05 17:13:29 reinelt Exp $
+/* $Id: system.c,v 1.25 2002/12/05 19:12:47 reinelt Exp $
  *
  * system status retreivement
  *
@@ -20,6 +20,9 @@
  *
  *
  * $Log: system.c,v $
+ * Revision 1.25  2002/12/05 19:12:47  reinelt
+ * sensors factor and offset patch from Petri Damsten <petri.damsten@raketti.net>
+ *
  * Revision 1.24  2001/08/05 17:13:29  reinelt
  *
  * cleaned up inlude of sys/time.h and time.h
@@ -743,6 +746,8 @@ int Sensor (int index, double *val, double *min, double *max)
   static double val_buf[SENSORS+1]={0.0,};
   static double min_buf[SENSORS+1]={0.0,};
   static double max_buf[SENSORS+1]={0.0,};
+  static double factor_buf[SENSORS+1]={0.0,};
+  static double offset_buf[SENSORS+1]={0.0,};
   static time_t now[SENSORS+1]={0,};
 
   if (index<0 || index>SENSORS) return -1;
@@ -772,7 +777,13 @@ int Sensor (int index, double *val, double *min, double *max)
     snprintf(buffer, 32, "Sensor%d_max", index);
     max_buf[index]=atof(cfg_get(buffer)?:"100");
     *max=max_buf[index];
-    
+
+    snprintf(buffer, 32, "Sensor%d_factor", index);
+    factor_buf[index]=atof(cfg_get(buffer)?:"1");
+
+    snprintf(buffer, 32, "Sensor%d_offset", index);
+    offset_buf[index]=atof(cfg_get(buffer)?:"0");
+
     fd[index]=open(sensor[index], O_RDONLY);
     if (fd[index]==-1) {
       error ("open(%s) failed: %s", sensor[index], strerror(errno));
@@ -798,7 +809,8 @@ int Sensor (int index, double *val, double *min, double *max)
     fd[index]=-1;
     return -1;
   }
-
+  value *= factor_buf[index];
+  value += offset_buf[index];
   val_buf[index]=value;
   *val=value;
   return 0;