Package frc.spectrumLib
Class SpectrumState
java.lang.Object
edu.wpi.first.wpilibj2.command.button.Trigger
frc.spectrumLib.SpectrumState
- All Implemented Interfaces:
BooleanSupplier
Represents a global or subsystem-specific state that can be used as a Trigger. Integrates with
WPILib's Trigger and Alert systems.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSpectrumState(edu.wpi.first.wpilibj.event.EventLoop eventLoop, String name) Create a new EventTrigger that gets polled by the given event loop instead of the EventSchedulerSpectrumState(String name) Create a new EventTrigger. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.Commandset(boolean value) protected static voidsetCondition(String name, boolean value) Set the value of an event conditionedu.wpi.first.wpilibj2.command.CommandsetFalse()edu.wpi.first.wpilibj2.command.CommandCreate a command that will set the state to false for a given time.voidsetState(boolean value) Directly set the spectrum state to the specified valueedu.wpi.first.wpilibj2.command.CommandsetTrue()edu.wpi.first.wpilibj2.command.CommandsetTrueForTime(DoubleSupplier time) Create a command that will set the state to true for a given time.edu.wpi.first.wpilibj2.command.CommandsetTrueForTimeWithCancel(DoubleSupplier time, Trigger cancelCondition) Create a command that will set the state to true for a given time, or until a cancel condition is met.edu.wpi.first.wpilibj2.command.CommandCreate a command that will set the state to true while the command is running Then it will set to false once it is cancellededu.wpi.first.wpilibj2.command.Commandtoggle()edu.wpi.first.wpilibj2.command.CommandCommand to set state to true, and then to false, ensuring your state will trigger change to false actionsedu.wpi.first.wpilibj2.command.CommandCommand to set state to false, and then to true, ensuring your state will trigger actionsMethods inherited from class edu.wpi.first.wpilibj2.command.button.Trigger
and, and, debounce, debounce, getAsBoolean, negate, not, onChange, onChangeToFalse, onChangeToTrue, onFalse, onFalse, onTrue, onTrue, or, or, runWithEndSequence, toggleOnFalse, toggleOnTrue, whileFalse, whileFalse, whileTrue, whileTrue
-
Constructor Details
-
SpectrumState
Create a new EventTrigger. This will run on the EventScheduler's event loop, which will be polled any time a path following command is running.- Parameters:
name- The name of the event. This will be the name of the event marker in the GUI
-
SpectrumState
Create a new EventTrigger that gets polled by the given event loop instead of the EventScheduler- Parameters:
eventLoop- The event loop to poll this triggername- The name of the event. This will be the name of the event marker in the GUI
-
-
Method Details
-
setState
public void setState(boolean value) Directly set the spectrum state to the specified value- Parameters:
value- The value to set the state to
-
setTrueWhileRunning
public edu.wpi.first.wpilibj2.command.Command setTrueWhileRunning()Create a command that will set the state to true while the command is running Then it will set to false once it is cancelled- Returns:
- the command
-
setTrueForTime
Create a command that will set the state to true for a given time.- Parameters:
time- The time in seconds to set the state to true- Returns:
- the command
-
setFalseForTime
Create a command that will set the state to false for a given time.- Parameters:
time- The time in seconds to set the state to false- Returns:
- the command
-
setTrueForTimeWithCancel
public edu.wpi.first.wpilibj2.command.Command setTrueForTimeWithCancel(DoubleSupplier time, Trigger cancelCondition) Create a command that will set the state to true for a given time, or until a cancel condition is met.- Parameters:
time- The time in seconds to set the state to truecancelCondition- The condition that will cancel the timer and set the state to false- Returns:
- the command
-
toggleToTrue
public edu.wpi.first.wpilibj2.command.Command toggleToTrue()Command to set state to false, and then to true, ensuring your state will trigger actions- Returns:
- the command
-
toggleToFalse
public edu.wpi.first.wpilibj2.command.Command toggleToFalse()Command to set state to true, and then to false, ensuring your state will trigger change to false actions- Returns:
-
set
public edu.wpi.first.wpilibj2.command.Command set(boolean value) - Parameters:
value-- Returns:
-
setTrue
public edu.wpi.first.wpilibj2.command.Command setTrue() -
setFalse
public edu.wpi.first.wpilibj2.command.Command setFalse() -
toggle
public edu.wpi.first.wpilibj2.command.Command toggle() -
setCondition
Set the value of an event condition- Parameters:
name- The name of the conditionvalue- The value of the condition
-