commit 018481aa0af02bf2d5523b556ad0966b8bb4abc8
Author: dsorber <david.sorber@gmail.com>
Date:   Thu Apr 18 18:00:18 2013 -0400

    Adding my improvements to the TMP512 controller code that I've developed over the past couple days.

diff --git a/525.743/code/test scripts/tmp512.py b/525.743/code/test scripts/tmp512.py
index 8475c1a..fa8e3ea 100644
--- a/525.743/code/test scripts/tmp512.py	
+++ b/525.743/code/test scripts/tmp512.py	
@@ -9,6 +9,15 @@ class TMP512(object):
         self.bus = smbus.SMBus(1)
         self.address = address
 
+        # Shunt Measurement Configuration 
+        #   - turn off shunt/bus voltage measurement
+        self.write_reg(0x00, 0x3998)
+
+        # Temperature Measurement Configuration
+        #   - continous conversion at 1 conversion/second
+        #   - enable remote 1, remote 2 and local
+        self.write_reg(0x01, 0xBE00)
+
     def _reverse16(self, value):
         """ A quick hack method for reversing byte order for a 16 bit value """
         str_val = '%04X' % value
@@ -19,10 +28,22 @@ class TMP512(object):
         raw = self.bus.read_word_data(self.address, reg)
         return self._reverse16(raw)
 
+    def write_reg(self, reg, data):
+        raw = self._reverse16(data)
+        self.bus.write_word_data(self.address, reg, raw)
+
+    def reset(self):
+        self.write_reg(0x00, 0xB998)
+        time.sleep(1)
+
+    def status(self):
+        return self.read_reg(0x02)
+
     def device_id(self):
         return '0x%04X' % self.read_reg(0x1F)
 
     def _convert_temp(self, raw_val):
+        # Raw temp is a 13 bit number, the units are 0.0625 C
         temp = (raw_val >> 3) * 0.0625
         # Convert C to F
         return (temp * 1.8) + 32
@@ -38,15 +59,26 @@ class TMP512(object):
 
 
 def main():
-
-    temp1 = TMP512(0x5c)
-    temp2 = TMP512(0x5d)
-    print '0x%04X' % temp1.read_reg(0x01)
-    print '0x%04X' % temp1.read_reg(0x09)
-    print '0x%04X' % temp1.read_reg(0x00)
+    import time
+
+    temp1 = TMP512(0x5d)
+    # temp1 = TMP512(0x5d)
+    # temp1.write_reg(0x00, 0x8000)
+    # time.sleep(1)
+    # temp1.reset()
+    print 'Status: 0x%04X' % temp1.status()
     print temp1.device_id()
     print 'The local temp1 is %d' % temp1.local_temp()
-    print 'The local temp2 is %d' % temp2.local_temp()
+
+    print 'Remote 1 temp limit: 0x%04X' % temp1.read_reg(0x12)
+    print 'Remote 1 nfactor: 0x%04X' % temp1.read_reg(0x16)
+
+    print 'The remote1 temp1 is 0x%04X' % temp1.temp_sensor1()
+    print 'The remote2 temp1 is %d' % temp1.temp_sensor2()
+    time.sleep(1)
+    print 'The remote1 temp1 is %d' % temp1.temp_sensor1()
+    print 'The remote2 temp1 is %d' % temp1.temp_sensor2()
+    time.sleep(1)
     print 'The remote1 temp1 is %d' % temp1.temp_sensor1()
     print 'The remote2 temp1 is %d' % temp1.temp_sensor2()
 
