示例#1
0
 private void SetTempValue(AnimatedLed led, double temp)
 {
     // Fade between blue and red.
     double blue = 1 - temp;
     double red = temp;
     led.Animate(red, 0, blue, 1, TimeSpan.FromSeconds(1), AnimationType.Linear);
 }
示例#2
0
 private void SetWindValue(AnimatedLed led, double wind)
 {
     // Fade from blue to white.
     led.Animate(wind, wind, 1.0, 1, TimeSpan.FromSeconds(1), AnimationType.Linear);
 }
示例#3
0
        private void SetColor(AnimatedLed led, double value, TimeSpan time)
        {
            double red = 0, green = 0, blue = 0;

            // Wrap the value if we hit 1.
            if (value == 1)
            {
                value = 0;
            }

            // Find what bucket we are in
            int rangeBot = (int)Math.Floor(((value) * m_blueRange.Length));
            int rangeTop = rangeBot + 1;
            if (rangeTop == m_blueRange.Length)
            {
                rangeTop = 0;
            }

            // Find where we are in that bucket-
            double placeInRange = ((value * m_blueRange.Length * m_blueRange.Length) % m_blueRange.Length) / 6.0;
            if(value == 1.0)
            {
                // Special case
                placeInRange = 1;
            }

            // Find the values per color
            red = m_redRange[rangeBot] + (m_redRange[rangeTop] - m_redRange[rangeBot]) * placeInRange;
            green = m_greenRange[rangeBot] + (m_greenRange[rangeTop] - m_greenRange[rangeBot]) * placeInRange;
            blue = m_blueRange[rangeBot] + (m_blueRange[rangeTop] - m_blueRange[rangeBot]) * placeInRange;

            // Animate the LED
            led.Animate(red, green, blue, 1.0, time, AnimationType.Linear);
        }