Class LEDAnimationFrame

java.lang.Object
org.chsrobotics.lib.hardware.ledStrip.LEDAnimationFrame

public class LEDAnimationFrame extends Object
Wraps around an array of RGBColors (or individual pixel color values), intended for combination into full animations.
  • Constructor Details

    • LEDAnimationFrame

      public LEDAnimationFrame(List<RGBColor> pixelColors)
      Constructs an LEDAnimationFrame.
      Parameters:
      pixelColors - Individual pixel colors to form the frame.
    • LEDAnimationFrame

      public LEDAnimationFrame()
      Constructor for an empty LEDAnimationFrame.
  • Method Details

    • numberOfPixels

      public int numberOfPixels()
      Returns the number of pixels currently in the animation frame.
      Returns:
      The number of individual colors.
    • getPixel

      public RGBColor getPixel(int index)
      Gets the pixel color value at an index.
      Parameters:
      index - The index to sample.
      Returns:
      The color at that index. If not a valid index, returns RGBColor.BLACK.
    • toNewSize

      public LEDAnimationFrame toNewSize(int newSize)
      Returns a new LEDAnimationFrame based off of this frame, but at a different size.
      Parameters:
      newSize - The desired size. If less than or equal to 0, returns this frame unchanged.
      Returns:
      A new frame. If the new size is larger than this size, repeats the existing pattern until the desired size is reached. If the new size is smaller, truncates this frame to the new size.
    • offset

      public LEDAnimationFrame offset(int step)
      Returns a new LEDAnimationFrame with each color offset (raised or lowered) in index by a given step.
      Parameters:
      step - The step to offset by.
      Returns:
      A new LEDAnimationFrame.
    • add

      Returns a new LEDAnimationFrame of another frame appended to this frame.
      Parameters:
      other - The frame to append to this.
      Returns:
      A new LEDAnimationFrame.
    • alternating

      public static LEDAnimationFrame alternating(int numberColorA, int numberColorB, RGBColor colorA, RGBColor colorB)
      Statically constructs and returns a new LEDAnimationFrame of alternating colors. To extend to a desired length, use toNewSize().
      Parameters:
      numberColorA - How many of color A should be put before switching to color B. If less than or equal to zero, returns an empty frame.
      numberColorB - How many of color B to put. If less than or equal to zero, returns and empty frame.
      colorA - The first RGBColor to put.
      colorB - The second RGBColor to put.
      Returns:
      A new LEDAnimationFrame.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object