001package com.ctre.phoenix.led; 002 003/** 004 * Animation that randomly turns on LEDs, until it reaches the maximum count and turns them all off 005 */ 006public class TwinkleOffAnimation extends BaseTwoSizeAnimation { 007 /** 008 * The maximum percentage of LEDs that are allowed to turn on 009 */ 010 public enum TwinkleOffPercent { 011 /** 012 * All the LEDs are allowed to turn on 013 */ 014 Percent100(0), 015 /** 016 * 88% of LEDs are allowed to turn on 017 */ 018 Percent88(1), 019 /** 020 * 76% of LEDs are allowed to turn on 021 */ 022 Percent76(2), 023 /** 024 * 64% of LEDs are allowed to turn on 025 */ 026 Percent64(3), 027 /** 028 * 42% of LEDs are allowed to turn on 029 */ 030 Percent42(4), 031 /** 032 * 30% of LEDs are allowed to turn on 033 */ 034 Percent30(5), 035 /** 036 * 18% of LEDs are allowed to turn on 037 */ 038 Percent18(6), 039 /** 040 * 6% of LEDs are allowed to turn on 041 */ 042 Percent6(7); 043 044 final public int value; 045 046 TwinkleOffPercent(int value) { 047 this.value = value; 048 } 049 } 050 051 /** 052 * Constructor for a TwinkleAnimation 053 * @param r How much red should the color have [0, 255] 054 * @param g How much green should the color have [0, 255] 055 * @param b How much blue should the color have [0, 255] 056 * @param w How much white should the color have [0, 255] 057 * @param speed How fast should the color travel the strip [0, 1] 058 * @param numLed How many LEDs the CANdle controls 059 * @param divider What percentage of LEDs can be on at any point 060 */ 061 public TwinkleOffAnimation(int r, int g, int b, int w, double speed, int numLed, TwinkleOffPercent divider) { 062 super(0x68, r, g, b, w, speed, numLed, 0, divider.value); 063 } 064 /** 065 * Constructor for a TwinklOffeAnimation 066 * @param r How much red should the color have [0, 255] 067 * @param g How much green should the color have [0, 255] 068 * @param b How much blue should the color have [0, 255] 069 */ 070 public TwinkleOffAnimation(int r, int g, int b) { 071 this(r, g, b, 0, 1, -1, TwinkleOffPercent.Percent100); 072 } 073 /** 074 * Sets the percentage of LEDs that are allowed on 075 * @param divider The percentage of LEDs that are allowed on at any point 076 */ 077 public void setDivider(TwinkleOffPercent divider) { 078 setSize(divider.value); 079 } 080}