Package frc.robot.commands
Class WaitUntilInterrupt
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.robot.commands.WaitUntilInterrupt
- All Implemented Interfaces:
Sendable
Command that creates an
AsynchronousInterrupt
and uses it to trigger a callback, waiting until the callback happens before finishing.-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Constructor Summary
ConstructorsConstructorDescriptionWaitUntilInterrupt
(DigitalSource source, BiConsumer<Boolean, Boolean> callback) Creates a new WaitUntilInterrupt command that finishes when the interrupt is triggered.WaitUntilInterrupt
(DigitalSource source, BiConsumer<Boolean, Boolean> callback, boolean risingEdge, boolean fallingEdge) Creates a new WaitUntilInterrupt command that finishes when the interrupt is triggered. -
Method Summary
Methods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, execute, finallyDo, finallyDo, getInterruptionBehavior, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, initSendable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
WaitUntilInterrupt
public WaitUntilInterrupt(DigitalSource source, BiConsumer<Boolean, Boolean> callback, boolean risingEdge, boolean fallingEdge) Creates a new WaitUntilInterrupt command that finishes when the interrupt is triggered.First bool in callback indicates trigger on rising edge, second bool indicates falling edge.
- Parameters:
source
- Digital source to await an interrupt on.callback
- Callback to call on interrupt.risingEdge
- Trigger on the rising edge.fallingEdge
- Trigger on the falling edge.
-
WaitUntilInterrupt
Creates a new WaitUntilInterrupt command that finishes when the interrupt is triggered. Triggers on both the rising and falling edges.First bool in callback indicates trigger on rising edge, second bool indicates falling edge.
- Parameters:
source
- Digital source to await an interrupt on.callback
- Callback to call on interrupt.
-
-
Method Details
-
initialize
public void initialize()- Overrides:
initialize
in classCommand
-
end
public void end(boolean interrupted) -
isFinished
public boolean isFinished()- Overrides:
isFinished
in classCommand
-