001package com.ctre.phoenix.led; 002 003/** 004 * The base class for all animations that CANdle supports. 005 */ 006public abstract class Animation { 007 private int animationIdx, numLed; 008 private double speed; 009 /** 010 * Constructor for an Animation class 011 * @param idx The animation-specific ID 012 * @param speed The rate at which the animation runs at. Higher is generally faster 013 * @param numLed The number of LEDs to run the animation on 014 */ 015 public Animation(int idx, double speed, int numLed) { 016 this.animationIdx = idx; 017 setSpeed(speed); 018 setNumLed(numLed); 019 } 020 /** 021 * Sets the speed of the animation 022 * @param speed The rate at which the animation runs at. Higher is generally faster 023 */ 024 public void setSpeed(double speed) { 025 if(speed > 1) speed = 1; 026 if(speed < 0) speed = 0; 027 this.speed = speed; 028 } 029 /** 030 * Sets the number of LEDs the animation will run on 031 * @param numLed The number of LEDs to run the animation on 032 */ 033 public void setNumLed(int numLed) { 034 if(numLed > 511) numLed = 511; 035 if(numLed < 0) numLed = 511; 036 this.numLed = numLed; 037 } 038 039 abstract BaseStandardAnimation getBaseStandardAnimation(); 040 abstract BaseTwoSizeAnimation getBaseTwoSizeAnimation(); 041 042 int getAnimationIdx() { return this.animationIdx; } 043 double getSpeed() { return this.speed; } 044 int getNumLed() { return this.numLed; } 045}