Package frc.spectrumLib.framework
Class SpectrumState
java.lang.Object
edu.wpi.first.wpilibj2.command.button.Trigger
frc.spectrumLib.framework.SpectrumState
- All Implemented Interfaces:
BooleanSupplier
-
Constructor Summary
ConstructorsConstructorDescriptionSpectrumState(EventLoop eventLoop, String name) Polled by the given event loop instead of the scheduler's default one.SpectrumState(String name) Polled by the command scheduler's default event loop. -
Method Summary
Modifier and TypeMethodDescriptionset(boolean value) protected static voidsetCondition(String name, boolean value) setFalse()voidsetState(boolean value) setTrue()setTrueForTime(DoubleSupplier time) setTrueForTimeWithCancel(DoubleSupplier time, Trigger cancelCondition) toggle()Sets the state true, then false after a 5 ms wait, so a binding polled between them still sees the true state.Sets the state false, then true after a 5 ms wait, so a binding polled between them still sees the false state.Methods 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
Polled by the command scheduler's default event loop.- Parameters:
name- the state's name, used as its key and in its alert
-
SpectrumState
Polled by the given event loop instead of the scheduler's default one.
-
-
Method Details
-
setState
public void setState(boolean value) -
setTrueWhileRunning
-
setTrueForTime
- Parameters:
time- how long to hold the state true, in seconds
-
setFalseForTime
- Parameters:
time- how long to hold the state false, in seconds
-
setTrueForTimeWithCancel
- Parameters:
time- the longest the state stays true, in secondscancelCondition- ends the wait early and drops the state to false
-
toggleToTrue
Sets the state false, then true after a 5 ms wait, so a binding polled between them still sees the false state. -
toggleToFalse
Sets the state true, then false after a 5 ms wait, so a binding polled between them still sees the true state. -
set
-
setTrue
-
setFalse
-
toggle
-
setCondition
-