예제 #1
0
    def read(self):
        try:
            I2C.start_tx(self.__addr)
            byte = I2C.read(1)

        finally:
            I2C.end_tx()

        return byte
예제 #2
0
    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