Main Site Documentation

Interruption event


#1

how do I stop an interrupt event?
I need that when I press the button, my gadgeteer feel just a press of the button and not 3 or 4, because otherwise I run 3 or 4 times my interrupt.
Thanks all

button = new GT.Interfaces.InterruptInput(socket6, GT.Socket.Pin.Six, GT.Interfaces.GlitchFilterMode.On, GT.Interfaces.ResistorMode.Disabled, GT.Interfaces.InterruptMode.RisingEdge, null);

button.Interrupt += new GT.Interfaces.InterruptInput.InterruptEventHandler(button_Interrupt);

void button_Interrupt(GT.Interfaces.InterruptInput sender, bool value)
        {
            Debug.Print("hello!!! ");
        } 



#2

that is the function of the glitch filter. The “problem” is that switches like push buttons are inherently “noisy” so are always prone to give you multiple interrupts. There are many approaches to deal with this, here’s a very authoritative source on the topic: http://www.ganssle.com/debouncing.htm

For me, if I wasn’t going to do a hardware fix, I’d simply manage a state variable and a time of change, and confirm the state hasn’t changed too quickly after the last change. But an equally valid test is to read the button’s state in the event handler and if it isn’t the same as the state that the handler detected, you can throw the sample away until they match.