Project

General

Profile

« Previous | Next » 

Revision 74eab0f1

Added by dsorber over 13 years ago

Did a bit more work. The remote temperature readings are way off, I need to figure out why.

View differences:

525.743/code/test scripts/tmp512.py
def device_id(self):
return '0x%04X' % self.read_reg(0x1F)
def _convert_temp(self, raw_val):
temp = (raw_val >> 3) * 0.0625
# Convert C to F
return (temp * 1.8) + 32
def local_temp(self):
return self.read_reg(0x08)
return self._convert_temp(self.read_reg(0x08))
def temp_sensor1(self):
return self._convert_temp(self.read_reg(0x09))
def temp_sensor2(self):
return self._convert_temp(self.read_reg(0x0A))
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)
print temp1.device_id()
print '0x%04X' % temp1.local_temp()
print 'The local temp1 is %d' % temp1.local_temp()
print 'The local temp2 is %d' % temp2.local_temp()
print 'The remote1 temp1 is %d' % temp1.temp_sensor1()
print 'The remote2 temp1 is %d' % temp1.temp_sensor2()
# bus = smbus.SMBus(1)
# address = 0x5c

Also available in: Unified diff