Class LibLEDSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
com.flarerobotics.lib.subsystem.led.LibLEDSubsystem
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
,edu.wpi.first.wpilibj2.command.Subsystem
public class LibLEDSubsystem
extends edu.wpi.first.wpilibj2.command.SubsystemBase
A preset LED subsystem.
To apply patterns, use the applyPatternRunnable(java.lang.Runnable)
method in order to
apply the patterns correctly.
To apply a LEDPattern instance, use LEDPatterns.generateRunnableFromPattern(edu.wpi.first.wpilibj.LEDPattern)
. The
rest of the methods already return Runnables.
Note: In order to use simulation, select Hardware -> Addressable LEDs from the topbar in the simulation UI.
-
Constructor Summary
ConstructorsConstructorDescriptionLibLEDSubsystem
(int ledPort) Constructs a new LibLEDSubsystem.LibLEDSubsystem
(int ledPort, int lengthPixels, edu.wpi.first.units.measure.Distance ledLength) Constructs a new LibLEDSubsystem. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPatternRunnable
(Runnable runnable) Applies a runnable to the LED.edu.wpi.first.wpilibj.AddressableLEDBuffer
Returns the adressable LED's buffer.edu.wpi.first.wpilibj.AddressableLED
getLED()
Returns the adressable LED.double
Returns the pixel density of the LED, or how many pixels are in a meter.Returns the LED patterns class, which contains pattern presets and a method to apply them.void
periodic()
void
resetLED()
Resets the LED to a solid white color.void
setLEDBuffer
(edu.wpi.first.wpilibj.AddressableLEDBuffer customBuffer) Applies the given buffer to the LED.Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
LibLEDSubsystem
public LibLEDSubsystem(int ledPort, int lengthPixels, edu.wpi.first.units.measure.Distance ledLength) Constructs a new LibLEDSubsystem.- Parameters:
ledPort
- The port of the LED.lengthPixels
- The length of the LED in pixels.ledLength
- The length of the LED.
-
LibLEDSubsystem
public LibLEDSubsystem(int ledPort) Constructs a new LibLEDSubsystem. Uses a default length of 60 pixels and a linear pixel density of 60 pixels per meter.- Parameters:
ledPort
- The port of the LED.
-
-
Method Details
-
periodic
public void periodic() -
getLEDPixelDensity
public double getLEDPixelDensity()Returns the pixel density of the LED, or how many pixels are in a meter.- Returns:
- The density.
-
getLED
public edu.wpi.first.wpilibj.AddressableLED getLED()Returns the adressable LED.- Returns:
- The LED.
-
getBuffer
public edu.wpi.first.wpilibj.AddressableLEDBuffer getBuffer()Returns the adressable LED's buffer.- Returns:
- The buffer.
-
getPatterns
Returns the LED patterns class, which contains pattern presets and a method to apply them.- Returns:
- The patterns class.
-
setLEDBuffer
public void setLEDBuffer(edu.wpi.first.wpilibj.AddressableLEDBuffer customBuffer) Applies the given buffer to the LED.- Parameters:
customBuffer
- The custom buffer.
-
resetLED
public void resetLED()Resets the LED to a solid white color. -
applyPatternRunnable
Applies a runnable to the LED.- Parameters:
runnable
- The runnable function.
-