Class SimpleLEDAnimation

java.lang.Object
org.chsrobotics.lib.hardware.ledStrip.SimpleLEDAnimation
All Implemented Interfaces:
LEDAnimation

public class SimpleLEDAnimation extends Object implements LEDAnimation
Wraps around an array of LEDAnimationFrames, intended for playing back in sequence.
  • Constructor Details

    • SimpleLEDAnimation

      public SimpleLEDAnimation(List<LEDAnimationFrame> frames)
      Constructs a new SimpleLEDAnimation.
      Parameters:
      frames - Frames to add to the animation. If a first frame is present, all other frames will be reshaped to match it in length.
  • Method Details

    • numberOfFrames

      public int numberOfFrames()
      Returns the number of frames the animation consists of.
      Returns:
      The number of frames present.
    • numberOfPixelsPerFrame

      public int numberOfPixelsPerFrame()
      Description copied from interface: LEDAnimation
      Returns the number of pixels per each frame.
      Specified by:
      numberOfPixelsPerFrame in interface LEDAnimation
      Returns:
      The expected number of pixels contained by every frame.
    • getNextFrame

      public LEDAnimationFrame getNextFrame()
      Description copied from interface: LEDAnimation
      Returns the current frame of the LEDAnimation.
      Specified by:
      getNextFrame in interface LEDAnimation
      Returns:
      The LEDAnimation to display.
    • getFrame

      public LEDAnimationFrame getFrame(int index)
      Returns the LEDAnimationFrame at an index.
      Parameters:
      index - The index to sample.
      Returns:
      The LEDAnimationFrame at that index.
    • gradientCascade

      public static SimpleLEDAnimation gradientCascade(int size, RGBColor colorA, RGBColor colorB)
      Statically constructs and returns a new SimpleLEDAnimation of a gradient between two colors which offsets itself by one step each cycle.
      Parameters:
      size - Number of pixels in the LED strip. If 0 or less, returns an empty animation.
      colorA - First color of the gradient.
      colorB - Second color of the gradient.
      Returns:
      A new LEDAnimation.
    • cascading

      public static SimpleLEDAnimation cascading(LEDAnimationFrame root)
      Statically constructs and returns a new SimpleLEDAnimation which offsets itself from an initial frame by one step each cycle.
      Parameters:
      root - The initial frame of the animation.
      Returns:
      A new LEDAnimation.
    • flashing

      public static SimpleLEDAnimation flashing(int periodCyclesA, int periodCyclesB, LEDAnimationFrame frameA, LEDAnimationFrame frameB)
      Statically constructs and returns a new SimpleLEDAnimation which periodically cycles between two frames.
      Parameters:
      periodCyclesA - How many consecutive cycles frameA should be shown for.
      periodCyclesB - How many consecutive cycles frameB should be shown for.
      frameA - The first frame to periodically display.
      frameB - The second frame to periodically display.
      Returns:
      A new LEDAnimation.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object