InterruptableSensorBase

class wpilib.InterruptableSensorBase[source]

Bases: wpilib.SensorBase

Base for sensors to be used with interrupts

Create a new InterrupatableSensorBase

allocateInterrupts(watcher)[source]

Allocate the interrupt

Parameters:watcher – True if the interrupt should be in synchronous mode where the user program will have to explicitly wait for the interrupt to occur.
cancelInterrupts()[source]

Cancel interrupts on this device. This deallocates all the chipobject structures and disables any interrupts.

disableInterrupts()[source]

Disable Interrupts without without deallocating structures.

enableInterrupts()[source]

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.

getAnalogTriggerForRouting()[source]
getChannelForRouting()[source]
getModuleForRouting()[source]
interrupt[source]
interrupts = <wpilib.resource.Resource object at 0x7f6810c1ac18>
readFallingTimestamp()[source]

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 setUpSourceEdge.

Returns:Timestamp in seconds since boot.
readRisingTimestamp()[source]

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(handler=None)[source]

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

Parameters:handler – (optional) The function that will be called whenever there is an interrupt on this device. Request interrupts in synchronous mode where the user program interrupt handler will be called when an interrupt occurs. The default is interrupt on rising edges only. If not specified, the user program will have to explicitly wait for the interrupt to occur using waitForInterrupt.
setUpSourceEdge(risingEdge, fallingEdge)[source]

Set which edge to trigger interrupts on

Parameters:
  • risingEdge – True to interrupt on rising edge
  • fallingEdge – True to interrupt on falling edge
waitForInterrupt(timeout, ignorePrevious=True)[source]

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 (default), ignore interrupts that happened before waitForInterrupt was called.