Package frc.spectrumLib.framework
Class SpectrumState
java.lang.Object
edu.wpi.first.wpilibj2.command.button.Trigger
frc.spectrumLib.framework.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.
-
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) Creates an instant command that sets the state to the given value.protected static voidsetCondition(String name, boolean value) Set the value of an event conditionsetFalse()Creates an instant command that sets the state tofalse.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()Creates an instant command that sets the state totrue.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()Creates an instant command that flips the current state value.Command to set state to true, and then to false, ensuring triggers bound to the false transition fire reliably.Command 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, debounce, debounce, getAsBoolean, multiPress, negate, onChange, onFalse, onTrue, or, toggleOnFalse, toggleOnTrue, whileFalse, 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 triggers bound to the false transition fire reliably.- Returns:
- the command
-
set
Creates an instant command that sets the state to the given value.- Parameters:
value- The desired state value- Returns:
- the command
-
setTrue
Creates an instant command that sets the state totrue.- Returns:
- the command
-
setFalse
Creates an instant command that sets the state tofalse.- Returns:
- the command
-
toggle
Creates an instant command that flips the current state value.- Returns:
- the command
-
setCondition
Set the value of an event condition- Parameters:
name- The name of the conditionvalue- The value of the condition
-