/// <summary> /// Fade out strip with a color /// </summary> /// <param name="strip">Strip of LEDs</param> /// <param name="delay">Delay of effect</param> /// <param name="brightness">Brightness of LEDs</param> /// <param name="red">Value of red for LEDs color</param> /// <param name="green">Value of green for LEDs color</param> /// <param name="blue">Value of blue for LEDs color</param> public static void FadeOut(this LedStrip strip, int delay, byte brightness, byte red, byte green, byte blue) { for (int k = 255; k > -1; k--) { strip.SetAll(brightness, (byte)(red * k / 255), (byte)(green * k / 255), (byte)(blue * k / 255)); strip.Show(); Thread.Sleep(delay); } }
/// <summary> /// Turn on random led with random color /// </summary> /// <param name="strip">Strip of LEDs</param> /// <param name="delay">Delay of effect</param> /// <param name="brightness">Brightness of LEDs</param> /// <param name="count">Number of LEDs to turn on</param> public static void TwinkleRandom(this LedStrip strip, int delay, byte brightness, int count) { strip.SetAll(brightness, 0, 0, 0); for (int i = 0; i < count; i++) { strip.SetPixel(Random.Next(strip.Size), brightness, (byte)Random.Next(255), (byte)Random.Next(255), (byte)Random.Next(255)); strip.Show(); Thread.Sleep(delay); } Thread.Sleep(delay); }