def waitForInterrupt(self, timeout, ignorePrevious=True): """In synchronous mode, wait for the defined interrupt to occur. You should **NOT** attempt to read the sensor from another thread while waiting for an interrupt. This is not threadsafe, and can cause memory corruption :param timeout: Timeout in seconds :param ignorePrevious: If True (default), ignore interrupts that happened before waitForInterrupt was called. """ if self.interrupt is None: raise ValueError("The interrupt is not allocated.") return hal.waitForInterrupt(self.interrupt, timeout, ignorePrevious)
def waitForInterrupt(self, timeout: float, ignorePrevious: bool = True) -> int: """In synchronous mode, wait for the defined interrupt to occur. You should **NOT** attempt to read the sensor from another thread while waiting for an interrupt. This is not threadsafe, and can cause memory corruption :param timeout: Timeout in seconds :param ignorePrevious: If True (default), ignore interrupts that happened before waitForInterrupt was called. """ if self.interrupt is None: raise ValueError("The interrupt is not allocated.") result = hal.waitForInterrupt(self.interrupt, timeout, ignorePrevious) rising = 0x1 if (result & 0xFF) else 0x0 falling = 0x100 if (result & 0xFF00) else 0x0 result = rising | falling return self.WaitResult(result)