Class LEDPatterns

java.lang.Object
com.flarerobotics.lib.subsystem.led.LEDPatterns

public class LEDPatterns extends Object
A container class holding LED patterns.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new LEDPatterns.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(edu.wpi.first.wpilibj.LEDPattern pattern)
    Applies the given pattern to the LED.
    bolt(edu.wpi.first.wpilibj.util.Color color, double length, double time, boolean multiple)
    Creates a pattern that triggers a bolt with a decreasing brightness tail across the LED.
    breathe(edu.wpi.first.wpilibj.util.Color color, double onTime, int minBrightness, int maxBrightness)
    Creates a pattern that moves a color between high and low brightness via a sine wave, which looks like "breathing".
    edu.wpi.first.wpilibj.LEDPattern
    continuousGradient(edu.wpi.first.wpilibj.util.Color... colors)
    Creates a continuous gradient.
    edu.wpi.first.wpilibj.LEDPattern
    discontinuousGradient(edu.wpi.first.wpilibj.util.Color... colors)
    Creates a discontinuous gradient.
    fire(double sparking, double cooling, List<edu.wpi.first.wpilibj.util.Color> colors, boolean sectionInverted)
    Creates a pattern that creates a flickering effect similar to a fire, using a specfic palette of colors.
    generateRunnableFromPattern(edu.wpi.first.wpilibj.LEDPattern pattern)
    Generates a runnable that applies the given pattern.
    edu.wpi.first.wpilibj.LEDPattern
    progressMask(edu.wpi.first.wpilibj.LEDPattern pattern, DoubleSupplier progressSupplier)
    Masks a progress bar on the pattern provided, where only the supplied percentage will be shown.
    edu.wpi.first.wpilibj.LEDPattern
    rainbow(double velocity, int brightness, int saturation)
    Applies a rainbow pattern to the LED subsystem.
    edu.wpi.first.wpilibj.LEDPattern
    solid(edu.wpi.first.wpilibj.util.Color color)
    Applies a solid color to the LED subsystem.
    edu.wpi.first.wpilibj.LEDPattern
    steps(Map<Double,edu.wpi.first.wpilibj.util.Color> steps)
    Creates a steps gradient where solid colors are displayed seperately at sections.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LEDPatterns

      public LEDPatterns(LibLEDSubsystem subsystem)
      Constructs a new LEDPatterns.
      Parameters:
      subsystem - The LED subsystem.
  • Method Details

    • apply

      public void apply(edu.wpi.first.wpilibj.LEDPattern pattern)
      Applies the given pattern to the LED.
      Parameters:
      pattern - The pattern to apply.
    • rainbow

      public edu.wpi.first.wpilibj.LEDPattern rainbow(double velocity, int brightness, int saturation)
      Applies a rainbow pattern to the LED subsystem.
      Parameters:
      brightness - The brightness on a scale of 0-255.
      saturation - The saturation on a scale of 0-255.
      velocity - The velocity in m/s. (use 1 for default)
      Returns:
      The LEDPattern that is applied to the subsystem.
    • solid

      public edu.wpi.first.wpilibj.LEDPattern solid(edu.wpi.first.wpilibj.util.Color color)
      Applies a solid color to the LED subsystem.
      Parameters:
      color - The color.
      Returns:
      The LEDPattern that is applied to the subsystem.
    • continuousGradient

      public edu.wpi.first.wpilibj.LEDPattern continuousGradient(edu.wpi.first.wpilibj.util.Color... colors)
      Creates a continuous gradient.
      Parameters:
      colors - The colors to include.
      Returns:
      The LEDPattern that is applied to the subsystem.
    • discontinuousGradient

      public edu.wpi.first.wpilibj.LEDPattern discontinuousGradient(edu.wpi.first.wpilibj.util.Color... colors)
      Creates a discontinuous gradient.
      Parameters:
      colors - The colors to include.
      Returns:
      The LEDPattern that is applied to the subsystem.
    • steps

      public edu.wpi.first.wpilibj.LEDPattern steps(Map<Double,edu.wpi.first.wpilibj.util.Color> steps)
      Creates a steps gradient where solid colors are displayed seperately at sections.
      Parameters:
      steps - The steps map, where the double is the point at which the section for the color starts, has the range [0, 1).
      Returns:
      The LEDPattern that is applied to the subsystem.
    • progressMask

      public edu.wpi.first.wpilibj.LEDPattern progressMask(edu.wpi.first.wpilibj.LEDPattern pattern, DoubleSupplier progressSupplier)
      Masks a progress bar on the pattern provided, where only the supplied percentage will be shown.
      Parameters:
      pattern - The pattern to apply the mask to.
      progressSupplier - The percentage supplier.
      Returns:
      The LEDPattern that is applied to the subsystem with the mask.
    • generateRunnableFromPattern

      public Runnable generateRunnableFromPattern(edu.wpi.first.wpilibj.LEDPattern pattern)
      Generates a runnable that applies the given pattern.
      Parameters:
      pattern - The pattern to apply.
      Returns:
      The generated runnable.
    • bolt

      public Runnable bolt(edu.wpi.first.wpilibj.util.Color color, double length, double time, boolean multiple)
      Creates a pattern that triggers a bolt with a decreasing brightness tail across the LED. Cannot return a LEDPattern as the return value requires a consumer.

      To use, call the function once to obtain the runnable. Then call the runnable periodically to update.

      Parameters:
      color - The color of the bolt.
      length - The length of the bolt.
      time - The amount of time to take to finish the movement of the bolt across the LED strip, and optionally the time after which to send a new bolt.
      multiple - Whether to continuously send bolts or not.
      Returns:
      The generated LED buffer runnable.
    • breathe

      public Runnable breathe(edu.wpi.first.wpilibj.util.Color color, double onTime, int minBrightness, int maxBrightness)
      Creates a pattern that moves a color between high and low brightness via a sine wave, which looks like "breathing".

      To use, call the function once to obtain the runnable. Then call the runnable periodically to update.

      Parameters:
      color - The color to breathe.
      onTime - The amount of time, in seconds, that the strip should be on for.
      minBrightness - The brightness at the lowest point of the breath (make this 0 to turn off the strip).
      maxBrightness - The brightness at the highest point of the breath.
      Returns:
      The generated LED buffer runnable.
    • fire

      public Runnable fire(double sparking, double cooling, List<edu.wpi.first.wpilibj.util.Color> colors, boolean sectionInverted)
      Creates a pattern that creates a flickering effect similar to a fire, using a specfic palette of colors. Algorithm derivative of Fire2012.

      To use, call the function once to obtain the runnable. Then call the runnable periodically to update.

      Parameters:
      sparking - Percentage likelihood of a new spark being lit. higher chance = more roaring fire, lower chance = more flickery fire [0-1].
      cooling - How much the air cools as it rises. less cooling = taller flames, more cooling = shorter flames. [0-1].
      colors - The list of colors to interpolate between. the first color indicates the lowest temperature (typically black), and the last color indicates the highest temperature. A palette resembling default Fire2012 would be List.of(Color.kBlack, Color.kRed, Color.kYellow, Color.kWhite).
      sectionInverted - If true, the fire will be inverted.
      Returns:
      The generated LED buffer runnable.