nanoFramework.Iot.Device.Mpr121 1.2.590
前缀已保留dotnet add package nanoFramework.Iot.Device.Mpr121 --version 1.2.590
NuGet\Install-Package nanoFramework.Iot.Device.Mpr121 -Version 1.2.590
此命令旨在在 Visual Studio 的包管理器控制台中使用,因为它使用 NuGet 模块的 Install-Package 版本。
<PackageReference Include="nanoFramework.Iot.Device.Mpr121" Version="1.2.590" />
对于支持 PackageReference 的项目,请将此 XML 节点复制到项目文件中以便引用代码包。
paket add nanoFramework.Iot.Device.Mpr121 --version 1.2.590
NuGet 团队不为此客户端提供支持。请联系其 维护者 以获取支持。
#r "nuget: nanoFramework.Iot.Device.Mpr121, 1.2.590"
#r 指令可用于 F# Interactive 和 Polyglot Notebooks。将它复制到交互工具或脚本的源代码中以引用代码包。
// Install nanoFramework.Iot.Device.Mpr121 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Mpr121&version=1.2.590 // Install nanoFramework.Iot.Device.Mpr121 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Mpr121&version=1.2.590
NuGet 团队不为此客户端提供支持。请联系其 维护者 以获取支持。
MPR121 - 超近程电容式触摸传感器控制器
具有12个通道的I2C超近程电容式触摸传感器控制器。
文档
- MPR121 数据表
用法
重要:在创建 I2cDevice
之前,请确保您正确设置了 I2C 引脚,特别是对于 ESP32,并确保您已安装 nanoFramework.Hardware.ESP32 nuget
。
//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
对于其他设备(如 STM32),请确保您正在使用您想要使用的 I2C 通道的预置引脚。
具有手动更新通道状态的自定义配置
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var mpr121 = new Mpr121(device: i2cDevice);
var statuses = mpr121.ReadChannelStatuses();
var status = statuses[Channels.Channel01]
? "pressed"
: "released";
Debug.WriteLine($"The 1st channel is {status}");
通道状态自动刷新
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
// Initialize controller with default configuration and auto-refresh the channel statuses every 100 ms.
var mpr121 = new Mpr121(device: i2cDevice, periodRefresh: 100);
// Subscribe to channel statuses updates.
mpr121.ChannelStatusesChanged += (object sender, ChannelStatusesChangedEventArgs e) =>
{
var channelStatuses = e.ChannelStatuses;
// do something.
};
自定义 MPR121 寄存器配置
var i2cDevice = I2cDevice.Create(new I2cConnectionSettings(busId: 1, deviceAddress: Mpr121.DefaultI2cAddress));
var config = new Mpr121Configuration
{
MaxHalfDeltaRising = 0x01,
NoiseHalfDeltaRising = 0x01,
NoiseCountLimitRising = 0x00,
FilterDelayCountLimitRising = 0x00,
MaxHalfDeltaFalling = 0x01,
NoiseHalfDeltaFalling = 0x01,
NoiseCountLimitFalling = 0xFF,
FilterDelayCountLimitFalling = 0x01,
ElectrodeTouchThreshold = 0x0F,
ElectrodeReleaseThreshold = 0x0A,
ChargeDischargeTimeConfiguration = 0x04,
ElectrodeConfiguration = 0x0C
};
var mpr121 = new Mpr121(device: i2cDevice, configuration: config);
此示例演示了如何使用自动刷新配置读取通道状态。
处理通道状态更改
mpr121.ChannelStatusesChanged += (object sender, ChannelStatusesChangedEventArgs e) =>
{
var channelStatuses = e.ChannelStatuses;
// do something.
};
绑定说明
绑定提供不同的设备配置选项。设备可以配置为定期更新通道状态。它还支持控制器寄存器的自定义配置。
产品 | 版本 兼容和附加的计算目标框架版本。 |
---|---|
NET Framework | net 兼容。 |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.System.Buffers.Binary.BinaryPrimitives (>= 1.2.586)
- nanoFramework.System.Device.I2c (>= 1.1.16)
NuGet 包
此包没有被任何 NuGet 包使用。
GitHub 仓库
此包没有被任何流行的 GitHub 仓库使用。
版本 | 下载 | 最后更新 |
---|---|---|
1.2.590 | 69 | 7/17/2024 |
1.2.570 | 76 | 6/14/2024 |
1.2.436 | 237 | 11/10/2023 |
1.2.416 | 105 | 11/8/2023 |
1.2.329 | 151 | 5/26/2023 |
1.2.313 | 127 | 5/12/2023 |
1.2.297 | 137 | 5/3/2023 |
1.2.212 | 288 | 1/5/2023 |
1.2.203 | 291 | 12/28/2022 |
1.2.159 | 348 | 11/14/2022 |
1.2.153 | 364 | 11/5/2022 |
1.2.141 | 393 | 10/25/2022 |
1.2.87 | 461 | 9/15/2022 |
1.2.82 | 456 | 9/14/2022 |
1.1.116.8772 | 423 | 6/24/2022 |
1.1.113.2032 | 432 | 6/23/2022 |
1.1.97.17326 | 430 | 6/13/2022 |
1.1.92.53000 | 423 | 6/8/2022 |
1.1.3 | 460 | 4/15/2022 |
1.1.1 | 422 | 4/14/2022 |
1.0.300 | 425 | 3/31/2022 |
1.0.288-preview.114 | 119 | 3/25/2022 |
1.0.288-preview.113 | 112 | 3/25/2022 |
1.0.288-preview.104 | 103 | 3/22/2022 |
1.0.288-preview.100 | 107 | 3/19/2022 |
1.0.288-preview.98 | 128 | 3/18/2022 |
1.0.288-preview.93 | 110 | 3/15/2022 |
1.0.288-preview.87 | 107 | 3/10/2022 |
1.0.288-preview.65 | 114 | 2/18/2022 |
1.0.288-preview.29 | 127 | 1/28/2022 |
1.0.288-preview.20 | 131 | 1/27/2022 |
1.0.288-preview.1 | 126 | 1/21/2022 |
1.0.259 | 328 | 12/9/2021 |
1.0.155 | 320 | 8/31/2021 |
1.0.136 | 389 | 7/17/2021 |
1.0.134 | 162 | 7/15/2021 |
1.0.133 | 184 | 7/14/2021 |
1.0.132 | 181 | 7/8/2021 |
1.0.130 | 154 | 7/6/2021 |
1.0.129 | 165 | 7/6/2021 |
1.0.125 | 189 | 7/5/2021 |
1.0.121 | 196 | 6/29/2021 |
1.0.119 | 217 | 6/28/2021 |
1.0.105 | 279 | 5/29/2021 |
1.0.54 | 211 | 5/25/2021 |