def getProximity(self): write(self.bus, 0x80, 0x08) while (not (read(self.bus, 0x80) & 0x20)): pass h = read(self.bus, 0x87) d = h << 8 | read(self.bus, 0x88) return d
def setInterrupt(self, state=0): if (state): write(self.bus, 0x80, 0x03) write(self.bus, 0x89, 0x02) else: write(self.bus, 0x80, 0x00) write(self.bus, 0x89, 0)
def setHighThreshold(self, t): highBits = (0xFF00 & t) >> 8 lowBits = (0x00FF & t) write(self.bus, 0x8C, highBits) write(self.bus, 0x8D, lowBits)
def setLowThreshold(self, t): highBits = (0xFF00 & t) >> 8 lowBits = (0x00FF & t) write(self.bus, 0x8A, highBits) write(self.bus, 0x8B, lowBits)
def resetInterrupt(self): write(self.bus, 0x8E, 0x01)
def setLedLevel(self, lvl: int): if (lvl >= 0 and lvl <= 20): write(self.bus, 0x83, lvl)