Class SpectrumState

java.lang.Object
edu.wpi.first.wpilibj2.command.button.Trigger
frc.spectrumLib.framework.SpectrumState
All Implemented Interfaces:
BooleanSupplier

public class SpectrumState extends Trigger
A named boolean state usable as a WPILib Trigger. Every instance built with the same name reads and writes one shared value, and each raises an Alert in the States group.
  • Constructor Details

    • SpectrumState

      public SpectrumState(String name)
      Polled by the command scheduler's default event loop.
      Parameters:
      name - the state's name, used as its key and in its alert
    • SpectrumState

      public SpectrumState(EventLoop eventLoop, String name)
      Polled by the given event loop instead of the scheduler's default one.
  • Method Details

    • setState

      public void setState(boolean value)
    • setTrueWhileRunning

      public Command setTrueWhileRunning()
    • setTrueForTime

      public Command setTrueForTime(DoubleSupplier time)
      Parameters:
      time - how long to hold the state true, in seconds
    • setFalseForTime

      public Command setFalseForTime(DoubleSupplier time)
      Parameters:
      time - how long to hold the state false, in seconds
    • setTrueForTimeWithCancel

      public Command setTrueForTimeWithCancel(DoubleSupplier time, Trigger cancelCondition)
      Parameters:
      time - the longest the state stays true, in seconds
      cancelCondition - ends the wait early and drops the state to false
    • toggleToTrue

      public Command toggleToTrue()
      Sets the state false, then true after a 5 ms wait, so a binding polled between them still sees the false state.
    • toggleToFalse

      public Command toggleToFalse()
      Sets the state true, then false after a 5 ms wait, so a binding polled between them still sees the true state.
    • set

      public Command set(boolean value)
    • setTrue

      public Command setTrue()
    • setFalse

      public Command setFalse()
    • toggle

      public Command toggle()
    • setCondition

      protected static void setCondition(String name, boolean value)