Skip to content

Commit 733b17b

Browse files
authored
Migrate Shared Projects into nuget (#136)
1 parent f2cceac commit 733b17b

File tree

77 files changed

+10308
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+10308
-12
lines changed

Diff for: devices/Multiplexing/GpioOutputSegment.cs

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Device.Gpio;
7+
using System.Threading;
8+
using Iot.Device.Multiplexing.Utility;
9+
10+
namespace Iot.Device.Multiplexing
11+
{
12+
/// <summary>
13+
/// IOutputSegment implementation that uses GpioController.
14+
/// </summary>
15+
public class GpioOutputSegment : IOutputSegment, IDisposable
16+
{
17+
private readonly int[] _pins;
18+
private readonly bool _shouldDispose;
19+
private readonly VirtualOutputSegment _segment;
20+
private GpioController _controller;
21+
22+
/// <summary>
23+
/// IOutputSegment implementation that uses GpioController.
24+
/// </summary>
25+
/// <param name="pins">The GPIO pins that should be used and are connected.</param>
26+
/// <param name="gpioController">The GpioController to use. If one isn't provided, one will be created.</param>
27+
/// <param name="shouldDispose">The policy to use (true, by default) for disposing the GPIO controller when disposing this instance.</param>
28+
public GpioOutputSegment(int[] pins, GpioController? gpioController = null, bool shouldDispose = true)
29+
{
30+
_shouldDispose = shouldDispose || gpioController is null;
31+
_controller = gpioController ?? new GpioController();
32+
_pins = pins;
33+
_segment = new VirtualOutputSegment(_pins.Length);
34+
35+
foreach (var pin in _pins)
36+
{
37+
_controller.OpenPin(pin, PinMode.Output);
38+
}
39+
}
40+
41+
/// <summary>
42+
/// The length of the segment; the number of GPIO pins it exposes.
43+
/// </summary>
44+
public int Length => _segment.Length;
45+
46+
/// <summary>
47+
/// Segment values.
48+
/// </summary>
49+
public PinValue this[int index]
50+
{
51+
get => _segment[index];
52+
set => _segment[index] = value;
53+
}
54+
55+
/// <summary>
56+
/// Writes a PinValue to a virtual segment.
57+
/// Does not display output.
58+
/// </summary>
59+
public void Write(int pin, PinValue value)
60+
{
61+
_segment.Write(pin, value);
62+
}
63+
64+
/// <summary>
65+
/// Writes discrete underlying bits to a virtual segment.
66+
/// Writes each bit, left to right. Least significant bit will written to index 0.
67+
/// Does not display output.
68+
/// </summary>
69+
public void Write(byte value)
70+
{
71+
_segment.Write(value);
72+
}
73+
74+
/// <summary>
75+
/// Writes discrete underlying bits to a virtual segment.
76+
/// Writes each byte, left to right. Least significant bit will written to index 0.
77+
/// Does not display output.
78+
/// </summary>
79+
public void Write(SpanByte value)
80+
{
81+
_segment.Write(value);
82+
}
83+
84+
/// <summary>
85+
/// Writes a byte to the underlying GpioController.
86+
/// </summary>
87+
public void TurnOffAll()
88+
{
89+
_segment.TurnOffAll();
90+
Display();
91+
}
92+
93+
/// <summary>
94+
/// Displays current state of segment.
95+
/// Segment is displayed at least until token receives a cancellation signal, possibly due to a specified duration expiring.
96+
/// </summary>
97+
public void Display(CancellationToken token)
98+
{
99+
Display();
100+
_segment.Display(token);
101+
}
102+
103+
/// <summary>
104+
/// Displays current state of segment.
105+
/// Segment is displayed at least until token receives a cancellation signal, possibly due to a specified duration expiring.
106+
/// </summary>
107+
private void Display()
108+
{
109+
for (int i = 0; i < _pins.Length; i++)
110+
{
111+
_controller.Write(_pins[i], _segment[i]);
112+
}
113+
}
114+
115+
/// <summary>
116+
/// Disposes the underlying GpioController.
117+
/// </summary>
118+
public void Dispose()
119+
{
120+
if (_shouldDispose)
121+
{
122+
_controller?.Dispose();
123+
_controller = null!;
124+
}
125+
}
126+
}
127+
}

Diff for: devices/Multiplexing/IOutputSegment.cs

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Device.Gpio;
6+
using System.Threading;
7+
8+
namespace Iot.Device.Multiplexing
9+
{
10+
/// <summary>
11+
/// Abstracts a segment of outputs from multiplexing sources (like a shift register).
12+
/// </summary>
13+
public interface IOutputSegment : IDisposable
14+
{
15+
/// <summary>
16+
/// Length of segment (number of outputs)
17+
/// </summary>
18+
int Length { get; }
19+
20+
/// <summary>
21+
/// Segment values.
22+
/// </summary>
23+
PinValue this[int index] { get; set; }
24+
25+
/// <summary>
26+
/// Writes a PinValue to a virtual segment.
27+
/// Does not display output until calling Display() or Display(CancellationToken ct) methods.
28+
/// </summary>
29+
void Write(int index, PinValue value);
30+
31+
/// <summary>
32+
/// Writes discrete underlying bits to a virtual segment.
33+
/// Writes each bit, left to right. Least significant bit will written to index 0.
34+
/// Does not display output.
35+
/// </summary>
36+
void Write(byte value);
37+
38+
/// <summary>
39+
/// Writes discrete underlying bits to a virtual output.
40+
/// Writes each byte, left to right. Least significant bit will written to index 0.
41+
/// Does not display output.
42+
/// </summary>
43+
void Write(SpanByte value);
44+
45+
/// <summary>
46+
/// Turns off all outputs.
47+
/// </summary>
48+
void TurnOffAll();
49+
50+
/// <summary>
51+
/// Displays current state of segment.
52+
/// Segment is displayed at least until token receives a cancellation signal, possibly due to a specified duration expiring.
53+
/// </summary>
54+
void Display(CancellationToken token);
55+
}
56+
}

Diff for: devices/Multiplexing/Multiplexing.nfproj

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>82efb396-b670-412d-871a-5c32ee51d472</ProjectGuid>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>Iot.Device.Multiplexing</RootNamespace>
16+
<AssemblyName>Iot.Device.Multiplexing</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
<DocumentationFile>bin\$(Configuration)\Iot.Device.Multiplexing.xml</DocumentationFile>
19+
</PropertyGroup>
20+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
21+
<ItemGroup>
22+
<Compile Include="GpioOutputSegment.cs" />
23+
<Compile Include="IOutputSegment.cs" />
24+
<Compile Include="Properties\AssemblyInfo.cs" />
25+
<Compile Include="VirtualOutputSegment.cs" />
26+
</ItemGroup>
27+
<ItemGroup>
28+
<Reference Include="mscorlib, Version=1.10.5.4, Culture=neutral, PublicKeyToken=c07d481e9758c731">
29+
<HintPath>packages\nanoFramework.CoreLibrary.1.10.5\lib\mscorlib.dll</HintPath>
30+
<Private>True</Private>
31+
<SpecificVersion>True</SpecificVersion>
32+
</Reference>
33+
<Reference Include="nanoFramework.Runtime.Events, Version=1.9.1.3, Culture=neutral, PublicKeyToken=c07d481e9758c731">
34+
<HintPath>packages\nanoFramework.Runtime.Events.1.9.1\lib\nanoFramework.Runtime.Events.dll</HintPath>
35+
<Private>True</Private>
36+
<SpecificVersion>True</SpecificVersion>
37+
</Reference>
38+
<Reference Include="System.Device.Gpio, Version=1.0.1.2, Culture=neutral, PublicKeyToken=c07d481e9758c731">
39+
<HintPath>packages\nanoFramework.System.Device.Gpio.1.0.1\lib\System.Device.Gpio.dll</HintPath>
40+
<Private>True</Private>
41+
<SpecificVersion>True</SpecificVersion>
42+
</Reference>
43+
<Reference Include="System.Threading, Version=1.0.2.2, Culture=neutral, PublicKeyToken=c07d481e9758c731">
44+
<HintPath>packages\nanoFramework.System.Threading.1.0.2\lib\System.Threading.dll</HintPath>
45+
<Private>True</Private>
46+
<SpecificVersion>True</SpecificVersion>
47+
</Reference>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="packages.config" />
51+
</ItemGroup>
52+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
53+
<ProjectExtensions>
54+
<ProjectCapabilities>
55+
<ProjectConfigurationsDeclaredAsItems />
56+
</ProjectCapabilities>
57+
</ProjectExtensions>
58+
<Import Project="packages\Nerdbank.GitVersioning.3.4.231\build\Nerdbank.GitVersioning.targets" Condition="Exists('packages\Nerdbank.GitVersioning.3.4.231\build\Nerdbank.GitVersioning.targets')" />
59+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
60+
<PropertyGroup>
61+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
62+
</PropertyGroup>
63+
<Error Condition="!Exists('packages\Nerdbank.GitVersioning.3.4.231\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Nerdbank.GitVersioning.3.4.231\build\Nerdbank.GitVersioning.targets'))" />
64+
</Target>
65+
</Project>

Diff for: devices/Multiplexing/Multiplexing.nuspec

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3+
<metadata>
4+
<id>nanoFramework.Iot.Device.Multiplexing</id>
5+
<version>$version$</version>
6+
<title>nanoFramework.Iot.Device.Multiplexing</title>
7+
<authors>nanoFramework project contributors</authors>
8+
<owners>nanoFramework project contributors,dotnetfoundation</owners>
9+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
10+
<license type="file">LICENSE.md</license>
11+
<releaseNotes>
12+
</releaseNotes>
13+
<developmentDependency>false</developmentDependency>
14+
<projectUrl>https://github.com/nanoframework/nanoFramework.IoT.Device</projectUrl>
15+
<iconUrl>https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad</iconUrl>
16+
<icon>images\nf-logo.png</icon>
17+
<repository type="git" url="https://github.com/nanoframework/nanoFramework.IoT.Device" commit="$commit$" />
18+
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
19+
<description>This package includes the .NET IoT Core binding Iot.Device.Multiplexing for .NET nanoFramework C# projects.</description>
20+
<summary>Iot.Device.Multiplexing assembly for .NET nanoFramework C# projects</summary>
21+
<tags>nanoFramework C# csharp netmf netnf Iot.Device.Multiplexing</tags>
22+
<dependencies>
23+
<dependency id="nanoFramework.CoreLibrary" version="1.10.5" />
24+
<dependency id="nanoFramework.System.Device.Gpio" version="1.0.1" />
25+
<dependency id="nanoFramework.Runtime.Events" version="1.9.1" />
26+
<dependency id="nanoFramework.System.Threading" version="1.0.2" />
27+
</dependencies>
28+
</metadata>
29+
<files>
30+
<file src="bin\Release\Iot.Device.Multiplexing.dll" target="lib\Iot.Device.Multiplexing.dll" />
31+
<file src="bin\Release\Iot.Device.Multiplexing.pdb" target="lib\Iot.Device.Multiplexing.pdb" />
32+
<file src="bin\Release\Iot.Device.Multiplexing.pdbx" target="lib\Iot.Device.Multiplexing.pdbx" />
33+
<file src="bin\Release\Iot.Device.Multiplexing.pe" target="lib\Iot.Device.Multiplexing.pe" />
34+
<file src="bin\Release\Iot.Device.Multiplexing.xml" target="lib\Iot.Device.Multiplexing.xml" />
35+
<file src="..\..\assets\nf-logo.png" target="images" />
36+
<file src="..\..\LICENSE.md" target="" />
37+
</files>
38+
</package>

Diff for: devices/Multiplexing/Multiplexing.sln

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31613.86
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "Multiplexing", "Multiplexing.nfproj", "{82EFB396-B670-412D-871A-5C32EE51D472}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{82EFB396-B670-412D-871A-5C32EE51D472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{82EFB396-B670-412D-871A-5C32EE51D472}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{82EFB396-B670-412D-871A-5C32EE51D472}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17+
{82EFB396-B670-412D-871A-5C32EE51D472}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{82EFB396-B670-412D-871A-5C32EE51D472}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{82EFB396-B670-412D-871A-5C32EE51D472}.Release|Any CPU.Deploy.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {23AD8C74-625B-4F79-9A1B-44C5211E8EDF}
26+
EndGlobalSection
27+
EndGlobal

Diff for: devices/Multiplexing/Properties/AssemblyInfo.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
[assembly: AssemblyTitle("Iot.Device.Multiplexing")]
6+
[assembly: AssemblyCompany("nanoFramework Contributors")]
7+
[assembly: AssemblyCopyright("Copyright(c).NET Foundation and Contributors")]
8+
9+
// Setting ComVisible to false makes the types in this assembly not visible
10+
// to COM components. If you need to access a type in this assembly from
11+
// COM, set the ComVisible attribute to true on that type.
12+
[assembly: ComVisible(false)]
13+
14+
/////////////////////////////////////////////////////////////////
15+
// This attribute is mandatory when building Interop libraries //
16+
// update this whenever the native assembly signature changes //
17+
[assembly: AssemblyNativeVersion("0.0.0.0")]
18+
/////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)