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 SimpleLEDAnimation
cascading
(LEDAnimationFrame root) Statically constructs and returns a new SimpleLEDAnimation which offsets itself from an initial frame by one step each cycle.boolean
static SimpleLEDAnimation
flashing
(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 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.int
hashCode()
int
Returns the number of frames the animation consists of.int
Returns 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:LEDAnimation
Returns the number of pixels per each frame.- Specified by:
numberOfPixelsPerFrame
in interfaceLEDAnimation
- Returns:
- The expected number of pixels contained by every frame.
-
getNextFrame
Description copied from interface:LEDAnimation
Returns the current frame of the LEDAnimation.- Specified by:
getNextFrame
in 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()
-