nanoFramework.Iot.Device.Mcp7940xx 1.0.541
前缀已保留
dotnet add package nanoFramework.Iot.Device.Mcp7940xx --version 1.0.541
NuGet\Install-Package nanoFramework.Iot.Device.Mcp7940xx -Version 1.0.541
该命令旨在在 Visual Studio 的包管理器控制台中使用,因为它使用 NuGet 模块的 Install-Package 版本。
<PackageReference Include="nanoFramework.Iot.Device.Mcp7940xx" Version="1.0.541" />
对于支持 PackageReference 的项目,将此 XML 节点复制到项目文件中,以引用此包。
paket add nanoFramework.Iot.Device.Mcp7940xx --version 1.0.541
NuGet 团队不提供对该客户端的支持。请联系其 维护者 以获取支持。
#r "nuget: nanoFramework.Iot.Device.Mcp7940xx, 1.0.541"
#r 指令可以用于 F# Interactive 和 Polyglot Notebooks。将此复制到交互工具或脚本的源代码中以引用包。
// Install nanoFramework.Iot.Device.Mcp7940xx as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Mcp7940xx&version=1.0.541 // Install nanoFramework.Iot.Device.Mcp7940xx as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Mcp7940xx&version=1.0.541
NuGet 团队不提供对该客户端的支持。请联系其 维护者 以获取支持。
Mcp7940xx/MCP79400/MCP79401/MCP79402 - 具有SRAM的I²C实时时钟/日历
MCP7940M实时时钟/日历(RTCC)使用内部计数器跟踪小时、分钟、秒、日、月、年和星期几的时间。可以在所有计数器上配置闹钟,包括月份。
文档
原始代码是为ESP32编写的
用法
重要:在创建 I2cDevice
之前,请确保为 ESP32 正确设置了 I²C 引脚。为此,请确保安装了 nanoFramework.Hardware.Esp32
NuGet,并使用 Configuration
类配置这些引脚
//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the I2C GPIOs used for the bus.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);
对于 STM32 等其他设备,请确保您正在使用想要的 I²C 总线的预设引脚。
以下示例演示了使用 Mcp7940xx 家族的时钟和闹钟功能。
using System;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;
using Iot.Device.Mcp7940xx;
using nanoFramework.Hardware.Esp32;
// Setup ESP32 I2C port.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);
// Setup Mcp7940m device.
I2cConnectionSettings i2cSettings = new I2cConnectionSettings(1, Mcp7940m.DefaultI2cAddress);
I2cDevice i2cDevice = new I2cDevice(i2cSettings);
Mcp7940m clock = new Mcp7940m(i2cDevice, ClockSource.ExternalCrystal);
clock.SetTime(DateTime.UtcNow);
clock.StartClock(true);
// Set Alarm 1 to trigger on the 4th minute of every hour.
Mcp7940m.Alarm alarm1 = new Mcp7940m.Alarm(AlarmMatchMode.Minute, minute: 4);
clock.SetAlarm1(alarm1);
clock.EnableAlarm1();
Debug.WriteLine($"Alarm 1 : {clock.GetAlarm1()}");
// Set Alarm 2 to trigger every Wednesday.
Mcp7940m.Alarm alarm2 = new Mcp7940m.Alarm(AlarmMatchMode.DayOfWeek, dayOfWeek: DayOfWeek.Wednesday);
clock.SetAlarm2(alarm2);
clock.EnableAlarm2();
Debug.WriteLine($"Alarm 2 : {clock.GetAlarm2()}");
while (true)
{
// Get current time.
DateTime currentTime = clock.GetTime();
Debug.WriteLine($"Time: {currentTime.ToString("yyyy/MM/dd HH:mm:ss")}");
// Check if alarm 1 has triggered.
if (clock.IsTriggeredAlarm1)
{
Debug.WriteLine("[ALARM 1]");
// Clear alarm 1 flag.
clock.ResetAlarm1();
}
// Check if alarm 2 has triggered.
if (clock.IsTriggeredAlarm2)
{
Debug.WriteLine("[ALARM 2]");
// Clear alarm 2 flag.
clock.ResetAlarm2();
// Turn off alarm 2.
clock.DisableAlarm2();
}
// Wait for one second.
Thread.Sleep(1000);
}
以下示例演示了访问 Mcp79401 的受保护 EEPROM 和 EUI。
using System;
using System.Device.I2c;
using System.Diagnostics;
using System.Threading;
using Iot.Device.Mcp7940xx;
using nanoFramework.Hardware.Esp32;
// Setup ESP32 I2C port.
Configuration.SetPinFunction(Gpio.IO21, DeviceFunction.I2C1_DATA);
Configuration.SetPinFunction(Gpio.IO22, DeviceFunction.I2C1_CLOCK);
// Setup Mcp79401 eeprom device.
I2cConnectionSettings i2cSettings = new I2cConnectionSettings(1, Mcp79401.Eeprom.DefaultI2cAddress);
I2cDevice i2cDevice = new I2cDevice(i2cSettings);
Mcp79401.Eeprom eeprom = new Mcp79401.Eeprom(i2cDevice);
// Read and write to EEPROM.
byte byteAddress = 0;
eeprom.WriteByte(byteAddress, 0xA6);
byte value = eeprom.ReadByte(byteAddress);
// Read EUI from EEPROM.
byte[] eui = eeprom.ReadEui();
产品 | 版本 兼容和额外的计算目标框架版本。 |
---|---|
.NET 框架 | net 兼容。 |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.Iot.Device.Common.NumberHelper (>= 1.2.586)
- nanoFramework.Runtime.Events (>= 1.11.18)
- nanoFramework.System.Device.Gpio (>= 1.1.41)
- nanoFramework.System.Device.I2c (>= 1.1.16)
- nanoFramework.System.Math (>= 1.5.43)
NuGet 包
此包没有由任何 NuGet 包使用。
GitHub 代码仓库
此包没有由任何流行的 GitHub 代码仓库使用。
版本 | 下载 | 最后更新 |
---|---|---|
1.0.541 | 60 | 7/24/2024 |
1.0.536 | 75 | 7/17/2024 |
1.0.516 | 83 | 6/14/2024 |
1.0.506 | 86 | 5/29/2024 |
1.0.498 | 91 | 5/17/2024 |
1.0.494 | 76 | 5/15/2024 |
1.0.482 | 103 | 4/15/2024 |
1.0.460 | 100 | 3/22/2024 |
1.0.382 | 218 | 11/10/2023 |
1.0.362 | 106 | 11/8/2023 |
1.0.330 | 134 | 9/6/2023 |
1.0.275 | 128 | 5/26/2023 |
1.0.262 | 126 | 5/16/2023 |
1.0.259 | 125 | 5/12/2023 |
1.0.254 | 127 | 5/11/2023 |
1.0.248 | 145 | 5/10/2023 |
1.0.243 | 126 | 5/3/2023 |
1.0.219 | 190 | 3/17/2023 |
1.0.199 | 228 | 2/22/2023 |
1.0.158 | 281 | 1/5/2023 |
1.0.154 | 293 | 1/3/2023 |
1.0.149 | 273 | 12/28/2022 |
1.0.99 | 346 | 11/5/2022 |
1.0.87 | 352 | 10/25/2022 |
1.0.74 | 366 | 10/22/2022 |
1.0.68 | 406 | 10/12/2022 |
1.0.60 | 403 | 10/8/2022 |
1.0.41 | 422 | 9/22/2022 |
1.0.33 | 460 | 9/15/2022 |
1.0.19 | 377 | 9/8/2022 |
1.0.3 | 382 | 8/25/2022 |
1.0.1 | 383 | 8/25/2022 |