Exemple #1
0
 private static void HaltActivity(LED_Queue QueueToModify, bool ForceQueueCleanup = false)
 {
     if (Actinic_Lights_Queue == null)
         return;
     if (ForceQueueCleanup) {
         QueueToModify.ClearQueue ();
     }
     if (QueueToModify.AnimationActive)
         Animation_Stop (QueueToModify);
 }
Exemple #2
0
        /// <summary>
        /// Add the collection of LEDs to the queue, automatically smoothly transitioning into it.
        /// </summary>
        /// <param name="QueueToModify">Queue to add animation to</param>
        /// <param name="LED_Collection">Desired LED appearance</param>
        private static void AddToAnimQueue(LED_Queue QueueToModify, List<LED> LED_Collection)
        {
            if (QueueToModify.QueueCount > 0 && Command_ConflictsExpected == false)
                Console.WriteLine ("(Warning: interrupting fade, appearance may vary.  If intended, prefix with '!')");
            // Don't warn about clearing the output queue if it's expected by running multiple commands at once

            QueueToModify.ClearQueue ();
            if (Animation_Fading_Enabled) {
                double Avg_OldPercent = Math.Min (Animation_Smoothing_Percentage_DEFAULT, 1);
                double Avg_NewPercent = Math.Max (1 - Animation_Smoothing_Percentage_DEFAULT, 0);
                List<LED> LED_Intermediate = new List<LED> ();
                lock (QueueToModify.LightsLastProcessed) {
                    for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) {
                        LED_Intermediate.Add (new LED (QueueToModify.LightsLastProcessed [i].R, QueueToModify.LightsLastProcessed [i].G, QueueToModify.LightsLastProcessed [i].B, QueueToModify.LightsLastProcessed [i].Brightness));
                    }
                }
                for (int i_fades = 0; i_fades < Animation_Smoothing_Iterations_DEFAULT; i_fades++) {
                    for (int i = 0; i < LightSystem.LIGHT_COUNT; i++) {
                        LED_Intermediate [i].R = (byte)((LED_Collection [i].R * Avg_NewPercent) + (LED_Intermediate [i].R * Avg_OldPercent));
                        LED_Intermediate [i].G = (byte)((LED_Collection [i].G * Avg_NewPercent) + (LED_Intermediate [i].G * Avg_OldPercent));
                        LED_Intermediate [i].B = (byte)((LED_Collection [i].B * Avg_NewPercent) + (LED_Intermediate [i].B * Avg_OldPercent));
                        LED_Intermediate [i].Brightness = (byte)((LED_Collection [i].Brightness * Avg_NewPercent) + (LED_Intermediate [i].Brightness * Avg_OldPercent));
                    }
                    QueueToModify.PushToQueue (LED_Intermediate);
                }
                // Just in case the fade did not finish completely, ensure the desired state is sent, too
                QueueToModify.PushToQueue (LED_Collection);
            } else {
                QueueToModify.PushToQueue (LED_Collection);
            }
        }