示例#1
0
        public static void Main()
        {
            // Defining two 74HC165s daisychained on the SPI bus, pin 10 as latchpin
            Ic74hc165 IcInChain = new Ic74hc165(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2);

            // Defining two 74HC595s daisychained on the SPI bus, pin 9 as latchpin
            Ic74hc595 IcOutChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D9, 2);

            // Defines all 16 leds
            for (uint Counter = 0; Counter < 16; ++Counter)
            {
                Leds[Counter] = IcOutChain.Pins[Counter];
            }

            // Defines all 16 buttons
            IIRQPort[] Buttons = new IIRQPort[16];
            for (uint Counter = 0; Counter < 16; ++Counter)
            {
                Buttons[Counter] = IcInChain.Pins[Counter];
                Buttons[Counter].OnStateChange += new StateChange(Program_OnStateChange);
                Buttons[Counter].ID = Counter.ToString();
            }

            // Enables interrupts
            IcInChain.EnableInterrupts();

            // Wait infinite; let the events to their jobs
            Thread.Sleep(Timeout.Infinite);
        }
示例#2
0
 /// <summary>
 /// Defines a GPO Port
 /// </summary>
 /// <param name="MainChain">The object of the main chain</param>
 /// <param name="BitNo">The number of the bit</param>
 public Ic74hc165IRQPort(Ic74hc165 MainChain, uint BitNo)
 {
     // Copies the parameters to local values
     this._Chain     = MainChain;
     this._BitNo     = BitNo;
     this._LastValue = this.Read();
 }
示例#3
0
 /// <summary>
 /// Defines a GPO Port
 /// </summary>
 /// <param name="MainChain">The object of the main chain</param>
 /// <param name="BitNo">The number of the bit</param>
 public Ic74hc165IRQPort(Ic74hc165 MainChain, uint BitNo)
 {
     // Copies the parameters to local values
     this._Chain = MainChain;
     this._BitNo = BitNo;
     this._LastValue = this.Read();
 }