/// <summary> /// Creates an OPC Pixel Frame from a list of LEDs. /// </summary> /// <param name="channel">Channel this frame will be sent to.</param> /// <param name="leds">List of LEDs to map.</param> public static OPCPixelFrame CreateFromLEDs(byte channel, IList <IFadeCandyPixelContainer> leds) { var data = new byte[leds.Count * 3]; foreach (IFadeCandyPixelContainer led in leds) { data[led.FadeCandyPixel.RedIndex] = led.Color.R; data[led.FadeCandyPixel.GreenIndex] = led.Color.G; data[led.FadeCandyPixel.BlueIndex] = led.Color.B; } var returnValue = new OPCPixelFrame(channel, data); return(returnValue); }
/// <summary> /// Sends a list of LEDs to the connected FadeCandy board. /// </summary> public override void SendLEDs(IList <ILightingControllerPixel> leds) { OPCPixelFrame.CreateChannelBurstFromLEDs(leds.Cast <IFadeCandyPixelContainer>().ToList()).ToList().ForEach(SendPixelFrame); }