SynchronousInterrupt¶
- class wpilib.SynchronousInterrupt(*args, **kwargs)¶
Bases:
pybind11_object
Class for handling synchronous (blocking) interrupts.
By default, interrupts will occur on rising edge.
Asynchronous interrupts are handled by the AsynchronousInterrupt class.
Overloaded function.
__init__(self: wpilib._wpilib.SynchronousInterrupt, source: wpilib._wpilib.DigitalSource) -> None
Construct a Synchronous Interrupt from a Digital Source.
- Parameters:
source – the DigitalSource the interrupts are triggered from
__init__(self: wpilib._wpilib.SynchronousInterrupt, source: wpilib._wpilib.DigitalSource) -> None
Construct a Synchronous Interrupt from a Digital Source.
- Parameters:
source – the DigitalSource the interrupts are triggered from
__init__(self: wpilib._wpilib.SynchronousInterrupt, source: wpilib._wpilib.DigitalSource) -> None
Construct a Synchronous Interrupt from a Digital Source.
- Parameters:
source – the DigitalSource the interrupts are triggered from
- class WaitResult(value: int)¶
Bases:
pybind11_object
Event trigger combinations for a synchronous interrupt.
Members:
kTimeout
kRisingEdge
kFallingEdge
kBoth
- kBoth = <WaitResult.kBoth: 257>¶
- kFallingEdge = <WaitResult.kFallingEdge: 256>¶
- kRisingEdge = <WaitResult.kRisingEdge: 1>¶
- kTimeout = <WaitResult.kTimeout: 0>¶
- property name¶
- property value¶
- getFallingTimestamp() seconds ¶
Get the timestamp of the last falling edge.
This function does not require the interrupt to be enabled to work.
This only works if falling edge was configured using setInterruptEdges.
- Returns:
the timestamp in seconds relative to getFPGATime
- getRisingTimestamp() seconds ¶
Get the timestamp (relative to FPGA Time) of the last rising edge.
- Returns:
the timestamp in seconds relative to getFPGATime
- setInterruptEdges(risingEdge: bool, fallingEdge: bool) None ¶
Set which edges cause an interrupt to occur.
- Parameters:
risingEdge – true to trigger on rising edge, false otherwise.
fallingEdge – true to trigger on falling edge, false otherwise
- waitForInterrupt(timeout: seconds, ignorePrevious: bool = True) wpilib._wpilib.SynchronousInterrupt.WaitResult ¶
Wait for an interrupt to occur.
Both rising and falling edge can be returned if both a rising and falling happened between calls, and ignorePrevious is false.
- Parameters:
timeout – The timeout to wait for. 0s or less will return immediately.
ignorePrevious – True to ignore any previous interrupts, false to return interrupt value if an interrupt has occurred since last call.
- Returns:
The edge(s) that were triggered, or timeout.
- wakeupWaitingInterrupt() None ¶
Wake up an existing wait call. Can be called from any thread.