예제 #1
0
        public static void CometMode(List <LEDBulb> Comet)
        {
            for (int i = 0; i < LEDs.Count; i++)
            {
                LEDs[i] = new LEDBulb(Effects.Colors[0]);
            }

            Random r = new Random();
            int    initialPosition = r.Next(App.settings.Length, Effects.LEDs.Count - App.settings.Length);

            LEDs.InsertRange(initialPosition, Comet); //Insert the comet array on the list of LEDs
            Thread.Sleep(App.settings.Speed);

            int steps;

            steps = LEDs.Count - initialPosition;

            for (int i = 0; i < Comet.Count; i++) //Remove the excess of LEDs
            {
                LEDs.RemoveAt(LEDs.Count - 1);
            }

            if (initialPosition > (LEDs.Count / 2))
            {
                for (int i = initialPosition; i < LEDs.Count; i++)
                {
                    ShiftRight();

                    if (i + Comet.Count > LEDs.Count)
                    {
                        LEDs[i] = Colors[0];
                    }

                    Thread.Sleep(App.settings.Speed);
                }
            }
            else
            {
                for (int i = initialPosition; i < LEDs.Count; i++)
                {
                    ShiftLeft();

                    if (i + Comet.Count > LEDs.Count)
                    {
                        LEDs[i] = Colors[0];
                    }

                    Thread.Sleep(App.settings.Speed);
                }
            }
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="origin"></param>
 public LEDBulb(LEDBulb origin)
 {
     this.r = origin.r;
     this.g = origin.g;
     this.b = origin.b;
 }