/// <summary> /// Creates a new DipSwitch connected to an array of Interrupt Ports /// </summary> /// <param name="interruptPorts"></param> public DipSwitch(IDigitalInputPort[] 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); } }
/// <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(IIODevice device, IPin[] switchPins, InterruptMode interruptMode, ResistorMode resistorMode, int debounceDuration = 20, int glitchFilterCycleCount = 0) { Switches = new ISwitch[switchPins.Length]; for (int i = 0; i < switchPins.Length; i++) { Switches[i] = new SpstSwitch(device, switchPins[i], interruptMode, resistorMode, debounceDuration, glitchFilterCycleCount); int index = i; Switches[i].Changed += (s, e) => HandleSwitchChanged(index); } }