[chronojump] ForceSensor analyze sliders +1s (or whatever) can adjust with previous value (if closer)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensor analyze sliders +1s (or whatever) can adjust with previous value (if closer)
- Date: Mon, 15 Feb 2021 14:22:06 +0000 (UTC)
commit 8ac039c7e5ec109cb72eedaf5b969c9c3604fd2b
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 15 15:20:38 2021 +0100
ForceSensor analyze sliders +1s (or whatever) can adjust with previous value (if closer)
src/gui/app1/forceSensorAnalyze.cs | 37 +++++++++++++++++++++++++++++++++----
src/utilMath.cs | 18 ++++++++++++++++++
2 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/src/gui/app1/forceSensorAnalyze.cs b/src/gui/app1/forceSensorAnalyze.cs
index cc138d38..f75f2b78 100644
--- a/src/gui/app1/forceSensorAnalyze.cs
+++ b/src/gui/app1/forceSensorAnalyze.cs
@@ -1809,7 +1809,15 @@ public partial class ChronoJumpWindow
{
if(startAMs - fsAI.GetTimeMS(i) >= preferences.forceSensorAnalyzeABSliderIncrement *
1000)
{
- hscale_force_sensor_ai_a.Value += i - startA;
+ //hscale_force_sensor_ai_a.Value += i - startA; is the sample where condition
is done,
+ //but maybe the sample before that condition is more close to 1s than this
+ if(MathUtil.PassedSampleIsCloserToCriteria (
+ startAMs - fsAI.GetTimeMS(i), startAMs - fsAI.GetTimeMS(i+1),
+ preferences.forceSensorAnalyzeABSliderIncrement * 1000))
+ hscale_force_sensor_ai_a.Value += (i - startA);
+ else
+ hscale_force_sensor_ai_a.Value += (i+1 - startA);
+
return;
}
}
@@ -1825,7 +1833,14 @@ public partial class ChronoJumpWindow
{
if(fsAI.GetTimeMS(i) - startAMs >= preferences.forceSensorAnalyzeABSliderIncrement *
1000)
{
- hscale_force_sensor_ai_a.Value += i - startA;
+ //hscale_force_sensor_ai_a.Value += i - startA;
+ if(MathUtil.PassedSampleIsCloserToCriteria (
+ fsAI.GetTimeMS(i) - startAMs, fsAI.GetTimeMS(i-1) - startAMs,
+ preferences.forceSensorAnalyzeABSliderIncrement * 1000))
+ hscale_force_sensor_ai_a.Value += (i - startA);
+ else
+ hscale_force_sensor_ai_a.Value += (i-1 - startA);
+
return;
}
}
@@ -1842,7 +1857,14 @@ public partial class ChronoJumpWindow
{
if(startBMs - fsAI.GetTimeMS(i) >= preferences.forceSensorAnalyzeABSliderIncrement *
1000)
{
- hscale_force_sensor_ai_b.Value += i - startB;
+ //hscale_force_sensor_ai_b.Value += i - startB;
+ if(MathUtil.PassedSampleIsCloserToCriteria (
+ startBMs - fsAI.GetTimeMS(i), startBMs - fsAI.GetTimeMS(i+1),
+ preferences.forceSensorAnalyzeABSliderIncrement * 1000))
+ hscale_force_sensor_ai_b.Value += (i - startB);
+ else
+ hscale_force_sensor_ai_b.Value += (i+1 - startB);
+
return;
}
}
@@ -1858,7 +1880,14 @@ public partial class ChronoJumpWindow
{
if(fsAI.GetTimeMS(i) - startBMs >= preferences.forceSensorAnalyzeABSliderIncrement *
1000)
{
- hscale_force_sensor_ai_b.Value += i - startB;
+ //hscale_force_sensor_ai_b.Value += i - startB;
+ if(MathUtil.PassedSampleIsCloserToCriteria (
+ fsAI.GetTimeMS(i) - startBMs, fsAI.GetTimeMS(i-1) - startBMs,
+ preferences.forceSensorAnalyzeABSliderIncrement * 1000))
+ hscale_force_sensor_ai_b.Value += (i - startB);
+ else
+ hscale_force_sensor_ai_b.Value += (i-1 - startB);
+
return;
}
}
diff --git a/src/utilMath.cs b/src/utilMath.cs
index 256f5c38..ac9ef2ca 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -368,4 +368,22 @@ public static class MathUtil
else
return false;
}
+
+ /*
+ public static double ClosestNumber(double num1, double num2, double numToCompare)
+ {
+ LogB.Information(string.Format("Compare: {0} and {1} with: {2}", num1, num2, numToCompare));
+ if( Math.Abs(num1 - numToCompare) <= Math.Abs(num2 - numToCompare) )
+ return num1;
+
+ return num2;
+ }
+ */
+ public static bool PassedSampleIsCloserToCriteria (
+ double criteriaPassedValue, double previousToCriteriaValue, double numToCompare)
+ {
+ LogB.Information(string.Format("Compare: {0} and {1} with: {2}", criteriaPassedValue,
previousToCriteriaValue, numToCompare));
+ return ( Math.Abs(criteriaPassedValue - numToCompare) <= Math.Abs(previousToCriteriaValue -
numToCompare) );
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]