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