Toolbox.NETMF.Hardware.IIRQPort


This is a generic interface used by multiplex classes in the .NETMF Toolbox.
It inherits everything from IGPIPort and adds interrupts as extra.
If you want to use this interface directly, I suggest to use the Toolbox.NETMF.Hardware.IntegratedIRQ class.

Methods

  • Read() Returns the current value, true for high, false for low.
  • Dispose() Releases the SPI pins (when using the bitbang constructor)

Properties

  • ID Gives the port it's own name
  • InvertReadings When true, this.Read() is inverted

Event

  • OnStateChange Triggered when the pin state changes

Sample code in C#

static IIRQPort Pin = new IntegratedIRQ(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);

public static void Main()
{
    Pin.ID = "Onboard button";
    Pin.OnStateChange += new StateChange(Pin_OnStateChange);

    Thread.Sleep(Timeout.Infinite);
}

static void Pin_OnStateChange(IIRQPort Object, bool State, DateTime Time)
{
    Debug.Print("State of button " + Object.ID + " changed to " + State.ToString());
}

Sample code in VB

Dim WithEvents Pin As IIRQPort = New IntegratedIRQ(Pins.ONBOARD_BTN, False, Port.ResistorMode.Disabled)

Sub Main()
    Pin.ID = "Onboard button"

    Thread.Sleep(Timeout.Infinite)
End Sub

Private Sub Pin_OnStateChange(ByVal PinObject As Toolbox.NETMF.Hardware.IIRQPort, ByVal State As Boolean, ByVal Time As Date) Handles Pin.OnStateChange
    Debug.Print("State of button " + PinObject.ID + " changed to " + State.ToString())
End Sub

Last edited Dec 29, 2012 at 6:43 AM by Garrcomm, version 2