InterruptableSensorBase

class wpilib.InterruptableSensorBase(self: wpilib.InterruptableSensorBase) → None

Bases: wpilib.ErrorBase

class WaitResult(self: wpilib._wpilib.InterruptableSensorBase.WaitResult, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kTimeout

kRisingEdge

kFallingEdge

kBoth

kBoth = <WaitResult.kBoth: 257>
kFallingEdge = <WaitResult.kFallingEdge: 256>
kRisingEdge = <WaitResult.kRisingEdge: 1>
kTimeout = <WaitResult.kTimeout: 0>
property name
cancelInterrupts(self: wpilib.InterruptableSensorBase) → None

Cancel interrupts on this device.

This deallocates all the chipobject structures and disables any interrupts.

disableInterrupts(self: wpilib.InterruptableSensorBase) → None

Disable Interrupts without without deallocating structures.

enableInterrupts(self: wpilib.InterruptableSensorBase) → None

Enable interrupts to occur on this input.

Interrupts are disabled when the RequestInterrupt call is made. This gives time to do the setup of the other options before starting to field interrupts.

getAnalogTriggerTypeForRouting(self: wpilib.InterruptableSensorBase)wpilib.AnalogTriggerType
getPortHandleForRouting(self: wpilib.InterruptableSensorBase) → int
readFallingTimestamp(self: wpilib.InterruptableSensorBase) → float

Return the timestamp for the falling interrupt that occurred most recently.

This is in the same time domain as GetClock(). The falling-edge interrupt should be enabled with DigitalInput.SetUpSourceEdge()

Returns

Timestamp in seconds since boot.

readRisingTimestamp(self: wpilib.InterruptableSensorBase) → float

Return the timestamp for the rising interrupt that occurred most recently.

This is in the same time domain as GetClock(). The rising-edge interrupt should be enabled with SetUpSourceEdge().

Returns

Timestamp in seconds since boot.

requestInterrupts(*args, **kwargs)

Overloaded function.

  1. requestInterrupts(self: wpilib._wpilib.InterruptableSensorBase, handler: Callable[[wpilib._wpilib.InterruptableSensorBase.WaitResult], None]) -> None

Request one of the 8 interrupts asynchronously on this digital input.

Request interrupts in asynchronous mode where the user’s interrupt handler will be called when the interrupt fires. Users that want control over the thread priority should use the synchronous method with their own spawned thread. The default is interrupt on rising edges only.

  1. requestInterrupts(self: wpilib._wpilib.InterruptableSensorBase) -> None

Request one of the 8 interrupts synchronously on this digital input.

Request interrupts in synchronous mode where the user program will have to explicitly wait for the interrupt to occur using WaitForInterrupt. The default is interrupt on rising edges only.

setUpSourceEdge(self: wpilib.InterruptableSensorBase, risingEdge: bool, fallingEdge: bool) → None

Set which edge to trigger interrupts on

Parameters
  • risingEdge – true to interrupt on rising edge

  • fallingEdge – true to interrupt on falling edge

waitForInterrupt(self: wpilib.InterruptableSensorBase, timeout: float, ignorePrevious: bool = True) → wpilib._wpilib.InterruptableSensorBase.WaitResult

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

Parameters
  • timeout – Timeout in seconds

  • ignorePrevious – If true, ignore interrupts that happened before WaitForInterrupt was called.

Returns

What interrupts fired