[chronojump] Encoder InertialFixed a bug on capture sum/sumInertialDisc unaligned along time, could affect sendin



commit a37ee822722570266c713dc4601250a6d1d58d16
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Mar 14 11:36:36 2022 +0100

    Encoder InertialFixed a bug on capture sum/sumInertialDisc unaligned along time, could affect sending 
curve to R

 src/encoderCapture.cs | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 539e56004..ade10d134 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Copyright (C) 2004-2020   Xavier de Blas <xaviblas gmail com> 
+ *  Copyright (C) 2004-2022   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -421,15 +421,20 @@ public abstract class EncoderCapture
                                }
 
                                sumInertialDisc += byteReaded;
+
                                encoderReadedInertialDisc.Add(byteReaded);
 
-                               if(inertialCalibrated && sumInertialDisc > 0)
-                                       byteReaded *= -1;
+                               //sum is the body, sumInertialDisc is the disc
+                               if(inertialCalibrated)
+                               {
+                                       int sumOld = sum;
+                                       sum = - Math.Abs(sumInertialDisc);
+                                       byteReaded = sum - sumOld;
+                               } else
+                                       sum += byteReaded;
 
-                               sum += byteReaded;
                                encoderReaded.Add(byteReaded);
 
-
                                if(! showOnlyBars)
                                {
                                        assignEncoderCapturePoints();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]