001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.led; 003 004/** 005 * The base class for all animations that CANdle supports. 006 * 007 * @deprecated This device's Phoenix 5 API is deprecated for removal in the 008 * 2027 season. Users should update to Phoenix 6 firmware and migrate to the 009 * Phoenix 6 API. A migration guide is available at 010 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html. 011 * <p> 012 * If the Phoenix 5 API must be used for this device, the device must have 22.X 013 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in 014 * the firmware year dropdown. 015 */ 016@Deprecated(since = "2026", forRemoval = true) 017public abstract class Animation { 018 private int animationIdx, numLed, ledOffset; 019 private double speed; 020 /** 021 * Constructor for an Animation class 022 * @param idx The animation-specific ID 023 * @param speed The rate at which the animation runs at. Higher is generally faster 024 * @param numLed The number of LEDs to run the animation on 025 * @param ledOffset Where to start the animation 026 */ 027 public Animation(int idx, double speed, int numLed, int ledOffset) { 028 this.animationIdx = idx; 029 setSpeed(speed); 030 setNumLed(numLed); 031 setLedOffset(ledOffset); 032 } 033 /** 034 * Sets the speed of the animation 035 * @param speed The rate at which the animation runs at. Higher is generally faster 036 */ 037 public void setSpeed(double speed) { 038 if(speed > 1) speed = 1; 039 if(speed < 0) speed = 0; 040 this.speed = speed; 041 } 042 /** 043 * Sets the number of LEDs the animation will run on 044 * @param numLed The number of LEDs to run the animation on 045 */ 046 public void setNumLed(int numLed) { 047 if(numLed > 511) numLed = 511; 048 if(numLed < 0) numLed = 511; 049 this.numLed = numLed; 050 } 051 /** 052 * Sets where the animation will start along the LED strip 053 * @param ledOffset Where to start the animation 054 */ 055 public void setLedOffset(int ledOffset) { 056 if(ledOffset > 511) ledOffset = 511; 057 if(ledOffset < 0) ledOffset = 511; 058 this.ledOffset = ledOffset; 059 } 060 061 abstract BaseStandardAnimation getBaseStandardAnimation(); 062 abstract BaseTwoSizeAnimation getBaseTwoSizeAnimation(); 063 064 int getAnimationIdx() { return this.animationIdx; } 065 double getSpeed() { return this.speed; } 066 int getNumLed() { return this.numLed; } 067 int getLedOffset() { return this.ledOffset; } 068}