[chronojump/michrolab] Fixed some wrong redrawing of values



commit 52ac637e0381db9866e286dfb51e7989b09b75ae
Author: Xavier Padullés <testing chronojump org>
Date:   Wed Aug 31 15:43:57 2022 +0200

    Fixed some wrong redrawing of values

 arduino/michrolab/graphs.ino    | 78 ++++++++++++++++++++---------------------
 arduino/michrolab/menus.ino     |  8 ++---
 arduino/michrolab/michrolab.ino | 12 +++----
 3 files changed, 45 insertions(+), 53 deletions(-)
---
diff --git a/arduino/michrolab/graphs.ino b/arduino/michrolab/graphs.ino
index 0fe6d9254..de0c8c1de 100644
--- a/arduino/michrolab/graphs.ino
+++ b/arduino/michrolab/graphs.ino
@@ -61,7 +61,7 @@ void Graph(ILI9341_t3 & d, double x, double y, double gx, double gy, double w, d
   oy = y;
 
 }
-void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double xlo, double xhi, double 
ylo, double yhi, double yinc, String title, String xlabel, String ylabel, unsigned int gcolor, unsigned int 
acolor, unsigned int pcolor, unsigned int tcolor, unsigned int bcolor, unsigned int goalColor, boolean 
resize){
+void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double xlo, double xhi, double 
ylo, double yhi, double yinc, String title, String xlabel, String ylabel, unsigned int gcolor, unsigned int 
acolor, unsigned int pcolor, unsigned int tcolor, unsigned int bcolor, unsigned int goalColor, boolean 
resize) {
   redrawAxes(d, gx, gy, w, h, xlo, xhi, ylo, yhi, yinc, title, xlabel, ylabel, gcolor, acolor, pcolor, 
tcolor, bcolor, goalColor, resize, 0);
 }
 void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double xlo, double xhi, double 
ylo, double yhi, double yinc, String title, String xlabel, String ylabel, unsigned int gcolor, unsigned int 
acolor, unsigned int pcolor, unsigned int tcolor, unsigned int bcolor, unsigned int goalColor, boolean 
resize, int dec)
@@ -83,7 +83,7 @@ void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double
   }
 
   if (resize){
-    tft.drawRect(0, 0, gx, gy, BLACK);
+    tft.fillRect(0, 0, gx, gy+4, BLACK);
     //Vertical line
     //d.drawLine(gx, gy, gx, gy - h, acolor);
   }
@@ -102,8 +102,8 @@ void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double
     //If the scale has changed the numbers must be redrawn
     if (resize)
     {
-      if(dec == 0) printTftValue(i, gx - 6, yAxis - 3, 1, dec);
-      else if(dec > 0) printTftValue(i, gx - 6 - 5*(dec + 1), yAxis - 3, 1, dec);
+      if (dec == 0) printTftValue(i, gx - 6, yAxis - 3, 1, dec);
+      else if (dec > 0) printTftValue(i, gx - 6 - 5 * (dec + 1), yAxis - 3, 1, dec);
     }
   }
 
@@ -137,14 +137,14 @@ void redrawAxes(ILI9341_t3 & d, double gx, double gy, double w, double h, double
 
 void barPlot (float gx, float gy, float w, float h, float yhi, int numBars, int currentIndex, float abRatio, 
unsigned int color)
 {
-/*
- * currentIndex is the las updated slot of the array
- * a is the separation between bars
- * b is the width of the bar
- * System of 2 equations:
- * abRatio = a/b
- * width = n * (a+b) + a
- */
+  /*
+     currentIndex is the las updated slot of the array
+     a is the separation between bars
+     b is the width of the bar
+     System of 2 equations:
+     abRatio = a/b
+     width = n * (a+b) + a
+  */
   //Solution of the system of 2 equations
   float b = w / (numBars + abRatio + abRatio * numBars);
   float a = b * abRatio;
@@ -152,54 +152,54 @@ void barPlot (float gx, float gy, float w, float h, float yhi, int numBars, int
   float barValue = 0;
   float barPixHeight = 0;
 
-//
-//  for(int i = currentIndex + 1; i <= currentIndex + 10; i++)
-//  {
-//    Serial.print(i % 10);
-//    Serial.print("\t");
-//  }
-//
-//  Serial.println();
-//
-//  for(int i = currentIndex + 1; i <= currentIndex + 10; i++)
-//  {
-//    Serial.print(bars[ i % 10]);
-//    Serial.print("\t");
-//  }
-//
-//
-//  Serial.println();
-  
+  //
+  //  for(int i = currentIndex + 1; i <= currentIndex + 10; i++)
+  //  {
+  //    Serial.print(i % 10);
+  //    Serial.print("\t");
+  //  }
+  //
+  //  Serial.println();
+  //
+  //  for(int i = currentIndex + 1; i <= currentIndex + 10; i++)
+  //  {
+  //    Serial.print(bars[ i % 10]);
+  //    Serial.print("\t");
+  //  }
+  //
+  //
+  //  Serial.println();
+
   //the first bar to plot corresponds to the last updated slot of the array
 
   //Deleting the previous bars (The older bar are not in the buffer)
-  for (int i = 1; i<10; i++)
+  for (int i = 1; i < 10; i++)
   {
     localX -= a;
     barValue = bars[ (currentIndex - i + 10) % 10];
     barPixHeight =  barValue * h / yhi;
-    tft.fillRect(gx+localX, gy - barPixHeight , b, barPixHeight, BLACK);
+    tft.fillRect(gx + localX, gy - barPixHeight , b, barPixHeight, BLACK);
     localX -= b;
   }
 
   //Deleting the most left Bar
   localX -= a;
-  tft.fillRect(gx+localX, gy - h , b, h, BLACK);
+  tft.fillRect(gx + localX, gy - h , b, h, BLACK);
   localX = w - b;
-  
-  for (int i = 0; i<10; i++)
+
+  for (int i = 0; i < 10; i++)
   {
     localX -= a;
     barValue = bars[ (currentIndex - i + 10) % 10];
     barPixHeight =  barValue * h / yhi;
     //Serial.println(String(gx+localX) + "," + String(gy) + "\t" + String(b) + "," + String(bars[ (i + 10 - 
numBars) % 10]));
-    if(i==0){
-      tft.fillRect(gx+localX, gy - barPixHeight , b, barPixHeight, RED);
+    if (i == 0) {
+      tft.fillRect(gx + localX, gy - barPixHeight , b, barPixHeight, RED);
     } else {
-      tft.fillRect(gx+localX, gy - barPixHeight , b, barPixHeight, BLUE);
+      tft.fillRect(gx + localX, gy - barPixHeight , b, barPixHeight, BLUE);
     }
     localX -= b;
   }
 
-//  Serial.println("-----");
+  //  Serial.println("-----");
 }
diff --git a/arduino/michrolab/menus.ino b/arduino/michrolab/menus.ino
index 4c2e51998..ab4f196d6 100644
--- a/arduino/michrolab/menus.ino
+++ b/arduino/michrolab/menus.ino
@@ -170,13 +170,11 @@ float selectValueDialog(String description, String rangesString, String incStrin
     //Selecting the force goal
     //TODO: Allow coninuous increasing by keeping pressed the button
     if (blueButton.fell()) {
-      tft.setTextColor(BLACK);
-      printTftValue(value, 236, 174, 2, decimals);
+      printTftValue(value, 236, 174, 2, decimals, BLACK);
       
       value += incValues[currentSegment - 1];
       if (abs(value -  rangesValues[rangesNum] - incValues[currentSegment - 1]) < 0.0001) {
-        tft.setTextColor(BLACK);
-        printTftValue(value, 236, 174, 2, decimals);
+        printTftValue(value, 236, 174, 2, decimals, BLACK);
         value = rangesValues[0];
         currentSegment = 1;
         drawLeftButton("+" + String(incValues[currentSegment - 1], decimals), WHITE, BLUE);
@@ -187,8 +185,6 @@ float selectValueDialog(String description, String rangesString, String incStrin
         currentSegment++;
         drawLeftButton("+" + String(incValues[currentSegment - 1], decimals), WHITE, BLUE);
       }
-      tft.setTextColor(WHITE);
-      tft.setCursor(216, 150);
       printTftValue(value, 236, 174, 2, decimals);
     }
 
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index aeac19f21..aac6f4086 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -672,7 +672,7 @@ void startLoadCellCapture(void)
     newGraphMax = forceGoal * 1.5;
   } else {
     newGraphMin = -100;
-    newGraphMax = max(300, measuredMax * 1.5);
+    newGraphMax = max(100, measuredMax * 1.5);
   }
 }
 
@@ -857,7 +857,6 @@ void updateTime( unsigned int decimals, float limit )
   //    tft.setTextColor(BLACK);
   //    printTftValue(totalTime / 1000000 - 1, 302, 215, 2, 0);
   //  }
-  tft.setTextColor(WHITE);
   if (limit == 0) {
     printTftValue(totalTime / 1000000, 302, 215, 2, decimals);
   }
@@ -1079,8 +1078,7 @@ void captureRaw()
             {
               capturingPreSteadiness = false;
               capturingSteadiness = true;
-              tft.setTextColor(BLACK);
-              printTftValue(totalTime / 1000000, 284, 215, 2, 0);
+              printTftValue(totalTime / 1000000, 284, 215, 2, 0, BLACK);
               redrawAxes(tft, graphX, graphY, graphW, graphH, xMin, xMax, graphMin, graphMax, yDivSize, "", 
"", "", WHITE, BLACK, BLACK, BLACK, BLACK, BLACK, resized);
               startLoadCellCapture();
               newGraphMax = forceGoal * 1.5;
@@ -1123,10 +1121,8 @@ void captureRaw()
         xGraph++;
         if (measured > measuredMax)
         {
-          tft.setTextColor(BLACK);
-          printTftValue(measuredMax, 94, 215, 2, 1);
+          printTftValue(measuredMax, 94, 215, 2, 1, BLACK);
           measuredMax = measured;
-          tft.setTextColor(WHITE);
           printTftValue(measuredMax, 94, 215, 2, 1);
         }
 
@@ -1462,7 +1458,7 @@ void showPowerResults()
 
 void jumpsCapture()
 {
-  readExercisesFile(jumps);
+  if (totalJumpTypes == 0) readExercisesFile(jumps);
   //printJumpTypesList();
   selectExerciseType(jumps);
   IntervalTimer testTime;             //Timer that controls the refreshing of time in lower right corner


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