Toolbox.NETMF.Hardware.AutoRepeatInputPort

Toolbox.NETMF.Hardware.AutoRepeatInputPort(port, resistor, activeLevel)

  • port The I/O pin selected for the input
  • resistor The resistor for wired-logic easing
  • activeLevel The level on which the input has to be considered active

Properties

  • ActiveLevel Gets the active level defined for this instance (read-only)
  • InitialDelay Get/set the initial delay before the auto-repeat starts.
  • AutoRepeatPeriod Get/set the interval period of the auto-repeat.

Events

  • StateChanged Fired whenever the internal state of the auto-repeat state-machine changes

How to connect

Toolbox.NETMF.Hardware.AutoRepeatInputPort.png

Sample code in C#

    public class Program
    {
        public static void Main()
        {
            //declare an input-port instance, configured on pin #0, with pull-up,
            //and active on "false" (e.g. when the button is pressed)
            AutoRepeatInputPort Button = new AutoRepeatInputPort(Pins.GPIO_PIN_D0, Port.ResistorMode.PullUp, false);

            Button.StateChanged += new AutoRepeatEventHandler(Button_StateChanged);

            Debug.Print("Press the switch for a while");
        }

        static void Button_StateChanged(object Sender, AutoRepeatEventArgs EventArgs)
        {
            switch (EventArgs.State)
            {
                case AutoRepeatInputPort.AutoRepeatState.Press:
                    Debug.Print("Pressed");
                    break;
                case AutoRepeatInputPort.AutoRepeatState.Release:
                    Debug.Print("Released");
                    break;
                case AutoRepeatInputPort.AutoRepeatState.Tick:
                    Debug.Print("Tick");
                    break;
            }
        }

    }

Sample code in VB

Module Module1

    ' declare an input-port instance, configured on pin #0, with pull-up,
    ' and active on "false" (e.g. when the button is pressed)
    Dim WithEvents Button As AutoRepeatInputPort = New AutoRepeatInputPort(Pins.GPIO_PIN_D0, Port.ResistorMode.PullUp, True)

    Sub Main()
        Debug.Print("Press the switch for a while")
    End Sub

    Private Sub Button_StateChanged(Sender As Object, EventArgs As Toolbox.NETMF.Hardware.AutoRepeatEventArgs) Handles Button.StateChanged
        Select Case EventArgs.State
            Case AutoRepeatInputPort.AutoRepeatState.Press
                Debug.Print("Pressed")
            Case AutoRepeatInputPort.AutoRepeatState.Release
                Debug.Print("Released")
            Case AutoRepeatInputPort.AutoRepeatState.Tick
                Debug.Print("Tick")
        End Select
    End Sub
End Module

Last edited Feb 8, 2012 at 4:17 AM by Highfield, version 9