java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
com.team2813.lib2813.subsystems.lightshow.Lightshow
All Implemented Interfaces:
Sendable, Subsystem
Direct Known Subclasses:
QueueLightshow

public abstract class Lightshow extends SubsystemBase
  • Field Details

    • off

      protected static final State off
      A static state that signifies that the lights should be off, that is always applied
    • states

      protected final Set<State> states
    • defaultState

      protected Optional<? extends State> defaultState
  • Constructor Details

    • Lightshow

      protected Lightshow(Class<T> enumClass)
      Creates a new Lightshow subsystem using an enum. Uses the given enumClass to get a list of States to use.
      Type Parameters:
      T - The type of enum that implements state
      Parameters:
      enumClass - The enum class that contains the states
    • Lightshow

      protected Lightshow(Set<? extends State> states)
      Creates a new Lightshow subsystem with a set of states.
      Parameters:
      states - The states
  • Method Details

    • useColor

      protected abstract void useColor(Color color)
      Sets the lights to the provided color.

      Subclasses should override this to display the provided color. For example, the value could be passed to com.ctre.phoenix.CANifier.setLEDOutput(double, LEDChannel).

      Parameters:
      color - Color to display
    • addStates

      public final <T extends Enum<T> & State> void addStates(Class<? extends T> enumClass)
    • addStates

      public final void addStates(Set<? extends State> states)
    • update

      protected abstract Optional<Color> update()
      Updates the current States. Makes the current states updated, and gets the Color to be displayed.
      Returns:
      an optional representing the color to be displayed
      See Also:
      Implementation Requirements:
      Do anything with states to determine which Color to display
    • periodic

      public void periodic()

      This implementation of Subsystem.periodic() updates the colors by passing the call of update() to the given Consumer. If the call to update() returns an empty optional, than the color of the default state is used, or the color is not changed.

      Implementation Requirements:
      useColor(Color) is passed the result of update(), or the defaultState's color. If there is no color from update() and no default state, there is no requirement for what to pass to useColor(Color), or if useColor(Color) is called at all
    • setDefaultState

      public void setDefaultState(State defaultState)
      Sets the State to be used if none is given.
      Parameters:
      defaultState - the State to be used as a default.