WPILibC++ 2023.4.3
|
Class for handling asynchronous interrupts using a callback thread. More...
#include <frc/AsynchronousInterrupt.h>
Public Member Functions | |
AsynchronousInterrupt (DigitalSource &source, std::function< void(bool, bool)> callback) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
AsynchronousInterrupt (DigitalSource *source, std::function< void(bool, bool)> callback) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
AsynchronousInterrupt (std::shared_ptr< DigitalSource > source, std::function< void(bool, bool)> callback) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
template<typename Callable , typename Arg , typename... Args> | |
AsynchronousInterrupt (DigitalSource &source, Callable &&f, Arg &&arg, Args &&... args) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
template<typename Callable , typename Arg , typename... Args> | |
AsynchronousInterrupt (DigitalSource *source, Callable &&f, Arg &&arg, Args &&... args) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
template<typename Callable , typename Arg , typename... Args> | |
AsynchronousInterrupt (std::shared_ptr< DigitalSource > source, Callable &&f, Arg &&arg, Args &&... args) | |
Construct an Asynchronous Interrupt from a Digital Source. More... | |
~AsynchronousInterrupt () | |
void | Enable () |
Enables interrupt callbacks. More... | |
void | Disable () |
Disables interrupt callbacks. More... | |
void | SetInterruptEdges (bool risingEdge, bool fallingEdge) |
Set which edges to trigger the interrupt on. More... | |
units::second_t | GetRisingTimestamp () |
Get the timestamp of the last rising edge. More... | |
units::second_t | GetFallingTimestamp () |
Get the timestamp of the last falling edge. More... | |
Class for handling asynchronous interrupts using a callback thread.
By default, interrupts will occur on rising edge. Callbacks are disabled by default, and Enable() must be called before they will occur.
Both rising and falling edges can be indicated in one callback if both a rising and falling edge occurred since the previous callback.
Synchronous (blocking) interrupts are handled by the SynchronousInterrupt class.
frc::AsynchronousInterrupt::AsynchronousInterrupt | ( | DigitalSource & | source, |
std::function< void(bool, bool)> | callback | ||
) |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
The first bool in the callback indicates the rising edge triggered the interrupt, the second bool is falling edge.
source | the DigitalSource the interrupts are triggered from |
callback | the callback function to call when the interrupt is triggered |
frc::AsynchronousInterrupt::AsynchronousInterrupt | ( | DigitalSource * | source, |
std::function< void(bool, bool)> | callback | ||
) |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
The first bool in the callback indicates the rising edge triggered the interrupt, the second bool is falling edge.
source | the DigitalSource the interrupts are triggered from |
callback | the callback function to call when the interrupt is triggered |
frc::AsynchronousInterrupt::AsynchronousInterrupt | ( | std::shared_ptr< DigitalSource > | source, |
std::function< void(bool, bool)> | callback | ||
) |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
The first bool in the callback indicates the rising edge triggered the interrupt, the second bool is falling edge.
source | the DigitalSource the interrupts are triggered from |
callback | the callback function to call when the interrupt is triggered |
|
inline |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
source | the DigitalSource the interrupts are triggered from |
f | the callback function to call when the interrupt is triggered |
arg | the first argument, interrupt was triggered on rising edge |
args | the remaining arguments, interrupt was triggered on falling edge |
|
inline |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
source | the DigitalSource the interrupts are triggered from |
f | the callback function to call when the interrupt is triggered |
arg | the first argument, interrupt was triggered on rising edge |
args | the remaining arguments, interrupt was triggered on falling edge |
|
inline |
Construct an Asynchronous Interrupt from a Digital Source.
At construction, the interrupt will trigger on the rising edge.
source | the DigitalSource the interrupts are triggered from |
f | the callback function to call when the interrupt is triggered |
arg | the first argument, interrupt was triggered on rising edge |
args | the remaining arguments, interrupt was triggered on falling edge |
frc::AsynchronousInterrupt::~AsynchronousInterrupt | ( | ) |
void frc::AsynchronousInterrupt::Disable | ( | ) |
Disables interrupt callbacks.
Does nothing if already disabled.
void frc::AsynchronousInterrupt::Enable | ( | ) |
Enables interrupt callbacks.
Before this, callbacks will not occur. Does nothing if already enabled.
units::second_t frc::AsynchronousInterrupt::GetFallingTimestamp | ( | ) |
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.
units::second_t frc::AsynchronousInterrupt::GetRisingTimestamp | ( | ) |
Get the timestamp of the last rising edge.
This function does not require the interrupt to be enabled to work.
This only works if rising edge was configured using SetInterruptEdges.
void frc::AsynchronousInterrupt::SetInterruptEdges | ( | bool | risingEdge, |
bool | fallingEdge | ||
) |
Set which edges to trigger the interrupt on.
risingEdge | Trigger on rising edge |
fallingEdge | Trigger on falling edge |