Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputPin"></param>
        /// <param name="type"></param>
        /// <param name="debounceDuration">in milliseconds</param>
        public PushButton(H.Cpu.Pin inputPin, CircuitTerminationType type, int debounceDuration = 20)
        {
            this.DebounceDuration = new TimeSpan(0, 0, 0, 0, debounceDuration);

            // if we terminate in ground, we need to pull the port high to test for circuit completion, otherwise down.
            H.Port.ResistorMode resistorMode = H.Port.ResistorMode.Disabled;
            switch (type)
            {
            case CircuitTerminationType.CommonGround:
                resistorMode = H.Port.ResistorMode.PullUp;
                break;

            case CircuitTerminationType.High:
                resistorMode = H.Port.ResistorMode.PullDown;
                break;

            case CircuitTerminationType.Floating:
                resistorMode = H.Port.ResistorMode.Disabled;
                break;
            }

            // create the interrupt port from the pin and resistor type
            this.DigitalIn = new H.InterruptPort(inputPin, true, resistorMode, H.Port.InterruptMode.InterruptEdgeBoth);

            // wire up the interrupt handler
            this.DigitalIn.OnInterrupt += DigitalIn_OnInterrupt;
        }
Exemple #2
0
        public SpdtSwitch(H.Cpu.Pin pin)
        {
            H.Port.ResistorMode resistorMode = H.Port.ResistorMode.Disabled;

            this.DigitalIn = new H.InterruptPort(pin, true, resistorMode, H.Port.InterruptMode.InterruptEdgeBoth);

            this.DigitalIn.OnInterrupt += DigitalIn_OnInterrupt;
        }
        public SpstSwitch(H.Cpu.Pin pin, CircuitTerminationType type)
        {
            // if we terminate in ground, we need to pull the port high to test for circuit completion, otherwise down.
            H.Port.ResistorMode resistorMode = H.Port.ResistorMode.Disabled;
            switch (type)
            {
            case CircuitTerminationType.CommonGround:
                resistorMode = H.Port.ResistorMode.PullUp;
                break;

            case CircuitTerminationType.High:
                resistorMode = H.Port.ResistorMode.PullDown;
                break;

            case CircuitTerminationType.Floating:
                resistorMode = H.Port.ResistorMode.Disabled;
                break;
            }

            this.DigitalIn = new H.InterruptPort(pin, true, resistorMode, Microsoft.SPOT.Hardware.Port.InterruptMode.InterruptEdgeBoth);

            this.DigitalIn.OnInterrupt += DigitalIn_OnInterrupt;
        }