Exemple #1
0
        /// <summary>
        /// Creates a new DipSwitch connected to an array of Interrupt Ports
        /// </summary>
        /// <param name="interruptPorts"></param>
        public DipSwitch(GpioPin[] interruptPorts)
        {
            Switches = new ISwitch[interruptPorts.Length];

            for (int i = 0; i < interruptPorts.Length; i++)
            {
                Switches[i] = new SpstSwitch(interruptPorts[i]);
                int index = i;
                Switches[i].Changed += (s, e) => HandleSwitchChanged(index);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new DipSwitch connected to the specified switchPins, with the InterruptMode and ResisterMode specified by the type parameters.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="switchPins"></param>
        /// <param name="interruptMode"></param>
        /// <param name="resistorMode"></param>
        /// <param name="debounceDuration"></param>
        /// <param name="glitchFilterCycleCount"></param>
        public DipSwitch(int[] switchPins, GpioPinEdge interruptMode, GpioPinDriveMode resistorMode, int debounceDuration = 20, int glitchFilterCycleCount = 0)
        {
            Switches = new ISwitch[switchPins.Length];

            for (int i = 0; i < switchPins.Length; i++)
            {
                Switches[i] = new SpstSwitch(switchPins[i], interruptMode, resistorMode, debounceDuration, glitchFilterCycleCount);
                int index = i;
                Switches[i].Changed += (s, e) => HandleSwitchChanged(index);
            }
        }