Hello,
I have a curious issue: a button is connect on socket 7, and a breadboard on socket 6. I test interrupt with the button on breadboard (wired to pin3). Interrupt works perfectly.
The button on socket 7 raise the interrupt (but just on falling edge): why ?
I must forget something, but I can find it !
public partial class Program
{
private bool _bMainboardLed;
private bool _bBreadBoardLed;
private DigitalOutput _doBreadboardLed;
private InterruptInput _iiBreadbordButton;
private InterruptPort _breadboardButtonInterruptPort;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
_bMainboardLed = false;
Mainboard.SetDebugLED(_bMainboardLed);
Debug.Print("Program Started");
// Configure button behavior
button.Mode=Button.LedMode.OnWhilePressed;
button.ButtonPressed += button_ButtonPressed;
// Configure Breadboard Input/Output
_bBreadBoardLed = false;
// Led connected on port 4 as digital output
_doBreadboardLed = breadBoardX1.CreateDigitalOutput(GT.Socket.Pin.Four, _bBreadBoardLed);
// Button connected on port 3 as digital input/interruption
_iiBreadbordButton = breadBoardX1.CreateInterruptInput(GT.Socket.Pin.Three, GlitchFilterMode.On, ResistorMode.PullUp,
InterruptMode.RisingAndFallingEdge);
_iiBreadbordButton.Interrupt += _iiBreadbordButton_Interrupt;
FlashMainboardLed();
}
void _iiBreadbordButton_Interrupt(InterruptInput sender, bool value)
{
Debug.Print(sender.ToString()+","+value);
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
_doBreadboardLed.Write(!_doBreadboardLed.Read());
}
private void FlashMainboardLed()
{
var tMainboard = new Thread(() =>
{
for (int i = 0; i < 5; i++)
{
_bMainboardLed = !_bMainboardLed;
Mainboard.SetDebugLED(_bMainboardLed);
Thread.Sleep(100);
}
});
tMainboard.Start();
}
}