def read(self): try: I2C.start_tx(self.__addr) byte = I2C.read(1) finally: I2C.end_tx() return byte
def __read(self): # get data... msb, lsb, config = I2C.read(3) unsigned = (msb << 8) | lsb # render voltage... signed = struct.unpack('h', struct.pack('H', unsigned)) v = (signed[0] / 32767.5) * 2.048 / MCP342X.__GAIN[self.__gain] return v, config