Class SimpleLEDAnimation
java.lang.Object
org.chsrobotics.lib.hardware.ledStrip.SimpleLEDAnimation
- All Implemented Interfaces:
LEDAnimation
Wraps around an array of LEDAnimationFrames, intended for playing back in sequence.
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleLEDAnimation(List<LEDAnimationFrame> frames) Constructs a new SimpleLEDAnimation. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleLEDAnimationcascading(LEDAnimationFrame root) Statically constructs and returns a new SimpleLEDAnimation which offsets itself from an initial frame by one step each cycle.booleanstatic SimpleLEDAnimationflashing(int periodCyclesA, int periodCyclesB, LEDAnimationFrame frameA, LEDAnimationFrame frameB) Statically constructs and returns a new SimpleLEDAnimation which periodically cycles between two frames.getFrame(int index) Returns the LEDAnimationFrame at an index.Returns the current frame of the LEDAnimation.static SimpleLEDAnimationgradientCascade(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.inthashCode()intReturns the number of frames the animation consists of.intReturns the number of pixels per each frame.
-
Constructor Details
-
SimpleLEDAnimation
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:LEDAnimationReturns the number of pixels per each frame.- Specified by:
numberOfPixelsPerFramein interfaceLEDAnimation- Returns:
- The expected number of pixels contained by every frame.
-
getNextFrame
Description copied from interface:LEDAnimationReturns the current frame of the LEDAnimation.- Specified by:
getNextFramein interfaceLEDAnimation- Returns:
- The LEDAnimation to display.
-
getFrame
Returns the LEDAnimationFrame at an index.- Parameters:
index- The index to sample.- Returns:
- The LEDAnimationFrame at that index.
-
gradientCascade
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
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
-
hashCode
public int hashCode()
-