/// <summary> /// Defines a chain of RGB LEDs /// </summary> /// <param name="Chipset">The chipset used to daisychain the LEDs</param> /// <param name="LedCount">The amount of LEDs in the chain</param> /// <param name="SPI_Device">The SPI bus the chain is connected to</param> /// <param name="ChipSelect_Port">If there's a CS circuitry, specify it's pin</param> /// <param name="ChipSelect_ActiveState">If there's a CS circuitry, specify it's active state</param> public RgbLedStrip(Chipsets Chipset, int LedCount, SPI.SPI_module SPI_Device, Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState) { // The used chipset this._Chipset = Chipset; // Stores the amount of LEDs this.LedCount = LedCount; // Extends the arrays for the LED states and brightness this._LedState = new byte[LedCount * 3]; this._Brightness = new byte[LedCount]; // Settings for the LPD8806 chip if (Chipset == Chipsets.LPD8806) { // Creates a new buffer (final 3 bytes should always be 0 and tells the chain we're done for now) this._Buffer = new byte[LedCount * 3 + 3]; // Default sequence of the Adafruit strips this.Sequence = Sequences.GRB; } // Settings for the WS2801 chip if (Chipset == Chipsets.WS2801) { // Creates a new buffer this._Buffer = new byte[LedCount * 3]; // Default sequence of the Adafruit chains this.Sequence = Sequences.RGB; } // Configures the SPI bus this._Conn = new MultiSPI(new SPI.Configuration( ChipSelect_Port: ChipSelect_Port, ChipSelect_ActiveState: ChipSelect_ActiveState, ChipSelect_SetupTime: 0, ChipSelect_HoldTime: 0, Clock_IdleState: false, Clock_Edge: true, Clock_RateKHz: 1000, SPI_mod: SPI_Device )); // Set brightness only half way, most LED strips are just way too bright imho this.SetBrightnessAll(128); // Turns off all LEDs this.SetColorAll(0); // Writes for the first time this.Write(); }
/// <summary> /// Defines a chain of RGB LEDs /// </summary> /// <param name="Chipset">The chipset used to daisychain the LEDs</param> /// <param name="LedCount">The amount of LEDs in the chain</param> /// <param name="SPI_Device">The SPI bus the chain is connected to</param> public RgbLedStrip(Chipsets Chipset, int LedCount, SPI.SPI_module SPI_Device) : this(Chipset, LedCount, SPI_Device, Cpu.Pin.GPIO_NONE, false) { }