Remarks

Mpr121
Status
Source code GitHub
NuGet package
                <img src="https://img.shields.io/nuget/v/Meadow.Foundation.Sensors.Hid.Mpr121.svg?label=Meadow.Foundation.Sensors.Hid.Mpr121" 
                style="width: auto; height: -webkit-fill-available;" /></a> |

Code Example

public class MeadowApp : App<F7Micro, MeadowApp>
{
    Mpr121 sensor;

    public MeadowApp()
    {
        sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
        sensor.ChannelStatusesChanged += SensorChannelStatusesChanged;
    }

    void SensorChannelStatusesChanged(object sender, ChannelStatusChangedEventArgs e)
    {
        string pads = string.Empty;

        for(int i = 0; i < e.ChannelStatus.Count; i++)
        {
            if(e.ChannelStatus[(Mpr121.Channels)i] == true)
            {
                pads += i + ", ";
            }
        }

        if (string.IsNullOrEmpty(pads))
        {
            Console.WriteLine("none");
        }
        else
        {
            Console.WriteLine(pads + "touched");
        }
    }
}

Wiring Example

To wire a Mpr121 to your Meadow board, connect the following:

Mpr121 Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object > Mpr121
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.Hid
Assembly Mpr121.dll

Syntax

public class Mpr121

Constructors

Mpr121(II2cBus, Byte, Int32, Mpr121.Mpr121Configuration)

Create a new MPR121 keypad object.

Declaration
public Mpr121(II2cBus i2cBus, byte address = 90, int refreshPeriod = -1, Mpr121.Mpr121Configuration configuration = null)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address
System.Int32 refreshPeriod
Mpr121.Mpr121Configuration configuration

Fields

DefaultI2cAddress

MPR121 Default I2C Address.

Declaration
public const byte DefaultI2cAddress = 90

Field Value

Type Description
System.Byte

Properties

RefreshPeriod

Gets or sets the period in milliseconds to refresh the channels statuses.

Declaration
public int RefreshPeriod { get; set; }

Property Value

Type Description
System.Int32

Methods

ReadChannelStatus(Mpr121.Channels)

Reads the channel status of MPR121 controller.

Declaration
public bool ReadChannelStatus(Mpr121.Channels channel)

Parameters

Type Name Description
Mpr121.Channels channel

The channel to read status.

Returns

Type Description
System.Boolean

ReadChannelStatuses()

Reads the channel statuses of MPR121 controller.

Declaration
public IReadOnlyDictionary<Mpr121.Channels, bool> ReadChannelStatuses()

Returns

Type Description
System.Collections.Generic.IReadOnlyDictionary<Mpr121.Channels, System.Boolean>

Events

ChannelStatusesChanged

Notifies about a the channel statuses have been changed. Refresh period can be changed by setting PeriodRefresh property.

Declaration
public event EventHandler<ChannelStatusChangedEventArgs> ChannelStatusesChanged

Event Type

Type Description
System.EventHandler<ChannelStatusChangedEventArgs>