-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for all GPIO and LDO pins, fix some inconsistent namings and typos.
- Loading branch information
Showing
16 changed files
with
833 additions
and
1,438 deletions.
There are no files selected for viewing
1,402 changes: 22 additions & 1,380 deletions
1,402
src/Iot.Device.Bindings/CompatibilitySuppressions.xml
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Iot.Device.Axp192 | ||
{ | ||
/// <summary> | ||
/// GPIO1-4 behavior | ||
/// </summary> | ||
public enum GpioBehavior | ||
{ | ||
/// <summary>NMOS Leak Open Output</summary> | ||
NmosLeakOpenOutput = 0, | ||
|
||
/// <summary>Universal Input Function</summary> | ||
UniversalInputFunction = 1, | ||
|
||
/// <summary>PWM output</summary> | ||
PwmOut = 2, | ||
|
||
/// <summary>Reserved</summary> | ||
Reserved = 3, | ||
|
||
/// <summary>ADC Input</summary> | ||
AdcInput = 4, | ||
|
||
/// <summary>Low Output</summary> | ||
LowOutput = 5, | ||
|
||
/// <summary>Floating</summary> | ||
Floating = 6, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UnitsNet; | ||
|
||
namespace Iot.Device.Axp192 | ||
{ | ||
/// <summary> | ||
/// This class provides a convenient way of retrieving important status | ||
/// information from the Axp192 in a single call | ||
/// </summary> | ||
public class PowerControlData | ||
{ | ||
private const double EmptyBatteryVoltage = 3.2; | ||
|
||
/// <summary> | ||
/// The internal temperature of the power controller | ||
/// </summary> | ||
public Temperature Temperature { get; init; } | ||
|
||
/// <summary> | ||
/// The input current, when powered via bus | ||
/// </summary> | ||
public ElectricCurrent InputCurrent { get; init; } | ||
|
||
/// <summary> | ||
/// The input voltage, when powered via bus | ||
/// </summary> | ||
public ElectricPotential InputVoltage { get; init; } | ||
|
||
/// <summary> | ||
/// The input status. Use this to determine the current power source | ||
/// </summary> | ||
public PowerStatus InputStatus { get; init; } | ||
|
||
/// <summary> | ||
/// The USB input voltage | ||
/// </summary> | ||
public ElectricPotential InputUsbVoltage { get; init; } | ||
|
||
/// <summary> | ||
/// The USB input current | ||
/// </summary> | ||
public ElectricCurrent InputUsbCurrent { get; init; } | ||
|
||
/// <summary> | ||
/// The charging current of the battery | ||
/// </summary> | ||
public ElectricCurrent BatteryChargingCurrent { get; init; } | ||
|
||
/// <summary> | ||
/// The status of the battery | ||
/// </summary> | ||
public BatteryStatus BatteryChargingStatus { get; init; } | ||
|
||
/// <summary> | ||
/// The battery discharge current | ||
/// </summary> | ||
public ElectricCurrent BatteryDischargeCurrent { get; init; } | ||
|
||
/// <summary> | ||
/// The power currently delivered by the battery | ||
/// </summary> | ||
public Power BatteryInstantaneousPower { get; init; } | ||
|
||
/// <summary> | ||
/// The current battery voltage | ||
/// </summary> | ||
public ElectricPotential BatteryVoltage { get; init; } | ||
|
||
/// <summary> | ||
/// Indicates whether a battery is present | ||
/// </summary> | ||
public bool BatteryPresent { get; init; } | ||
|
||
/// <summary> | ||
/// Returns the charge level of the battery. | ||
/// Only valid if a battery is present. | ||
/// </summary> | ||
public Ratio BatteryLevel | ||
{ | ||
get | ||
{ | ||
ElectricPotential value = BatteryVoltage - ElectricPotential.FromVolts(EmptyBatteryVoltage); | ||
return Ratio.FromPercent(MathExtensions.Clamp(value.Volts * 100, 0, 100)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Returns the status of the battery as user-readable english text | ||
/// </summary> | ||
/// <returns>A user-readable string describing the status of the battery</returns> | ||
public string GetBatteryStatusAsText() | ||
{ | ||
var flags = BatteryChargingStatus; | ||
List<string> parts = new List<string>(); | ||
if (!BatteryPresent) | ||
{ | ||
parts.Add("No Battery present"); | ||
} | ||
else if ((flags & BatteryStatus.BatteryConnected) == BatteryStatus.None) | ||
{ | ||
// Probably corresponds to the bit above, therefore only print either message | ||
parts.Add("No battery connected"); | ||
} | ||
|
||
if ((flags & BatteryStatus.Overheated) != BatteryStatus.None) | ||
{ | ||
parts.Add("Power controller overheated"); | ||
} | ||
|
||
if ((flags & BatteryStatus.Charging) != BatteryStatus.None) | ||
{ | ||
parts.Add("Charging"); | ||
} | ||
|
||
if ((flags & BatteryStatus.BatteryActivationMode) != BatteryStatus.None) | ||
{ | ||
parts.Add("Active"); | ||
} | ||
else | ||
{ | ||
parts.Add("Inactive"); | ||
} | ||
|
||
if ((flags & BatteryStatus.ChargingCurrentLessThanExpected) != BatteryStatus.None) | ||
{ | ||
parts.Add("Charging current low"); | ||
} | ||
else | ||
{ | ||
parts.Add("Charging current as expected"); | ||
} | ||
|
||
// Bit 1 has nothing to do with the battery, but is dependent on the wiring and determines the powering sequence | ||
return string.Join(", ", parts); | ||
} | ||
|
||
/// <summary> | ||
/// Returns a printable representation of this structure | ||
/// </summary> | ||
/// <returns>A multiline-string</returns> | ||
public override string ToString() | ||
{ | ||
return @$"Chip Temperature: {Temperature} | ||
Input Current: {InputCurrent} | ||
Input Voltage: {InputVoltage} | ||
Input Status: {InputStatus} | ||
Input Usb Voltage: {InputUsbVoltage} | ||
Input Usb Current: {InputUsbCurrent} | ||
Battery Charging Current: {BatteryChargingCurrent} | ||
Battery Charging Status: {GetBatteryStatusAsText()} | ||
Battery Discharge Current: {BatteryDischargeCurrent} | ||
Battery Instantaneous Power: {BatteryInstantaneousPower} | ||
Battery Voltage: {BatteryVoltage} ({BatteryLevel.Percent:F0}%)"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>$(DefaultBindingTfms)</TargetFrameworks> | ||
<EnableDefaultItems>false</EnableDefaultItems> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="*.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="README.md" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Arduino\Arduino.csproj" /> | ||
<ProjectReference Include="..\Axp192\Axp192.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.7.33808.371 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8F604D83-94DE-4729-84B0-62363CEE5A3D}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "M5Stack", "M5Stack.csproj", "{46FCB389-3AEA-44DA-B59A-45DE665DF7DC}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Arduino", "..\Arduino\Arduino.csproj", "{D1A1F396-39D1-4A8F-AC59-33FC1DD7321A}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Axp192", "..\Axp192\Axp192.csproj", "{4C4E652C-F589-4040-B535-35F7AB2F6365}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{46FCB389-3AEA-44DA-B59A-45DE665DF7DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{46FCB389-3AEA-44DA-B59A-45DE665DF7DC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{46FCB389-3AEA-44DA-B59A-45DE665DF7DC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{46FCB389-3AEA-44DA-B59A-45DE665DF7DC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{D1A1F396-39D1-4A8F-AC59-33FC1DD7321A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{D1A1F396-39D1-4A8F-AC59-33FC1DD7321A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{D1A1F396-39D1-4A8F-AC59-33FC1DD7321A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{D1A1F396-39D1-4A8F-AC59-33FC1DD7321A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4C4E652C-F589-4040-B535-35F7AB2F6365}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4C4E652C-F589-4040-B535-35F7AB2F6365}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4C4E652C-F589-4040-B535-35F7AB2F6365}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4C4E652C-F589-4040-B535-35F7AB2F6365}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1BD14274-4E83-4F3E-B0B1-B7B0FF2D670F} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.