Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

Characteristic Locus
Inheritance object > DipSwitch
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Switches
Assembly Meadow.Foundation.dll

Syntax

public class DipSwitch

Constructors

DipSwitch(IDigitalInterruptPort[])

Creates a new DipSwitch connected to an array of Interrupt Ports

Declaration
public DipSwitch(IDigitalInterruptPort[] interruptPorts)

Parameters

Type Name Description
IDigitalInterruptPort[] interruptPorts

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

DipSwitch(IPin[], InterruptMode, ResistorMode)

Creates a new DipSwitch connected to the specified switchPins, with the InterruptMode and ResisterMode specified by the type parameters.

Declaration
public DipSwitch(IPin[] switchPins, InterruptMode interruptMode, ResistorMode resistorMode)

Parameters

Type Name Description
IPin[] switchPins

An array of pins for each switch

InterruptMode interruptMode

The interrupt mode for all pins

ResistorMode resistorMode

The resistor mode for all pins

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

DipSwitch(IPin[], InterruptMode, ResistorMode, TimeSpan, TimeSpan)

Creates a new DipSwitch connected to the specified switchPins, with the InterruptMode and ResisterMode specified by the type parameters.

Declaration
public DipSwitch(IPin[] switchPins, InterruptMode interruptMode, ResistorMode resistorMode, TimeSpan debounceDuration, TimeSpan glitchFilterCycleCount)

Parameters

Type Name Description
IPin[] switchPins
InterruptMode interruptMode
ResistorMode resistorMode
TimeSpan debounceDuration
TimeSpan glitchFilterCycleCount

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

Properties

this[int]

Returns the ISwitch at the specified index.

Declaration
public ISwitch this[int i] { get; }

Parameters

Type Name Description
int i

Property Value

Type Description
ISwitch

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

Switches

Returns the switch array.

Declaration
public ISwitch[] Switches { get; }

Property Value

Type Description
ISwitch[]

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

Methods

HandleSwitchChanged(int)

Event handler when switch value has been changed

Declaration
protected void HandleSwitchChanged(int switchNumber)

Parameters

Type Name Description
int switchNumber

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"

Events

Changed

Raised when one of the switches is switched on or off.

Declaration
public event ArrayEventHandler Changed

Event Type

Type Description
ArrayEventHandler

Remarks

DipSwitch
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation

DipSwitch represents a DIP-switch wired in a bus configuration, in which all switches are terminated to the same ground/common or high pin.

public class MeadowApp : App<F7Micro, MeadowApp>
{
    protected DipSwitch dipSwitch;

    public MeadowApp()
    {
        Console.WriteLine("Initializing...");

        IDigitalInputPort[] ports =
        {
            Device.CreateDigitalInputPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D08, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D09, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D10, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
            Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown),
        };

        dipSwitch = new DipSwitch(ports);
        dipSwitch.Changed += (s,e) =>
        {
            Console.WriteLine("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
        };

        Console.WriteLine("DipSwitch...");
    }
}

Sample projects available on GitHub

Code Example

protected DipSwitch dipSwitch;

public override Task Initialize()
{
    Resolver.Log.Info("Initializing...");

    IDigitalInterruptPort[] ports =
    {
        Device.CreateDigitalInterruptPort(Device.Pins.D06, InterruptMode.EdgeRising, ResistorMode.InternalPullDown),
    };

    dipSwitch = new DipSwitch(ports);
    dipSwitch.Changed += (s, e) =>
    {
        Resolver.Log.Info("Switch " + e.ItemIndex + " changed to " + (((ISwitch)e.Item).IsOn ? "on" : "off"));
    };

    Resolver.Log.Info("DipSwitch...");

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

<img src="../../API_Assets/Meadow.Foundation.Sensors.Switches.DipSwitch/DipSwitch_Fritzing.svg"