コード例 #1
0
        /// <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();
        }
コード例 #2
0
ファイル: Ic74HC165.cs プロジェクト: riotgibbon/netduino
        /// <summary>
        /// Initialises a chain of one or multiple parallel to serial ICs over managed SPI
        /// </summary>
        /// <param name="SPI_Module">The SPI interface it's connected to</param>
        /// <param name="LatchPin">The slave select pin connected to the IC(s)</param>
        /// <param name="Bytes">The amount of 8-bit IC(s) connected</param>
        /// <param name="SpeedKHz">The max. SPI speed</param>
        public Ic74hc165(SPI.SPI_module SPI_Module, Cpu.Pin LatchPin, uint Bytes = 1, uint SpeedKHz = 1000)
        {
            // Full SPI configuration
            this._SpiInterface = new MultiSPI(new SPI.Configuration(
                                                  ChipSelect_Port: LatchPin,
                                                  ChipSelect_ActiveState: true,
                                                  ChipSelect_SetupTime: 0,
                                                  ChipSelect_HoldTime: 0,
                                                  Clock_IdleState: true,
                                                  Clock_Edge: false,
                                                  Clock_RateKHz: SpeedKHz,
                                                  SPI_mod: SPI_Module
                                                  ));

            // The amount of ICs
            this._Init(Bytes);
        }
コード例 #3
0
        /// <summary>
        /// Initialises a chain of one or multiple parallel to serial ICs over managed SPI
        /// </summary>
        /// <param name="SPI_Module">The SPI interface it's connected to</param>
        /// <param name="LatchPin">The slave select pin connected to the IC(s)</param>
        /// <param name="Bytes">The amount of 8-bit IC(s) connected</param>
        /// <param name="SpeedKHz">The max. SPI speed</param>
        public Ic74hc165(SPI.SPI_module SPI_Module, Cpu.Pin LatchPin, uint Bytes = 1, uint SpeedKHz = 1000)
        {
            // Full SPI configuration
            this._SpiInterface = new MultiSPI(new SPI.Configuration(
                ChipSelect_Port: LatchPin,
                ChipSelect_ActiveState: true,
                ChipSelect_SetupTime: 0,
                ChipSelect_HoldTime: 0,
                Clock_IdleState: true,
                Clock_Edge: false,
                Clock_RateKHz: SpeedKHz,
                SPI_mod: SPI_Module
            ));

            // The amount of ICs
            this._Init(Bytes);
        }
コード例 #4
0
ファイル: Lpd8806Chain.cs プロジェクト: riotgibbon/netduino
        /// <summary>
        /// Defines a chain of LPD8806-driven RGB LEDs
        /// </summary>
        /// <param name="LedCount">The amount of LEDs in the chain (2 per IC)</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 Lpd8806Chain(int LedCount, SPI.SPI_module SPI_Device, Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState)
        {
            // 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: 10000,
                                          SPI_mod: SPI_Device
                                          ));

            // Stores the amount of LEDs
            this.LedCount = LedCount;

            // 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];

            // Turns off all LEDs
            this.ConfigureAll(0, true);
        }
コード例 #5
0
        /// <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();
        }