Skip to content

Commit 84af045

Browse files
authored
Adding Iot.Device.Bindings package (#155)
* Adding Iot.Device.Bindings package * Adding missing tag
1 parent 9598969 commit 84af045

File tree

9 files changed

+66
-18
lines changed

9 files changed

+66
-18
lines changed

build.proj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
<Target Name="BuildProduct">
2424
<ItemGroup>
25-
<_BuildProductProjects Include="$(MSBuildThisFileDirectory)src\**\*.csproj" />
25+
<_ExcludeBuildProductProjects Include="$(MSBuildThisFileDirectory)src\Iot.Device.Bindings\Iot.Device.Bindings.csproj" />
26+
<_BuildProductProjects Include="$(MSBuildThisFileDirectory)src\**\*.csproj" Exclude="@(_ExcludeBuildProductProjects)" />
2627
</ItemGroup>
2728

2829
<MSBuild Projects="@(_BuildProductProjects)" />
@@ -38,7 +39,6 @@
3839

3940
<Target Name="BuildSamples">
4041
<ItemGroup>
41-
<_ExcludeBuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\pwm-led\pwm-led.csproj" />
4242
<_ExcludeBuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\serialport-arduino\arduino-demo.csproj" />
4343
<_BuildSampleProjects Include="$(MSBuildThisFileDirectory)samples\**\*.csproj" Exclude="@(_ExcludeBuildSampleProjects)" />
4444
</ItemGroup>
@@ -59,7 +59,8 @@
5959

6060
<Target Name="Pack">
6161
<ItemGroup>
62-
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\**\*.csproj" />
62+
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\Iot.Device.Bindings\Iot.Device.Bindings.csproj" />
63+
<_ProjectsToPackage Include="$(MSBuildThisFileDirectory)src\System.Device.Gpio\System.Device.Gpio.csproj" />
6364
</ItemGroup>
6465

6566
<MSBuild Projects="@(_ProjectsToPackage)" Targets="Pack" />

samples/led-more-blinking-lights/Volume.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System;
66
using System.Device.Spi;
77
using System.Device.Spi.Drivers;
8-
using Iot.Device;
8+
using Iot.Device.Mcp3008;
99

1010
public class Volume : IDisposable
1111
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project>
2+
<!-- Packaging related properties -->
3+
<PropertyGroup>
4+
<MajorVersion>0</MajorVersion>
5+
<MinorVersion>1</MinorVersion>
6+
<Description>This preview package provides a set of Device Bindings that use System.Device.Gpio package to communicate with a microcontroller.</Description>
7+
<Copyright>Microsoft Corporation, All rights reserved.</Copyright>
8+
<PackageTags>.NET Core GPIO Pins SPI I2C PWM BCM2835 BCM2837 RPi IoT Device Bindings</PackageTags>
9+
</PropertyGroup>
10+
11+
<Import Project="..\..\Directory.Build.props" />
12+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<LangVersion>Latest</LangVersion>
6+
<EnableDefaultItems>false</EnableDefaultItems>
7+
<IsPackable>true</IsPackable>
8+
<DeviceRoot>$(MSBuildThisFileDirectory)../devices/</DeviceRoot>
9+
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
10+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackageRefAssembly</TargetsForTfmSpecificContentInPackage>
11+
<!--Disabling default items so samples source won't get build by the main library-->
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<_ExcludeFromCompile Include="$(DeviceRoot)**/samples/**/*.cs" />
16+
<_ExcludeFromCompile Include="$(DeviceRoot)**/tests/**/*.cs" />
17+
<_ExcludeFromCompile Include="$(DeviceRoot)**/obj/**/*.cs" />
18+
<Compile Include="$(DeviceRoot)**/*.cs" Exclude="@(_ExcludeFromCompile)" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="$(MSBuildThisFileDirectory)../System.Device.Gpio/System.Device.Gpio.csproj">
23+
<AdditionalProperties>RuntimeIdentifier=linux</AdditionalProperties>
24+
</ProjectReference>
25+
</ItemGroup>
26+
27+
<Target Name="PackageRefAssembly">
28+
<ItemGroup>
29+
<TfmSpecificPackageFile Include="$(TargetRefPath)">
30+
<PackagePath>ref/$(TargetFramework)</PackagePath>
31+
</TfmSpecificPackageFile>
32+
</ItemGroup>
33+
</Target>
34+
35+
</Project>

src/devices/Directory.Build.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
3-
<PropertyGroup>
4-
<NoWarn>$(NoWarn);CS8321</NoWarn>
5-
<DeterministicSourcePaths>false</DeterministicSourcePaths>
6-
<IsPackable>false</IsPackable>
7-
</PropertyGroup>
3+
<PropertyGroup>
4+
<NoWarn>$(NoWarn);CS8321</NoWarn>
5+
<DeterministicSourcePaths>false</DeterministicSourcePaths>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
88
</Project>

src/devices/Mcp3008/Mcp3008.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Device.Gpio;
77
using System.Device.Spi;
88

9-
namespace Iot.Device
9+
namespace Iot.Device.Mcp3008
1010
{
1111
public class Mcp3008 : IDisposable
1212
{

src/devices/Mcp3008/samples/Mcp3008.Sample.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void Main(string[] args)
2222
// the two implementations.
2323

2424
// SPI implementation
25-
Mcp3008 GetMcp3008WithSpi()
25+
Mcp3008.Mcp3008 GetMcp3008WithSpi()
2626
{
2727
Console.WriteLine("Using SPI protocol.");
2828

@@ -33,27 +33,27 @@ Mcp3008 GetMcp3008WithSpi()
3333
};
3434

3535
var spi = new UnixSpiDevice(connection);
36-
var mcp3008 = new Mcp3008(spi);
36+
var mcp3008 = new Mcp3008.Mcp3008(spi);
3737
return mcp3008;
3838
}
3939

4040
// GPIO (via bit banging) implementation
41-
Mcp3008 GetMcp3008WithGpio()
41+
Mcp3008.Mcp3008 GetMcp3008WithGpio()
4242
{
4343
Console.WriteLine("Using GPIO pins.");
44-
var mcp3008 = new Mcp3008(18, 23, 24, 25);
44+
var mcp3008 = new Mcp3008.Mcp3008(18, 23, 24, 25);
4545
return mcp3008;
4646
}
4747

48-
Mcp3008 mcp = GetMcp3008WithSpi();
48+
Mcp3008.Mcp3008 mcp = GetMcp3008WithSpi();
4949
// Uncomment next line to use GPIO instead.
5050
// Mcp3008 mcp = GetMcp3008WithGpio();
5151

5252
using (mcp)
5353
{
5454
while (true)
5555
{
56-
double value = mcp.Read(0, Mcp3008.InputConfiguration.SingleEnded);
56+
double value = mcp.Read(0, Mcp3008.Mcp3008.InputConfiguration.SingleEnded);
5757
value = value / 10.24;
5858
value = Math.Round(value);
5959
Console.WriteLine(value);

src/devices/Si7021/Si7021.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System;
66
using System.Device.I2c;
77

8-
namespace Iot.Device
8+
namespace Iot.Device.Si7021
99
{
1010
public class Si7021 : IDisposable
1111
{

src/devices/Si7021/samples/Si7021.sample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void Main(string[] args)
1919

2020
var i2cSettings = new I2cConnectionSettings(BusId, Si7021Address);
2121
var i2cDevice = new Windows10I2cDevice(i2cSettings);
22-
var i2CSi7021 = new Si7021(i2cDevice);
22+
var i2CSi7021 = new Si7021.Si7021(i2cDevice);
2323

2424
using (i2CSi7021)
2525
{

0 commit comments

Comments
 (0)