[chronojump] Method: GetSampleOrPreviousAtTimeUs to get a sample from time
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Method: GetSampleOrPreviousAtTimeUs to get a sample from time
- Date: Fri, 5 Nov 2021 22:24:07 +0000 (UTC)
commit 9d6074b76e04e79985e6d8b37456010e1552acba
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Nov 5 19:23:09 2021 -0300
Method: GetSampleOrPreviousAtTimeUs to get a sample from time
src/forceSensor.cs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index ed0f4d585..4e0bfda06 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -993,6 +993,22 @@ public class ForceSensorCapturePoints
return forces[count];
}
+ //gets which sample we have at some time in Us or if it does not match, returns previous sample
+ //startAtSample is to make algorithm more efficient
+ public int GetSampleOrPreviousAtTimeUs (int us, int startAtSample)
+ {
+ int lastPos = startAtSample;
+ for(int i = startAtSample; i < times.Count; i ++)
+ {
+ if(times[i] > us)
+ return lastPos;
+
+ lastPos ++;
+ }
+
+ return lastPos;
+ }
+
public void GetAverageAndMaxForce(int countA, int countB, out double avg, out double max)
{
if(countA == countB) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]