001package com.ctre.phoenix.led;
002
003/**
004 * Animation that sends a pocket of light across the LED strip.
005 */
006public class LarsonAnimation extends BaseTwoSizeAnimation {
007    /**
008     * How the pocket of light behaves when it reaches the end of the strip
009     */
010    public enum BounceMode {
011        /**
012         * Bounce the pocket as soon as the first LED reaches the end of the strip
013         */
014        Front(0),
015        /**
016         * Bounce the pocket once it is midway through the end of the strip
017         */
018        Center(1),
019        /**
020         * Bounce the pocket once all the LEDs are off the strip
021         */
022        Back(2);
023
024        final public int value;
025
026        BounceMode(int value) {
027            this.value = value;
028        }
029    }
030    /**
031     * Constructor for a LarsonAnimation
032     * @param r How much red should the color have [0, 255]
033     * @param g How much green should the color have [0, 255]
034     * @param b How much blue should the color have [0, 255]
035     * @param w How much white should the color have [0, 255]
036     * @param speed How fast should the color travel the strip [0, 1]
037     * @param numLed The number of LEDs the CANdle will control
038     * @param mode How the pocket of LEDs will behave once it reaches the end of the strip
039     * @param size How large the pocket of LEDs are [0, 7]
040     */
041    public LarsonAnimation(int r, int g, int b, int w, double speed, int numLed, BounceMode mode, int size) {
042        super(0x61, r, g, b, w, speed, numLed, mode.value, size);
043    }
044    /**
045     * Constructor for a LarsonAnimation
046     * @param r How much red should the color have [0, 255]
047     * @param g How much green should the color have [0, 255]
048     * @param b How much blue should the color have [0, 255]
049     */
050    public LarsonAnimation(int r, int g, int b) {
051        this(r, g, b, 0, 1, -1, BounceMode.Front, 2);
052    }
053
054    /**
055     * Sets the bounce mode of the animation.
056     * @param mode How the pocket of LEDs will behave once it reaches the end of the strip
057     */
058    public void setBounceMode(BounceMode mode) {
059        setDirection(mode.value);
060    }
061    
062    /**
063     * Sets the size of the pocket of LEDs
064     * @param size The size of the pocket [0, 7]
065     */
066    public void setSize(int size) {
067        super.setSize(size);
068    }
069}