WPILibC++ 2023.4.3-108-ge5452e3
frc::AsynchronousInterrupt Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ AsynchronousInterrupt() [1/6]

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.

Parameters
sourcethe DigitalSource the interrupts are triggered from
callbackthe callback function to call when the interrupt is triggered

◆ AsynchronousInterrupt() [2/6]

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.

Parameters
sourcethe DigitalSource the interrupts are triggered from
callbackthe callback function to call when the interrupt is triggered

◆ AsynchronousInterrupt() [3/6]

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.

Parameters
sourcethe DigitalSource the interrupts are triggered from
callbackthe callback function to call when the interrupt is triggered

◆ AsynchronousInterrupt() [4/6]

template<typename Callable , typename Arg , typename... Args>
frc::AsynchronousInterrupt::AsynchronousInterrupt ( DigitalSource source,
Callable &&  f,
Arg &&  arg,
Args &&...  args 
)
inline

Construct an Asynchronous Interrupt from a Digital Source.

At construction, the interrupt will trigger on the rising edge.

Parameters
sourcethe DigitalSource the interrupts are triggered from
fthe callback function to call when the interrupt is triggered
argthe first argument, interrupt was triggered on rising edge
argsthe remaining arguments, interrupt was triggered on falling edge

◆ AsynchronousInterrupt() [5/6]

template<typename Callable , typename Arg , typename... Args>
frc::AsynchronousInterrupt::AsynchronousInterrupt ( DigitalSource source,
Callable &&  f,
Arg &&  arg,
Args &&...  args 
)
inline

Construct an Asynchronous Interrupt from a Digital Source.

At construction, the interrupt will trigger on the rising edge.

Parameters
sourcethe DigitalSource the interrupts are triggered from
fthe callback function to call when the interrupt is triggered
argthe first argument, interrupt was triggered on rising edge
argsthe remaining arguments, interrupt was triggered on falling edge

◆ AsynchronousInterrupt() [6/6]

template<typename Callable , typename Arg , typename... Args>
frc::AsynchronousInterrupt::AsynchronousInterrupt ( std::shared_ptr< DigitalSource source,
Callable &&  f,
Arg &&  arg,
Args &&...  args 
)
inline

Construct an Asynchronous Interrupt from a Digital Source.

At construction, the interrupt will trigger on the rising edge.

Parameters
sourcethe DigitalSource the interrupts are triggered from
fthe callback function to call when the interrupt is triggered
argthe first argument, interrupt was triggered on rising edge
argsthe remaining arguments, interrupt was triggered on falling edge

◆ ~AsynchronousInterrupt()

frc::AsynchronousInterrupt::~AsynchronousInterrupt ( )

Member Function Documentation

◆ Disable()

void frc::AsynchronousInterrupt::Disable ( )

Disables interrupt callbacks.

Does nothing if already disabled.

◆ Enable()

void frc::AsynchronousInterrupt::Enable ( )

Enables interrupt callbacks.

Before this, callbacks will not occur. Does nothing if already enabled.

◆ GetFallingTimestamp()

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.

Returns
the timestamp in seconds relative to GetFPGATime

◆ GetRisingTimestamp()

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.

Returns
the timestamp in seconds relative to GetFPGATime

◆ SetInterruptEdges()

void frc::AsynchronousInterrupt::SetInterruptEdges ( bool  risingEdge,
bool  fallingEdge 
)

Set which edges to trigger the interrupt on.

Parameters
risingEdgeTrigger on rising edge
fallingEdgeTrigger on falling edge

The documentation for this class was generated from the following file: