add Swan.Tiny and CodingStyles

This commit is contained in:
BlubbFish 2019-12-09 17:27:40 +01:00
parent 2f1d949dcc
commit c41f2043e2
7 changed files with 60 additions and 36 deletions

View File

@ -9,24 +9,21 @@ namespace Unosquare.WiringPi {
/// Represents the Bootstrap class to extract resources.
/// </summary>
/// <seealso cref="Unosquare.RaspberryIO.Abstractions.IBootstrap" />
public class BootstrapWiringPi : IBootstrap
{
private static readonly Object SyncLock = new Object();
/// <inheritdoc />
public void Bootstrap()
{
lock (SyncLock)
{
Resources.EmbeddedResources.ExtractAll();
DependencyContainer.Current.Register<IGpioController>(new GpioController());
DependencyContainer.Current.Register<ISpiBus>(new SpiBus());
DependencyContainer.Current.Register<II2CBus>(new I2CBus());
DependencyContainer.Current.Register<ISystemInfo>(new SystemInfo());
DependencyContainer.Current.Register<ITiming>(new Timing());
DependencyContainer.Current.Register<IThreading>(new Threading());
}
}
}
public class BootstrapWiringPi : IBootstrap {
private static readonly Object SyncLock = new Object();
/// <inheritdoc />
public void Bootstrap() {
lock(SyncLock) {
Resources.EmbeddedResources.ExtractAll();
_ = DependencyContainer.Current.Register<IGpioController>(new GpioController());
_ = DependencyContainer.Current.Register<ISpiBus>(new SpiBus());
_ = DependencyContainer.Current.Register<II2CBus>(new I2CBus());
_ = DependencyContainer.Current.Register<ISystemInfo>(new SystemInfo());
_ = DependencyContainer.Current.Register<ITiming>(new Timing());
_ = DependencyContainer.Current.Register<IThreading>(new Threading());
}
}
}
}

View File

@ -396,7 +396,7 @@ namespace Unosquare.WiringPi {
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The awaitable task.</returns>
public Task WriteAsync(GpioPinValue value) => Task.Run(() => { this.Write(value); });
public Task WriteAsync(GpioPinValue value) => Task.Run(() => this.Write(value));
/// <summary>
/// Writes the specified bit value.
@ -413,7 +413,7 @@ namespace Unosquare.WiringPi {
/// <returns>
/// The awaitable task.
/// </returns>
public Task WriteAsync(Boolean value) => Task.Run(() => { this.Write(value); });
public Task WriteAsync(Boolean value) => Task.Run(() => this.Write(value));
/// <summary>
/// Writes the specified value. 0 for low, any other value for high
@ -428,7 +428,7 @@ namespace Unosquare.WiringPi {
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The awaitable task.</returns>
public Task WriteAsync(Int32 value) => Task.Run(() => { this.Write(value); });
public Task WriteAsync(Int32 value) => Task.Run(() => this.Write(value));
/// <summary>
/// Writes the specified value as an analog level.
@ -452,7 +452,7 @@ namespace Unosquare.WiringPi {
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The awaitable task.</returns>
public Task WriteLevelAsync(Int32 value) => Task.Run(() => { this.WriteLevel(value); });
public Task WriteLevelAsync(Int32 value) => Task.Run(() => this.WriteLevel(value));
#endregion

View File

@ -39,16 +39,15 @@ namespace Unosquare.WiringPi.Resources {
return;
}
using(Stream stream = typeof(EmbeddedResources).Assembly.GetManifestResourceStream(resourceName)) {
using(FileStream outputStream = File.OpenWrite(targetPath)) {
stream?.CopyTo(outputStream);
}
using Stream stream = typeof(EmbeddedResources).Assembly.GetManifestResourceStream(resourceName);
using(FileStream outputStream = File.OpenWrite(targetPath)) {
stream?.CopyTo(outputStream);
}
try {
_ = SysCall.Chmod(targetPath, (UInt32)executablePermissions);
} catch {
/* Ignore */
}
try {
_ = SysCall.Chmod(targetPath, (UInt32)executablePermissions);
} catch {
/* Ignore */
}
}
}

View File

@ -107,7 +107,7 @@ namespace Unosquare.WiringPi {
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <returns>The awaitable task.</returns>
public Task WriteAsync(Byte[] buffer) => Task.Run(() => { this.Write(buffer); });
public Task WriteAsync(Byte[] buffer) => Task.Run(() => this.Write(buffer));
/// <summary>
/// Retrieves the spi bus. If the bus channel is not registered it sets it up automatically.

View File

@ -19,8 +19,8 @@ namespace Unosquare.WiringPi {
public Version LibraryVersion {
get {
String[] libParts = Native.WiringPi.WiringPiLibrary.Split('.');
Int32 major = Int32.Parse(libParts[libParts.Length - 2]);
Int32 minor = Int32.Parse(libParts[libParts.Length - 1]);
Int32 major = Int32.Parse(libParts[^2]);
Int32 minor = Int32.Parse(libParts[^1]);
return new Version(major, minor);
}
}

View File

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>This library uses WiringPi to enables developers to use the various Raspberry Pi's hardware modules including the Camera to capture images and video, the GPIO pins, and both, the SPI and I2C buses.</Description>
<Copyright>Unosquare (c) 2016-2019</Copyright>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Unosquare.WiringPi</AssemblyName>
<PackageId>Unosquare.WiringPi</PackageId>
<Version>0.4.2</Version>
<Authors>Unosquare</Authors>
<PackageIconUrl>https://github.com/unosquare/wiringpi-dotnet/raw/master/logos/raspberryio-logo-32.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/unosquare/wiringpi-dotnet</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/unosquare/wiringpi-dotnet/master/LICENSE</PackageLicenseUrl>
<PackageTags>Raspberry Pi GPIO Camera SPI I2C Embedded IoT Mono C# .NET wiringPi</PackageTags>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\gpio" />
<EmbeddedResource Include="Resources\libwiringPi.so.2.50" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Swan.Tiny\Swan.Tiny.csproj" />
<ProjectReference Include="..\Unosquare.RaspberryIO.Abstractions\Unosquare.RaspberryIO.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@ -21,6 +21,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Swan.Lite\Swan.Lite.csproj" />
<ProjectReference Include="..\Swan\Swan.csproj" />
<ProjectReference Include="..\Unosquare.RaspberryIO.Abstractions\Unosquare.RaspberryIO.Abstractions.csproj" />
</ItemGroup>