Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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 | object > Mpr121 |
Implements | II2cPeripheral |
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.Hid |
Assembly | Mpr121.dll |
Syntax
public class Mpr121 : II2cPeripheral
Constructors
Mpr121(II2cBus, byte, int, 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 | |
byte | address | |
int | refreshPeriod | |
Mpr121.Mpr121Configuration | configuration |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
Fields
i2cComms
I2C Communication bus used to communicate with the peripheral
Declaration
protected readonly II2cCommunications i2cComms
Field Value
Type | Description |
---|---|
II2cCommunications |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
Properties
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
RefreshPeriod
Gets or sets the period in milliseconds to refresh the channels statuses.
Declaration
public int RefreshPeriod { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
Methods
ReadChannelStatus(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 |
---|---|
bool |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
ReadChannelStatuses()
Reads the channel statuses of MPR121 controller.
Declaration
public IReadOnlyDictionary<Mpr121.Channels, bool> ReadChannelStatuses()
Returns
Type | Description |
---|---|
IReadOnlyDictionary<Mpr121.Channels, bool> |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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:
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 |
---|---|
EventHandler<ChannelStatusChangedEventArgs> |
Remarks
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(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 + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
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: