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)
def __getCelsius__(self): d = self.readBytes(2) count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF return signInteger(count, 12) * 0.0625
def readSignedInteger(self, address): d = self.readUnsignedInteger(address) return signInteger(d, 16)
def __getCelsius__(self): d = self.readBytes(2) count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF return signInteger(count, 12)*0.0625
def __getCelsius__(self): d = self.readRegisters(0x05, 2) count = ((d[0] << 8) | d[1]) & 0x1FFF return signInteger(count, 13) * 0.0625
def readSigned(self, address, numBytes, byteOrder='little'): d = self.readUnsigned(address, numBytes, byteOrder) return signInteger(d, numBytes * 8)