Class Lightshow
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
com.team2813.lib2813.subsystems.lightshow.Lightshow
- Direct Known Subclasses:
QueueLightshow
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidvoidperiodic()voidsetDefaultState(State defaultState) Sets theStateto be used if none is given.update()Updates the current States.protected abstract voidSets the lights to the provided color.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Field Details
-
off
A static state that signifies that the lights should be off, that is always applied -
states
-
defaultState
-
-
Constructor Details
-
Lightshow
Creates a new Lightshow subsystem using an enum. Uses the givenenumClassto get a list ofStates to use.- Type Parameters:
T- The type of enum that implements state- Parameters:
enumClass- The enum class that contains the states
-
Lightshow
Creates a new Lightshow subsystem with a set of states.- Parameters:
states- The states
-
-
Method Details
-
useColor
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
-
addStates
-
update
Updates the current States. Makes the currentstatesupdated, and gets the Color to be displayed. -
periodic
public void periodic()This implementation of
Subsystem.periodic()updates the colors by passing the call ofupdate()to the givenConsumer. If the call toupdate()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 ofupdate(), or thedefaultState's color. If there is no color fromupdate()and no default state, there is no requirement for what to pass touseColor(Color), or ifuseColor(Color)is called at all
-
setDefaultState
Sets theStateto be used if none is given.- Parameters:
defaultState- theStateto be used as a default.
-