Ejemplo n.º 1
0
    def __read_reg(cls, addr):
        try:
            I2C.start_tx(cls.__ADDR)
            value = I2C.read_cmd(addr, 1)
        finally:
            I2C.end_tx()

        return value
Ejemplo n.º 2
0
    def __read_image(cls, memory_addr, count):
        try:
            I2C.start_tx(Host.DFE_EEPROM_ADDR)

            content = I2C.read_cmd(memory_addr, count)

            return EEPROMImage(content)
        finally:
            I2C.end_tx()
    def __read_raw(self):
        try:
            I2C.start_tx(self.__I2C_ADDR)
            values = I2C.read_cmd(self.__reg_addr, 2)

            return values[0] << 8 | values[1]

        finally:
            I2C.end_tx()
Ejemplo n.º 4
0
    def __read_config(self):
        try:
            I2C.start_tx(self.__addr)
            msb, lsb = I2C.read_cmd(ADS1115.__REG_CONFIG, 2)

        finally:
            I2C.end_tx()

        config = (msb << 8) | lsb
        return config
Ejemplo n.º 5
0
    def __read_temp(cls):
        try:
            I2C.start_tx(cls.__ADDR)
            msb, lsb = I2C.read_cmd(cls.__REG_TEMP, 2)
        finally:
            I2C.end_tx()

        # render voltage...
        unsigned_c = float(msb & 0x1f) * 16 + float(lsb) / 16
        sign = msb & 0x10

        temp = 256 - unsigned_c if sign else unsigned_c

        return temp
Ejemplo n.º 6
0
    def __read_array(cls, device_addr, memory_addr, count):
        try:
            I2C.start_tx(Host.DFE_UID_ADDR)

            # I2C.read(1)
        finally:
            I2C.end_tx()

        try:
            I2C.start_tx(Host.DFE_UID_ADDR)

            # I2C.write(0x80)

            return I2C.read_cmd(0x80, count)  # memory_addr,
        finally:
            I2C.end_tx()
Ejemplo n.º 7
0
    def __read_conv(self):
        try:
            I2C.start_tx(self.__addr)
            msb, lsb = I2C.read_cmd(ADS1115.__REG_CONV, 2)

        finally:
            I2C.end_tx()

        # render voltage...
        unsigned = (msb << 8) | lsb

        # print("unsigned: 0x%04x" % unsigned)

        signed = struct.unpack('h', struct.pack('H', unsigned))

        v = (signed[0] / 32767.5) * ADS1115.__FULL_SCALE[self.__gain]

        return v