From 9dd1e483a530b2debb3e42062f9f9e880d5875f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 28 Apr 2020 20:03:18 +0100 Subject: [PATCH] Rework GpioChangeCounter Read (#123) ***PUBLISH_RELEASE*** --- ...pio\342\200\213Change\342\200\213Counter.cs" | 17 ++++++----------- .../Properties/AssemblyInfo.cs | 2 +- source/version.json | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git "a/source/Windows.Devices.Gpio/Gpio\342\200\213Change\342\200\213Counter.cs" "b/source/Windows.Devices.Gpio/Gpio\342\200\213Change\342\200\213Counter.cs" index 7a64722..5a83639 100644 --- "a/source/Windows.Devices.Gpio/Gpio\342\200\213Change\342\200\213Counter.cs" +++ "b/source/Windows.Devices.Gpio/Gpio\342\200\213Change\342\200\213Counter.cs" @@ -28,7 +28,6 @@ public sealed class Gpio​Change​Counter : IDisposable private bool _inputMode; private GpioChangePolarity _polarity = GpioChangePolarity.Falling; private bool _countActive = false; - private TimeSpan _readTime; // this is used as the lock object // a lock is required because multiple threads can access the Gpio​Change​Counter @@ -51,10 +50,10 @@ public sealed class Gpio​Change​Counter : IDisposable { if ( pin.SharingMode != GpioSharingMode.Exclusive ) { - throw new ArgumentException(); } + throw new ArgumentException(); + } _pinNumber = pin.PinNumber; - _readTime = new TimeSpan(0); _inputMode = (pin.GetDriveMode() < GpioPinDriveMode.Output ); @@ -114,21 +113,17 @@ public GpioChangeCount Read() internal GpioChangeCount ReadInternal(bool reset) { - GpioChangeCount ChangeCount = new GpioChangeCount(); + GpioChangeCount changeCount; lock (_syncLock) { if (_disposedValue) { throw new ObjectDisposedException(); } - ChangeCount.Count = NativeRead(reset); - - // _readTime is filled by the NativeRead() - ChangeCount.RelativeTime = _readTime; + changeCount = NativeRead(reset); } - return ChangeCount; + return changeCount; } - /// /// Resets the count to 0 and returns the previous count. /// @@ -249,7 +244,7 @@ public void Dispose() private extern void NativeInit(); [MethodImpl(MethodImplOptions.InternalCall)] - private extern ulong NativeRead(bool Reset); + private extern GpioChangeCount NativeRead(bool Reset); [MethodImpl(MethodImplOptions.InternalCall)] private extern void NativeStart(); diff --git a/source/Windows.Devices.Gpio/Properties/AssemblyInfo.cs b/source/Windows.Devices.Gpio/Properties/AssemblyInfo.cs index 4674a3c..2debb9b 100644 --- a/source/Windows.Devices.Gpio/Properties/AssemblyInfo.cs +++ b/source/Windows.Devices.Gpio/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////// // update this whenever the native assembly signature changes // -[assembly: AssemblyNativeVersion("100.1.2.1")] +[assembly: AssemblyNativeVersion("100.1.2.2")] //////////////////////////////////////////////////////////////// // Setting ComVisible to false makes the types in this assembly not visible diff --git a/source/version.json b/source/version.json index 1dc1ace..a143843 100644 --- a/source/version.json +++ b/source/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.4.1-preview.{height}", + "version": "1.4.2-preview.{height}", "assemblyVersion": { "precision": "revision" },