nanoFramework.Iot.Device.Ip5306 1.2.613

前缀已保留
dotnet add package nanoFramework.Iot.Device.Ip5306 --version 1.2.613                
NuGet\Install-Package nanoFramework.Iot.Device.Ip5306 -Version 1.2.613                
此命令旨在在 Visual Studio 的包管理器控制台中使用,因为它使用 NuGet 模块的 Install-Package 版本。
<PackageReference Include="nanoFramework.Iot.Device.Ip5306" Version="1.2.613" />                
对于支持 PackageReference 的项目,将此 XML 节点复制到项目文件中以引用该包。
paket add nanoFramework.Iot.Device.Ip5306 --version 1.2.613                
#r "nuget: nanoFramework.Iot.Device.Ip5306, 1.2.613"                
#r 指令可以在 F# Interactive 和 Polyglot Notebooks 中使用。将其复制到交互式工具或脚本的源代码中以引用包。
// Install nanoFramework.Iot.Device.Ip5306 as a Cake Addin
#addin nuget:?package=nanoFramework.Iot.Device.Ip5306&version=1.2.613

// Install nanoFramework.Iot.Device.Ip5306 as a Cake Tool
#tool nuget:?package=nanoFramework.Iot.Device.Ip5306&version=1.2.613                

IP5306 - 电源管理

此芯片主要用于电源银行和嵌入式设备作为电源管理设备。它通过 I2C 连接,允许调整充电电流、电压、截止电压。它具有点亮 4 个 LED 以显示电池充电状态的能力。此设备用于 M5Stack。

文档

中文数据表可以在 此处 找到。

用法

在使用 I2C 时,始终需要确保使用正确的引脚。在 ESP32 上,如果您不使用默认引脚,则需要注册这些引脚。

Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);
Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);

I2cDevice i2c = new(new I2cConnectionSettings(1, Ip5306.SecondaryI2cAddress));
Ip5306 power = new(i2c);

注意 IP5306 的默认地址为 0xEA,M5Stack 使用的地址为 0x75(在此设置为 SecondaryI2cAddress)。

访问属性

所有属性都可以进行调整和修改。以下是如何显示所有属性的示例

Debug.WriteLine($"  AutoPowerOnEnabled: {power.AutoPowerOnEnabled}");
Debug.WriteLine($"  BoostOutputEnabled: {power.BoostOutputEnabled}");
Debug.WriteLine($"  BoostWhenVinUnpluggedEnabled: {power.BoostWhenVinUnpluggedEnabled}");
Debug.WriteLine($"  BostEnabled: {power.BoostEnabled}");
Debug.WriteLine($"  ButtonOffEnabled: {power.ButtonOffEnabled}");
Debug.WriteLine($"  ChargerEnabled: {power.ChargerEnabled}");
Debug.WriteLine($"  ChargingBatteryVoltage: {power.ChargingBatteryVoltage}");
Debug.WriteLine($"  ChargingCurrent: {power.ChargingCurrent}");
Debug.WriteLine($"  ChargingCutOffCurrent: {power.ChargingCutOffCurrent}");
Debug.WriteLine($"  ChargingCuttOffVoltage{power.ChargingCuttOffVoltage}");
Debug.WriteLine($"  ChargingLoopSelection: {power.ChargingLoopSelection}");
Debug.WriteLine($"  ChargingUnderVoltage: {power.ChargingUnderVoltage}");
Debug.WriteLine($"  ConstantChargingVoltage: {power.ConstantChargingVoltage}");
Debug.WriteLine($"  FlashLightBehavior {power.FlashLightBehavior}");
Debug.WriteLine($"  IsBatteryFull: {power.IsBatteryFull}");
Debug.WriteLine($"  IsCharging: {power.IsCharging}");
Debug.WriteLine($"  IsOutputLoadHigh: {power.IsOutputLoadHigh}");
Debug.WriteLine($"  LightDutyShutdownTime: {power.LightDutyShutdownTime}");
Debug.WriteLine($"  LowPowerOffEnabled: {power.LowPowerOffEnabled}");
Debug.WriteLine($"  ShortPressToSwitchBosst: {power.ShortPressToSwitchBosst}");
Debug.WriteLine($"  SwitchOffBoostBehavior: {power.SwitchOffBoostBehavior}");
Debug.WriteLine($"  GetButtonStatus: {power.GetButtonStatus()}");

按钮状态

您可以获取按钮状态

var button = power.GetButtonStatus();
switch (button)
{
    case ButtonPressed.DoubleClicked:
        Debug.WriteLine("double clicked");
        break;
    case ButtonPressed.LongPressed:
        Debug.WriteLine("Long pressed");
        break;
    case ButtonPressed.ShortPressed:
        Debug.WriteLine("Short pressed");
        break;
    case ButtonPressed.NotPressed:
    default:
        break;
}

重要:根据您为按钮设置的的行为,设备可能会关闭与其连接的设备。因此请在设置时要小心。一旦I2C连接断开,您就无法调整行为。

M5Stack配置

M5Stack的配置如下

// Configuration for M5Stack
power.ButtonOffEnabled = true;
power.BoostOutputEnabled = false;
power.AutoPowerOnEnabled = true;
power.ChargerEnabled = true;
power.BoostEnabled = true;
power.LowPowerOffEnabled = true;
power.FlashLightBehavior = ButtonPress.Doubleclick;
power.SwitchOffBoostBehavior = ButtonPress.LongPress;
power.BoostWhenVinUnpluggedEnabled = true;
power.ChargingUnderVoltage = ChargingUnderVoltage.V4_55;
power.ChargingLoopSelection = ChargingLoopSelection.Vin;
power.ChargingCurrent = ElectricCurrent.FromMilliamperes(2250);
power.ConstantChargingVoltage = ConstantChargingVoltage.Vm28;
power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_17;
power.LightDutyShutdownTime = LightDutyShutdownTime.S32;
power.ChargingCutOffCurrent = ChargingCutOffCurrent.C500mA;
power.ChargingCuttOffVoltage = ChargingCutOffVoltage.V4_2;
产品 兼容的以及额外的计算目标框架版本。
.NET Framework net 兼容。
兼容的目标框架
包含的目标框架(在包中)
关于目标框架.NET标准了解更多信息。

NuGet包 (3)

显示依赖nanoFramework.Iot.Device.Ip5306的前3个NuGet包

下载
nanoFramework.M5Core

此包包含为.NET nanoFramework C#项目而设置的nanoFramework.M5Core组件。

nanoFramework.Fire

此包包含为.NET nanoFramework C#项目而设置的nanoFramework.Fire组件。

nanoFramework.M5Stack

此包包含为.NET nanoFramework C#项目而设置的nanoFramework.M5Stack组件。

GitHub仓库

此包未用于任何流行的GitHub仓库。

版本 下载 上次更新
1.2.613 44 8/9/2024
1.2.601 109 7/26/2024
1.2.590 177 7/17/2024
1.2.573 270 6/19/2024
1.2.570 84 6/14/2024
1.2.536 380 4/15/2024
1.2.514 294 3/22/2024
1.2.494 182 2/28/2024
1.2.474 263 1/24/2024
1.2.462 161 1/5/2024
1.2.458 124 12/20/2023
1.2.436 252 11/10/2023
1.2.403 324 10/6/2023
1.2.396 204 9/27/2023
1.2.384 206 9/6/2023
1.2.378 252 8/16/2023
1.2.369 239 8/2/2023
1.2.363 198 7/28/2023
1.2.357 220 7/19/2023
1.2.354 199 7/14/2023
1.2.345 207 6/21/2023
1.2.341 182 6/14/2023
1.2.337 230 6/7/2023
1.2.335 114 6/2/2023
1.2.329 211 5/26/2023
1.2.313 307 5/12/2023
1.2.302 256 5/10/2023
1.2.297 276 5/3/2023
1.2.273 960 3/17/2023
1.2.267 593 3/10/2023
1.2.263 465 3/8/2023
1.2.259 492 2/27/2023
1.2.256 489 2/24/2023
1.2.253 490 2/22/2023
1.2.222 1,052 1/9/2023
1.2.208 1,432 1/3/2023
1.2.203 614 12/28/2022
1.2.153 1,952 11/5/2022
1.2.141 2,110 10/25/2022
1.2.63 6,880 9/3/2022
1.2.47 1,006 8/15/2022
1.2.40 972 8/6/2022
1.2.38 926 8/5/2022
1.2.28 2,422 8/1/2022
1.2.13 1,934 7/24/2022
1.2.10 938 7/23/2022
1.1.142.3202 1,809 7/7/2022
1.1.133.52556 2,646 6/30/2022
1.1.121.35854 2,331 6/26/2022
1.1.102.51394 2,358 6/15/2022
1.1.99.36719 935 6/14/2022
1.1.72.29765 4,727 5/31/2022
1.1.64.21380 2,305 5/26/2022
1.1.54.28879 1,737 5/23/2022
1.1.40 2,522 5/5/2022
1.1.1 8,070 4/14/2022
1.0.302 3,419 3/31/2022
1.0.300 418 3/31/2022
1.0.288-preview.113 133 3/25/2022
1.0.288-preview.103 135 3/21/2022
1.0.288-preview.98 127 3/18/2022
1.0.288-preview.93 148 3/15/2022
1.0.288-preview.86 167 3/8/2022
1.0.288-preview.77 152 2/27/2022
1.0.288-preview.75 118 2/26/2022
1.0.288-preview.65 139 2/18/2022
1.0.288-preview.63 121 2/16/2022
1.0.288-preview.61 131 2/12/2022
1.0.288-preview.58 116 2/10/2022
1.0.288-preview.53 117 2/9/2022
1.0.288-preview.41 166 1/31/2022
1.0.288-preview.29 137 1/28/2022
1.0.288-preview.20 165 1/27/2022
1.0.288-preview.18 134 1/27/2022
1.0.288-preview.5 140 1/24/2022
1.0.288-preview.1 138 1/21/2022
1.0.267 329 1/4/2022
1.0.259 515 12/9/2021
1.0.258 267 12/7/2021
1.0.218 472 10/18/2021
1.0.203 315 10/11/2021
1.0.191 304 9/29/2021
1.0.177 318 9/22/2021