Example #1
0
    def __read_image(cls, addr, count):
        try:
            I2C.start_tx(Host.DFE_EEPROM_ADDR)

            content = I2C.read_cmd16(addr, count)

            return EEPROMImage(content)
        finally:
            I2C.end_tx()
Example #2
0
    def status(self):
        try:
            I2C.start_tx(self.__addr)
            status_msb, status_lsb, _ = I2C.read_cmd16(SHT31.__CMD_READ_STATUS, 3)

            return (status_msb << 8) | status_lsb

        finally:
            I2C.end_tx()
Example #3
0
    def sample(self):
        try:
            I2C.start_tx(self.__addr)
            temp_msb, temp_lsb, _, humid_msb, humid_lsb, _ = I2C.read_cmd16(
                SHT31.__CMD_READ_SINGLE_HIGH, 6)

            raw_humid = (humid_msb << 8) | humid_lsb
            raw_temp = (temp_msb << 8) | temp_lsb

            return SHTDatum(SHT31.humid(raw_humid), SHT31.temp(raw_temp))

        finally:
            I2C.end_tx()
Example #4
0
    def sample(self):
        if self.__addr == 0:
            return None

        try:
            I2C.start_tx(self.__addr)
            temp_msb, temp_lsb, _, humid_msb, humid_lsb, _ = I2C.read_cmd16(SHT31.__CMD_READ_SINGLE_HIGH, 6,
                                                                            wait=self.MEASUREMENT_DURATION)

            raw_humid = (humid_msb << 8) | humid_lsb
            raw_temp = (temp_msb << 8) | temp_lsb

            return SHTDatum(SHT31.humid(raw_humid), SHT31.temp(raw_temp))

        finally:
            I2C.end_tx()
    def __read(self, command, wait, count=0):
        try:
            self.obtain_lock()

            try:
                I2C.start_tx(self.__i2c_addr)

                encoded = I2C.read_cmd16(command, count)
                values = self.__decode(encoded)

            finally:
                I2C.end_tx()

            time.sleep(wait)
            return values

        finally:
            self.release_lock()