Exemplo n.º 1
0
 def __analogRead__(self, channel, diff=False):
     config = self.readRegisters(self.CONFIG, 2)
     config[0] &= ~self.CONFIG_CHANNEL_MASK
     if diff:
         config[0] |= channel << 4
     else:
         config[0] |= (channel + 4) << 4
     self.writeRegisters(self.CONFIG, config)
     sleep(0.001)
     d = self.readRegisters(self.VALUE, 2)
     value = (d[0] << 8 | d[1]) >> (16-self._analogResolution)
     return signInteger(value, self._analogResolution)
Exemplo n.º 2
0
 def __getCelsius__(self):
     d = self.readBytes(2)
     count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF
     return signInteger(count, 12) * 0.0625
Exemplo n.º 3
0
 def readSignedInteger(self, address):
     d = self.readUnsignedInteger(address)
     return signInteger(d, 16)
Exemplo n.º 4
0
 def readSignedInteger(self, address):
     d = self.readUnsignedInteger(address)
     return signInteger(d, 16)
Exemplo n.º 5
0
 def __getCelsius__(self):
     d = self.readBytes(2)
     count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF
     return signInteger(count, 12)*0.0625
Exemplo n.º 6
0
 def __getCelsius__(self):
     d = self.readRegisters(0x05, 2)
     count = ((d[0] << 8) | d[1]) & 0x1FFF
     return signInteger(count, 13) * 0.0625
Exemplo n.º 7
0
 def readSigned(self, address, numBytes, byteOrder='little'):
     d = self.readUnsigned(address, numBytes, byteOrder)
     return signInteger(d, numBytes * 8)