'Read a value from a I2C-HAT digital input.'

def read_di(self, address, channel):

    from raspihats.i2c_hats import ResponseException
    with self._lock:
        i2c_hat = self._i2c_hats[address]
        try:
            value = i2c_hat.di.value
            return ((value >> channel) & 1)
        except ResponseException as ex:
            raise I2CHatsException(str(ex))
