Skip to content

Commit

Permalink
Rework start and stop continuous conversion (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniofagundes authored Sep 22, 2022
1 parent a057da6 commit f3efd80
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions nanoFramework.GiantGecko.Adc/AdcController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ public bool StartAveragedContinuousSampling(AdcChannel[] channels, int count)
_scanChannels = channels;

// set average count to 1 for single sample
// update flag upon successful start
_continuousSamplingStarted = NativeStartContinuousConversion(count);

return _continuousSamplingStarted;
// flag is updated in native code upon successful start
return NativeStartContinuousConversion(count);
}

/// <summary>
Expand All @@ -183,11 +181,8 @@ public void StopContinuousSampling()
{
CheckIfContinuousSamplingIsStarted(true);

NativeStoptContinuousConversion();

// update flag
_continuousSamplingStarted = false;

// flag is updated in native code upon successful start
NativeStopContinuousConversion();
}

private void CheckIfContinuousSamplingIsStarted(bool invertCheck = false)
Expand Down Expand Up @@ -219,7 +214,7 @@ private void CheckIfContinuousSamplingIsStarted(bool invertCheck = false)
private extern bool NativeStartContinuousConversion(int count);

[MethodImpl(MethodImplOptions.InternalCall)]
private extern bool NativeStoptContinuousConversion();
private extern void NativeStopContinuousConversion();

[MethodImpl(MethodImplOptions.InternalCall)]
private extern int[] NativeGetLastContinuousSamples();
Expand Down

0 comments on commit f3efd80

Please sign in to comment.