[chronojump/michrolab] Added jumps barplot
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] Added jumps barplot
- Date: Thu, 14 Jul 2022 09:34:48 +0000 (UTC)
commit 6b9ce39e627fc6c6be463641b6d815f90916e04f
Author: xpadulles <x padulles gmail com>
Date: Thu Jul 14 11:33:43 2022 +0200
Added jumps barplot
arduino/michrolab/graphs.ino | 24 ++++++++++++++----------
arduino/michrolab/michrolab.ino | 14 +++++++++-----
2 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/arduino/michrolab/graphs.ino b/arduino/michrolab/graphs.ino
index d97a881ec..fc79bb302 100644
--- a/arduino/michrolab/graphs.ino
+++ b/arduino/michrolab/graphs.ino
@@ -129,30 +129,34 @@ 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)
+{
/*
- *
* 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
*/
-void barPlot (float gx, float gy, float w, float h, float yhi, int numBars, int currentIndex, float abRatio,
unsigned int color)
-{
//Solution of the system of 2 equations
float b = w / (numBars + abRatio + abRatio * numBars);
float a = b * abRatio;
- float localX = 0;
+ float localX = w - b;
float barValue = 0;
float barPixHeight = 0;
- for (int i = currentIndex; i< currentIndex + numBars; i++)
+ for (int i = 0; i<10; i++)
{
- localX += a;
- barValue = bars[ (i + 10 - numBars) % 10];
+ 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]));
- tft.fillRect(gx+localX, gy - barPixHeight , b, barPixHeight, color);
- localX += b;
+ //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);
+ } else {
+ tft.fillRect(gx+localX, gy - barPixHeight , b, barPixHeight, BLUE);
+ }
+ localX -= b;
}
}
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index 4d8919ff2..11c55c830 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -1342,8 +1342,12 @@ void startJumpsCapture()
rcaFlag = false;
float flightTime = 0;
bool firstContact = true;
+
+ for (int i = 0; i<10; i++)
+ {
+ bars[i] = 0;
+ }
tft.fillScreen(BLACK);
-//Testing barPlot
redrawAxes(tft, 30, 200, 290, 200, 290, 200, 0, 100, 10, "", "", "", WHITE, GREY, WHITE, WHITE, BLACK,
RED, true);
redButton.update();
int index = 0;
@@ -1353,7 +1357,7 @@ void startJumpsCapture()
{
rcaFlag = false;
Serial.print(rcaTime);
- Serial.print(":");
+ Serial.println(":");
if(rcaState)
{
Serial.println("R;");
@@ -1361,13 +1365,13 @@ void startJumpsCapture()
} else if(!rcaState && !firstContact)
{
Serial.println("r;");
- barPlot(30, 200, 290, 200, 100, 10, (index -1)%10, 0.5, BLACK);
- index = (index + 1) % 10;
+ //barPlot(30, 200, 290, 200, 100, 10, (index -1)%10, 0.5, BLACK);
+ tft.fillRect(30,0,290,200, BLACK);
flightTime = (float)(rcaTime - lastRcaTime) / 1E6;
bars[index] = 122.6*flightTime*flightTime; //In cm
- Serial.println(bars[index]);
redrawAxes(tft, 30, 200, 290, 200, 290, 200, 0, 100, 10, "", "", "", WHITE, GREY, WHITE, WHITE,
BLACK, RED, true);
barPlot(30, 200, 290, 200, 100, 10, index, 0.5, RED);
+ index = (index + 1) % 10;
}
lastRcaState = rcaState;
lastRcaTime = rcaTime;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]