Class SpectrumLEDs

java.lang.Object
frc.spectrumLib.leds.SpectrumLEDs
All Implemented Interfaces:
edu.wpi.first.wpilibj2.command.Subsystem, SpectrumSubsystem
Direct Known Subclasses:
LedFull, LedLeft, LedRight

public class SpectrumLEDs extends Object implements SpectrumSubsystem
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected edu.wpi.first.wpilibj2.command.Command
     
    protected final edu.wpi.first.wpilibj.LEDPattern
     
    final Trigger
     
    protected final edu.wpi.first.wpilibj.AddressableLED
     
    protected final edu.wpi.first.wpilibj.AddressableLEDBuffer
     
    protected final edu.wpi.first.wpilibj.AddressableLEDBufferView
     
    final edu.wpi.first.wpilibj.util.Color
     
    final edu.wpi.first.wpilibj.util.Color
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    edu.wpi.first.wpilibj.LEDPattern
    blink(edu.wpi.first.wpilibj.util.Color c, double onTime)
    Creates an LED pattern that blinks with the specified on-time duration.
    edu.wpi.first.wpilibj.LEDPattern
    bounce(edu.wpi.first.wpilibj.util.Color c, double durationInSeconds)
    Creates a bouncing LED pattern with the specified color and duration.
    edu.wpi.first.wpilibj.LEDPattern
    breathe(edu.wpi.first.wpilibj.util.Color c, double period)
    Creates a breathing LED pattern with the specified period.
    edu.wpi.first.wpilibj.LEDPattern
    chase(edu.wpi.first.wpilibj.util.Color color1, double percent, double speed)
    Creates an LED chase pattern with the specified color, percentage, and speed.
    checkPriority(int priority)
     
    edu.wpi.first.wpilibj.LEDPattern
    countdown(DoubleSupplier countStartTimeSec, double durationInSeconds)
    Creates an LEDPattern that represents a countdown effect.
    edu.wpi.first.wpilibj.LEDPattern
    edges(edu.wpi.first.wpilibj.util.Color c, double length)
     
    int
     
     
    edu.wpi.first.wpilibj2.command.Command
     
    edu.wpi.first.wpilibj.AddressableLED
     
    edu.wpi.first.wpilibj.AddressableLEDBuffer
     
    edu.wpi.first.wpilibj.AddressableLEDBufferView
     
    edu.wpi.first.wpilibj.LEDPattern
    gradient(edu.wpi.first.wpilibj.util.Color... colors)
    Creates a gradient LED pattern using the specified colors.
    boolean
     
    edu.wpi.first.wpilibj.LEDPattern
    ombre(edu.wpi.first.wpilibj.util.Color startColor, edu.wpi.first.wpilibj.util.Color endColor)
    Creates an ombre LED pattern that transitions smoothly between two colors.
    void
     
    edu.wpi.first.wpilibj.LEDPattern
    Creates and returns a rainbow LED pattern with specified brightness and saturation.
    edu.wpi.first.wpilibj.LEDPattern
    rainbow(int saturation, int value)
    Generates a rainbow LED pattern with the specified saturation and value.
    edu.wpi.first.wpilibj.LEDPattern
    scroll(edu.wpi.first.wpilibj.LEDPattern pattern, double speedMps)
    Scrolls the given LED pattern at the specified speed.
    edu.wpi.first.wpilibj.LEDPattern
     
    setCommandPriority(int commandPriority)
     
    edu.wpi.first.wpilibj2.command.Command
    setPattern(edu.wpi.first.wpilibj.LEDPattern pattern)
     
    edu.wpi.first.wpilibj2.command.Command
    setPattern(edu.wpi.first.wpilibj.LEDPattern pattern, int priority)
     
    void
     
    void
     
    edu.wpi.first.wpilibj.LEDPattern
    solid(edu.wpi.first.wpilibj.util.Color color)
    Creates a solid LED pattern with the specified color.
    edu.wpi.first.wpilibj.LEDPattern
    stripe(double percent, edu.wpi.first.wpilibj.util.Color color1, edu.wpi.first.wpilibj.util.Color color2)
    LED Pattern Stripe, takes in a double percent and sets the first length number of LEDs to one color and the rest of the strip to another
    edu.wpi.first.wpilibj.LEDPattern
    wave(edu.wpi.first.wpilibj.util.Color c1, edu.wpi.first.wpilibj.util.Color c2, double cycleLength, double durationSecs)
    Creates a wave LED pattern that transitions between two colors over a specified cycle length of LEDs and duration.

    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, getName, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
  • Field Details

    • led

      protected final edu.wpi.first.wpilibj.AddressableLED led
    • ledBuffer

      protected final edu.wpi.first.wpilibj.AddressableLEDBuffer ledBuffer
    • ledView

      protected final edu.wpi.first.wpilibj.AddressableLEDBufferView ledView
    • defaultPattern

      protected final edu.wpi.first.wpilibj.LEDPattern defaultPattern
    • defaultCommand

      protected edu.wpi.first.wpilibj2.command.Command defaultCommand
    • defaultTrigger

      public final Trigger defaultTrigger
    • purple

      public final edu.wpi.first.wpilibj.util.Color purple
    • white

      public final edu.wpi.first.wpilibj.util.Color white
  • Constructor Details

  • Method Details

    • periodic

      public void periodic()
      Specified by:
      periodic in interface edu.wpi.first.wpilibj2.command.Subsystem
    • isAttached

      public boolean isAttached()
    • checkPriority

      public Trigger checkPriority(int priority)
    • setPattern

      public edu.wpi.first.wpilibj2.command.Command setPattern(edu.wpi.first.wpilibj.LEDPattern pattern, int priority)
    • setPattern

      public edu.wpi.first.wpilibj2.command.Command setPattern(edu.wpi.first.wpilibj.LEDPattern pattern)
    • setupStates

      public void setupStates()
      Specified by:
      setupStates in interface SpectrumSubsystem
    • setupDefaultCommand

      public void setupDefaultCommand()
      Specified by:
      setupDefaultCommand in interface SpectrumSubsystem
    • stripe

      public edu.wpi.first.wpilibj.LEDPattern stripe(double percent, edu.wpi.first.wpilibj.util.Color color1, edu.wpi.first.wpilibj.util.Color color2)
      LED Pattern Stripe, takes in a double percent and sets the first length number of LEDs to one color and the rest of the strip to another
    • solid

      public edu.wpi.first.wpilibj.LEDPattern solid(edu.wpi.first.wpilibj.util.Color color)
      Creates a solid LED pattern with the specified color.
      Parameters:
      color - the color to be used for the solid LED pattern
      Returns:
      an LEDPattern object representing the solid color pattern
    • blink

      public edu.wpi.first.wpilibj.LEDPattern blink(edu.wpi.first.wpilibj.util.Color c, double onTime)
      Creates an LED pattern that blinks with the specified on-time duration.
      Parameters:
      onTime - the duration (in seconds) for which the LED stays on during each blink cycle
      Returns:
      an LEDPattern that blinks with the specified on-time duration
    • breathe

      public edu.wpi.first.wpilibj.LEDPattern breathe(edu.wpi.first.wpilibj.util.Color c, double period)
      Creates a breathing LED pattern with the specified period.
      Parameters:
      period - The period of the breathing effect in seconds.
      Returns:
      An LEDPattern object representing the breathing effect.
    • rainbow

      public edu.wpi.first.wpilibj.LEDPattern rainbow()
      Creates and returns a rainbow LED pattern with specified brightness and saturation.
      Returns:
      an LEDPattern object representing a rainbow pattern with maximum brightness (255) and medium saturation (128).
    • scrollingRainbow

      public edu.wpi.first.wpilibj.LEDPattern scrollingRainbow()
    • rainbow

      public edu.wpi.first.wpilibj.LEDPattern rainbow(int saturation, int value)
      Generates a rainbow LED pattern with the specified saturation and value.
      Parameters:
      saturation - the saturation level of the rainbow pattern (0-255)
      value - the brightness value of the rainbow pattern (0-255)
      Returns:
      an LEDPattern object representing the rainbow pattern
    • gradient

      public edu.wpi.first.wpilibj.LEDPattern gradient(edu.wpi.first.wpilibj.util.Color... colors)
      Creates a gradient LED pattern using the specified colors.
      Parameters:
      colors - The array of colors to be used in the gradient pattern.
      Returns:
      An LEDPattern object representing the gradient pattern.
    • scroll

      public edu.wpi.first.wpilibj.LEDPattern scroll(edu.wpi.first.wpilibj.LEDPattern pattern, double speedMps)
      Scrolls the given LED pattern at the specified speed.
      Parameters:
      pattern - the LEDPattern to be scrolled
      speedMps - the speed at which the pattern should scroll, in meters per second
      Returns:
      a new LEDPattern that represents the scrolled pattern
    • chase

      public edu.wpi.first.wpilibj.LEDPattern chase(edu.wpi.first.wpilibj.util.Color color1, double percent, double speed)
      Creates an LED chase pattern with the specified color, percentage, and speed.
      Parameters:
      color1 - The color to be used in the chase pattern.
      percent - The percentage of the pattern that will be the specified color.
      speed - The speed at which the pattern will scroll, in Hertz.
      Returns:
      An LEDPattern object representing the chase pattern.
    • bounce

      public edu.wpi.first.wpilibj.LEDPattern bounce(edu.wpi.first.wpilibj.util.Color c, double durationInSeconds)
      Creates a bouncing LED pattern with the specified color and duration.
      Parameters:
      c - the color of the bouncing LED
      durationInSeconds - the duration of one complete bounce cycle in seconds
      Returns:
      an LEDPattern that applies the bouncing effect to the LEDs
    • ombre

      public edu.wpi.first.wpilibj.LEDPattern ombre(edu.wpi.first.wpilibj.util.Color startColor, edu.wpi.first.wpilibj.util.Color endColor)
      Creates an ombre LED pattern that transitions smoothly between two colors.
      Parameters:
      startColor - The starting color of the ombre effect.
      endColor - The ending color of the ombre effect.
      Returns:
      An LEDPattern that applies the ombre effect to the LED strip.
    • wave

      public edu.wpi.first.wpilibj.LEDPattern wave(edu.wpi.first.wpilibj.util.Color c1, edu.wpi.first.wpilibj.util.Color c2, double cycleLength, double durationSecs)
      Creates a wave LED pattern that transitions between two colors over a specified cycle length of LEDs and duration.
      Parameters:
      c1 - The first color in the wave pattern.
      c2 - The second color in the wave pattern.
      cycleLength - The length of the wave cycle in terms of LEDs.
      durationSecs - The duration of the entire wave pattern in seconds.
      Returns:
      An LEDPattern that applies the wave effect to the LEDs.
    • countdown

      public edu.wpi.first.wpilibj.LEDPattern countdown(DoubleSupplier countStartTimeSec, double durationInSeconds)
      Creates an LEDPattern that represents a countdown effect. The countdown starts from a specified time and lasts for a given duration. During the countdown, the LEDs transition from yellow to red, and progressively turn off from the end of the strip towards the beginning.
      Parameters:
      countStartTimeSec - A DoubleSupplier that provides the start time of the countdown in seconds.
      durationInSeconds - The total duration of the countdown in seconds.
      Returns:
      An LEDPattern that applies the countdown effect to the LEDs.
    • edges

      public edu.wpi.first.wpilibj.LEDPattern edges(edu.wpi.first.wpilibj.util.Color c, double length)
    • getConfig

      public SpectrumLEDs.Config getConfig()
    • getLed

      public edu.wpi.first.wpilibj.AddressableLED getLed()
    • getLedBuffer

      public edu.wpi.first.wpilibj.AddressableLEDBuffer getLedBuffer()
    • getLedView

      public edu.wpi.first.wpilibj.AddressableLEDBufferView getLedView()
    • getDefaultCommand

      public edu.wpi.first.wpilibj2.command.Command getDefaultCommand()
      Specified by:
      getDefaultCommand in interface edu.wpi.first.wpilibj2.command.Subsystem
    • getCommandPriority

      public int getCommandPriority()
    • setCommandPriority

      public SpectrumLEDs setCommandPriority(int commandPriority)
      Returns:
      this.