public static ws2811_channel_t ws2811_channel_get(ws2811_t ws, int channelnum) { global::System.IntPtr cPtr = rpi_ws281xPINVOKE.ws2811_channel_get(ws2811_t.getCPtr(ws), channelnum); ws2811_channel_t ret = (cPtr == global::System.IntPtr.Zero) ? null : new ws2811_channel_t(cPtr, false); return(ret); }
/// <summary> /// Initializes a new <see cref="Neopixel" /> instance. /// </summary> /// <param name="ledCount">The count of leds.</param> /// <param name="pin">The GPIO pin index connected to the display signal line.</param> /// <param name="stripType">The strip type to use.</param> /// <param name="frequency">The frequency of the display signal.</param> /// <param name="dma">The DMA channel to use.</param> /// <param name="invert">Whether the signal line should be inverted</param> /// <param name="brightness">The overall brightness.</param> /// <param name="channel">The PWM channel to use</param> public Neopixel(int ledCount, int pin, int stripType, uint frequency = 800000, int dma = 10, bool invert = false, byte brightness = 255, int channel = 0) { _leds = new ws2811_t(); // Initialize the channels to zero for (var i = 0; i < 2; i++) { var chan = rpi_ws281x.ws2811_channel_get(_leds, i); var chanRef = ws2811_channel_t.getCPtr(chan); rpi_ws281xPINVOKE.ws2811_channel_t_count_set(chanRef, 0); rpi_ws281xPINVOKE.ws2811_channel_t_gpionum_set(chanRef, 0); rpi_ws281xPINVOKE.ws2811_channel_t_invert_set(chanRef, 0); rpi_ws281xPINVOKE.ws2811_channel_t_brightness_set(chanRef, 0); } // Initialize the channel in use _channel = rpi_ws281x.ws2811_channel_get(_leds, channel); var channelRef = ws2811_channel_t.getCPtr(_channel); rpi_ws281xPINVOKE.ws2811_channel_t_count_set(channelRef, ledCount); rpi_ws281xPINVOKE.ws2811_channel_t_gpionum_set(channelRef, pin); rpi_ws281xPINVOKE.ws2811_channel_t_invert_set(channelRef, Convert.ToInt32(invert)); rpi_ws281xPINVOKE.ws2811_channel_t_brightness_set(channelRef, brightness); rpi_ws281xPINVOKE.ws2811_channel_t_strip_type_set(channelRef, stripType); // Initialize the controller var ledRef = ws2811_t.getCPtr(_leds); rpi_ws281xPINVOKE.ws2811_t_freq_set(ledRef, frequency); rpi_ws281xPINVOKE.ws2811_t_dmanum_set(ledRef, dma); //Grab the led data array. LedList = new LedList(_channel); }
/// <summary> /// Initialize the channel properties. /// </summary> /// <param name="channel">Channel to initialize.</param> /// <param name="channelSettings">Settings for the channel.</param> private void InitChannel(ref ws2811_channel_t channel, Channel channelSettings) { channel.count = channelSettings.Lights.Count; channel.gpionum = channelSettings.GpioPin; channel.brightness = channelSettings.Brightness; channel.invert = Convert.ToInt32(channelSettings.Invert); if (channelSettings.StripType != StripType.Unknown) { channel.strip_type = (int)channelSettings.StripType; } }
/// <summary> /// Initialize the channel properties. /// </summary> /// <param name="channel">Channel to initialize.</param> /// <param name="channelSettings">Settings for the channel.</param> private void InitChannel(ref ws2811_channel_t channel, Channel channelSettings) { channel.count = channelSettings.LEDCount; channel.gpionum = channelSettings.GPIOPin; channel.brightness = channelSettings.Brightness; channel.invert = Convert.ToInt32(channelSettings.Invert); if (channelSettings.StripType != StripType.Unknown) { //Strip type is set by the native assembly if not explicitly set. //This type defines the ordering of the colors e. g. RGB or GRB, ... channel.strip_type = (int)channelSettings.StripType; } }
/// <summary> /// Initialize the channel propierties /// </summary> /// <param name="channelIndex">Index of the channel tu initialize</param> /// <param name="settings">Controller Settings</param> private ws2811_channel_t InitChannel(int channelIndex, Settings settings) { ws2811_channel_t channel = new ws2811_channel_t(); if (settings.Controllers.ContainsKey(channelIndex)) { channel.count = settings.Controllers[channelIndex].LEDCount; channel.gpionum = settings.Controllers[channelIndex].GPIOPin; channel.brightness = settings.Controllers[channelIndex].Brightness; channel.invert = Convert.ToInt32(settings.Controllers[channelIndex].Invert); if (settings.Controllers[channelIndex].StripType != StripType.Unknown) { //Strip type is set by the native assembly if not explicitly set. //This type defines the ordering of the colors e. g. RGB or GRB, ... channel.strip_type = (int)settings.Controllers[channelIndex].StripType; } } return(channel); }
/// <summary> /// Initializes a new instance <see cref="LedList" /> instance. /// </summary> /// <param name="channel"></param> public LedList(ws2811_channel_t channel) { _channel = channel; }
public static int ws2811_led_set(ws2811_channel_t channel, int lednum, uint color) { int ret = rpi_ws281xPINVOKE.ws2811_led_set(ws2811_channel_t.getCPtr(channel), lednum, color); return(ret); }
public static uint ws2811_led_get(ws2811_channel_t channel, int lednum) { uint ret = rpi_ws281xPINVOKE.ws2811_led_get(ws2811_channel_t.getCPtr(channel), lednum); return(ret); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ws2811_channel_t obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }