001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.led; 003 004/** 005 * Animation that sends a pocket of light across the LED strip. 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 class LarsonAnimation extends BaseTwoSizeAnimation { 018 /** 019 * How the pocket of light behaves when it reaches the end of the strip 020 */ 021 public enum BounceMode { 022 /** 023 * Bounce the pocket as soon as the first LED reaches the end of the strip 024 */ 025 Front(0), 026 /** 027 * Bounce the pocket once it is midway through the end of the strip 028 */ 029 Center(1), 030 /** 031 * Bounce the pocket once all the LEDs are off the strip 032 */ 033 Back(2); 034 035 final public int value; 036 037 BounceMode(int value) { 038 this.value = value; 039 } 040 } 041 /** 042 * Constructor for a LarsonAnimation 043 * @param r How much red should the color have [0, 255] 044 * @param g How much green should the color have [0, 255] 045 * @param b How much blue should the color have [0, 255] 046 * @param w How much white should the color have [0, 255] 047 * @param speed How fast should the color travel the strip [0, 1] 048 * @param numLed The number of LEDs the CANdle will control 049 * @param mode How the pocket of LEDs will behave once it reaches the end of the strip 050 * @param size How large the pocket of LEDs are [0, 7] 051 * @param ledOffset Where to start the animation 052 */ 053 public LarsonAnimation(int r, int g, int b, int w, double speed, int numLed, BounceMode mode, int size, int ledOffset) { 054 super(0x61, r, g, b, w, speed, numLed, mode.value, size, ledOffset); 055 } 056 /** 057 * Constructor for a LarsonAnimation 058 * @param r How much red should the color have [0, 255] 059 * @param g How much green should the color have [0, 255] 060 * @param b How much blue should the color have [0, 255] 061 * @param w How much white should the color have [0, 255] 062 * @param speed How fast should the color travel the strip [0, 1] 063 * @param numLed The number of LEDs the CANdle will control 064 * @param mode How the pocket of LEDs will behave once it reaches the end of the strip 065 * @param size How large the pocket of LEDs are [0, 7] 066 */ 067 public LarsonAnimation(int r, int g, int b, int w, double speed, int numLed, BounceMode mode, int size) { 068 this(r, g, b, w, speed, numLed, mode, size, 0); 069 } 070 /** 071 * Constructor for a LarsonAnimation 072 * @param r How much red should the color have [0, 255] 073 * @param g How much green should the color have [0, 255] 074 * @param b How much blue should the color have [0, 255] 075 */ 076 public LarsonAnimation(int r, int g, int b) { 077 this(r, g, b, 0, 1, -1, BounceMode.Front, 2, 0); 078 } 079 080 /** 081 * Sets the bounce mode of the animation. 082 * @param mode How the pocket of LEDs will behave once it reaches the end of the strip 083 */ 084 public void setBounceMode(BounceMode mode) { 085 setDirection(mode.value); 086 } 087 088 /** 089 * Sets the size of the pocket of LEDs 090 * @param size The size of the pocket [0, 7] 091 */ 092 public void setSize(int size) { 093 super.setSize(size); 094 } 095}