[chronojump/FS-TFT-Menu] Fixed reverse signal on CairoGraphEncoderSignal when screen height is very low



commit 1bf103744ef58a316aac8aeb687e458abd273ce4
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Apr 10 12:54:31 2022 +0200

    Fixed reverse signal on CairoGraphEncoderSignal when screen height is very low

 src/gui/cairo/encoder.cs | 5 +++++
 src/gui/cairo/xy.cs      | 9 +++++++++
 2 files changed, 14 insertions(+)
---
diff --git a/src/gui/cairo/encoder.cs b/src/gui/cairo/encoder.cs
index afc58fad2..f07df61c0 100644
--- a/src/gui/cairo/encoder.cs
+++ b/src/gui/cairo/encoder.cs
@@ -41,6 +41,11 @@ public class CairoGraphEncoderSignal : CairoXY
                //doing = false;
                points_list_painted = 0;
                points_list_inertial_painted = 0;
+
+               //need to be small because graphHeight could be 100,
+               //if margins are big then calculatePaintY could give us reverse results
+               outerMargin = 10;
+               innerMargin = 0;
        }
 
        //separated in two methods to ensure endGraphDisposing on any return of the other method
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 72cfa8be8..8380d1c69 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -665,6 +665,15 @@ public abstract class CairoXY : CairoGeneric
        {
                 //return graphHeight - totalMargins - ((realY - minY) * (graphHeight - totalMargins - 
totalMargins) / (absoluteMaxY - minY));
                //to avoid /0 problems (eg raceAnalyzer change person: absoluteMaxY-minY = 0
+
+               /* debug:
+               LogB.Information(string.Format("graphHeight: {0}, totalMargins: {1}, restOfFormula: {2}",
+                                       graphHeight, totalMargins,
+                                       (realY - minY) * UtilAll.DivideSafe (
+                               graphHeight - totalMargins - totalMargins,
+                               absoluteMaxY - minY) ));
+               */
+
                 return graphHeight - totalMargins - ((realY - minY) * UtilAll.DivideSafe (
                                graphHeight - totalMargins - totalMargins,
                                absoluteMaxY - minY));


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