예제 #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)
예제 #2
0
 def __getCelsius__(self):
     d = self.readBytes(2)
     count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF
     return signInteger(count, 12) * 0.0625
예제 #3
0
 def readSignedInteger(self, address):
     d = self.readUnsignedInteger(address)
     return signInteger(d, 16)
예제 #4
0
 def readSignedInteger(self, address):
     d = self.readUnsignedInteger(address)
     return signInteger(d, 16)
예제 #5
0
파일: tmpXXX.py 프로젝트: Hunter275/webiopi
 def __getCelsius__(self):
     d = self.readBytes(2)
     count = ((d[0] << 4) | (d[1] >> 4)) & 0xFFF
     return signInteger(count, 12)*0.0625
예제 #6
0
 def __getCelsius__(self):
     d = self.readRegisters(0x05, 2)
     count = ((d[0] << 8) | d[1]) & 0x1FFF
     return signInteger(count, 13) * 0.0625
예제 #7
0
 def readSigned(self, address, numBytes, byteOrder='little'):
     d = self.readUnsigned(address, numBytes, byteOrder)
     return signInteger(d, numBytes * 8)