private static void Wipe(WS281x controller, Color color) { for (int i = 0; i <= controller.GetController().LEDCount - 1; i++) { controller.SetLEDColor(0, i, color); controller.Render(); System.Threading.Thread.Sleep(1000 / 15); } }
private static void Wipe(WS281x device, Color color) { var controller = device.GetController(ControllerType.PWM0); for (int i = 0; i < controller.LEDCount; i++) { controller.SetLED(i, color); device.Render(); System.Threading.Thread.Sleep(1000 / 15); } }
private static void Wipe(WS281x device, Color color) { var controller = device.GetController(); foreach (var led in controller.LEDs) { led.Color = color; device.Render(); // wait for a minimum of 5 milliseconds var waitPeriod = (int)Math.Max(500.0 / controller.LEDCount, 5.0); Thread.Sleep(waitPeriod); } }
private static void Wipe(WS281x device, Color color) { var controller = device.GetController(); foreach (var led in controller.LEDs) { led.Color = color; device.Render(true); // by manipulating the LED directly instead of using the controller, the IsDirty state is lost. // nothing will get rendered // wait for a minimum of 5 milliseconds var waitPeriod = (int)Math.Max(500.0 / controller.LEDCount, 5.0); Thread.Sleep(waitPeriod); } }
public void Execute(AbortRequest request) { Console.Clear(); Console.Write("How many LEDs to you want to use: "); var ledCount = Int32.Parse(Console.ReadLine()); //The default settings uses a frequency of 800000 Hz and the DMA channel 10. var settings = Settings.CreateDefaultSettings(); //Set brightness to maximum (255) //Use Unknown as strip type. Then the type will be set in the native assembly. settings.Channels[0] = new Channel(ledCount, 18, 255, false, StripType.WS2812_STRIP); using (var controller = new WS281x(settings)) { var colors = GetAnimationColors(); while (!request.IsAbortRequested) { for (int i = 0; i <= controller.GetController().LEDCount - 1; i++) { var colorIndex = (i + colorOffset) % colors.Count; controller.SetLEDColor(0, i, colors[colorIndex]); } controller.Render(); if (colorOffset == int.MaxValue) { colorOffset = 0; } colorOffset++; System.Threading.Thread.Sleep(50); } } }