001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.led; 003 004/** 005 * Animation that gradually lights the entire LED strip one LED at a time. 006 */ 007public class ColorFlowAnimation extends BaseTwoSizeAnimation { 008 /** 009 * What direction does the color go 010 */ 011 public enum Direction { 012 /** 013 * Color goes forward, away from CANdle 014 */ 015 Forward(0), 016 /** 017 * Color goes backward, toward CANdle 018 */ 019 Backward(1); 020 021 final public int value; 022 023 Direction(int value) { 024 this.value = value; 025 } 026 } 027 028 /** 029 * Constructor for a ColorFlowAnimation 030 * @param r How much red should the color have [0, 255] 031 * @param g How much green should the color have [0, 255] 032 * @param b How much blue should the color have [0, 255] 033 * @param w How much white should the color have [0, 255] 034 * @param speed How fast should the color travel the strip [0, 1] 035 * @param numLed How many LEDs is the CANdle controlling 036 * @param direction What direction should the color move in 037 * @param ledOffset Where to start the animation 038 */ 039 public ColorFlowAnimation(int r, int g, int b, int w, double speed, int numLed, Direction direction, int ledOffset) { 040 super(0x62, r, g, b, w, speed, numLed, direction.value, 0, ledOffset); 041 } 042 /** 043 * Constructor for a ColorFlowAnimation 044 * @param r How much red should the color have [0, 255] 045 * @param g How much green should the color have [0, 255] 046 * @param b How much blue should the color have [0, 255] 047 * @param w How much white should the color have [0, 255] 048 * @param speed How fast should the color travel the strip [0, 1] 049 * @param numLed How many LEDs is the CANdle controlling 050 * @param direction What direction should the color move in 051 */ 052 public ColorFlowAnimation(int r, int g, int b, int w, double speed, int numLed, Direction direction) { 053 this(r, g, b, w, speed, numLed, direction, 0); 054 } 055 /** 056 * Constructor for a ColorFlowAnimation 057 * @param r How much red should the color have [0, 255] 058 * @param g How much green should the color have [0, 255] 059 * @param b How much blue should the color have [0, 255] 060 */ 061 public ColorFlowAnimation(int r, int g, int b) { 062 this(r, g, b, 0, 1, -1, Direction.Forward, 0); 063 } 064 065 /** 066 * Sets the direction the color flow moves in 067 * @param direction What direction should the color move in 068 */ 069 public void setDirection(Direction direction) { 070 setDirection(direction.value); 071 } 072}