diff web/log.py @ 75:ca08442635ca

report raw ds18b20 values instead
author Matt Johnston <matt@ucc.asn.au>
date Tue, 03 Jul 2012 22:44:21 +0800
parents 0a8639039453
children 959e88c0bdfa
line wrap: on
line diff
--- a/web/log.py	Tue Jul 03 21:55:50 2012 +0800
+++ b/web/log.py	Tue Jul 03 22:44:21 2012 +0800
@@ -11,6 +11,7 @@
 import sqlite3
 import traceback
 import datetime
+import struct
 from colorsys import hls_to_rgb
 
 import config
@@ -143,6 +144,10 @@
     f.flush()
     return f
 
+def convert_ds18b20_12bit(reading):
+    value = struct.unpack('>h', binascii.unhexlify(reading))[0]
+    return value * 0.0625
+
 def parse(lines):
    
     debugf = record_debug(lines)
@@ -160,10 +165,6 @@
     for s in sensors:
         meas.append([])
 
-    def val_scale(v):
-        # convert decidegrees to degrees
-        return 0.1 * v
-
     for n in xrange(num_measurements):
         vals = [val_scale(int(x)) for x in entries["meas%d" % n].strip().split()]
         if len(vals) != num_sensors: