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); }
public LedController() { // Create the controller m_controller = new TLC5947Controller(6, 13); m_controller.ToggleAnimation(true); // Create the LED array m_leds = new AnimatedLed[5]; // Create the LEDs m_leds[0] = new AnimatedLed(LedType.RBG, true); m_leds[1] = new AnimatedLed(LedType.RBG, true); m_leds[2] = new AnimatedLed(LedType.RBG, true); m_leds[3] = new AnimatedLed(LedType.RBG, true); m_leds[4] = new AnimatedLed(LedType.RBG, true); // Associate the LEDs m_controller.AssoicateLed(0, m_leds[0].GetLed()); m_controller.AssoicateLed(3, m_leds[1].GetLed()); m_controller.AssoicateLed(6, m_leds[2].GetLed()); m_controller.AssoicateLed(9, m_leds[3].GetLed()); m_controller.AssoicateLed(15, m_leds[4].GetLed()); }
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); }
private void SetWindValue(AnimatedLed led, double wind) { // Fade from blue to white. led.Animate(wind, wind, 1.0, 1, TimeSpan.FromSeconds(1), AnimationType.Linear); }