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(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 TypeMethodDescriptionset(boolean value) protected static voidsetCondition(String name, boolean value) Set the value of an event conditionsetFalse()Create a command that will set the state to false for a given time.voidsetState(boolean value) Directly set the spectrum state to the specified valuesetTrue()setTrueForTime(DoubleSupplier time) Create a command that will set the state to true for a given time.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.Create a command that will set the state to true while the command is running Then it will set to false once it is cancelledtoggle()Command to set state to true, and then to false, ensuring your state will trigger change to false actionsCommand 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
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
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
Command to set state to false, and then to true, ensuring your state will trigger actions- Returns:
- the command
-
toggleToFalse
Command to set state to true, and then to false, ensuring your state will trigger change to false actions- Returns:
-
set
- Parameters:
value-- Returns:
-
setTrue
-
setFalse
-
toggle
-
setCondition
Set the value of an event condition- Parameters:
name- The name of the conditionvalue- The value of the condition
-