[chronojump/FS-LCD-Menu] Added maximum mean force during 1s
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/FS-LCD-Menu] Added maximum mean force during 1s
- Date: Tue, 4 Jan 2022 12:26:41 +0000 (UTC)
commit 4893a016f06b69b1836519bc5504ab81943fb892
Author: xpadulles <x padulles gmail com>
Date: Tue Jan 4 13:25:47 2022 +0100
Added maximum mean force during 1s
arduino/ForceSensorLCD/ForceSensorLCD.ino | 34 ++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/arduino/ForceSensorLCD/ForceSensorLCD.ino b/arduino/ForceSensorLCD/ForceSensorLCD.ino
index f2a0b7e8a..47ae7e1d9 100644
--- a/arduino/ForceSensorLCD/ForceSensorLCD.ino
+++ b/arduino/ForceSensorLCD/ForceSensorLCD.ino
@@ -204,6 +204,14 @@ const String menuList [] = {
"---- System - "
};
+//Array where all measures in 1s are stored
+float forces1s[90];
+//The current position in the array
+int currentPosition = 0;
+//mean force during 1s
+float meanForce1s;
+float maxMeanForce1s = 0;
+
void setup() {
pinMode(redButtonPin, INPUT);
pinMode(blueButtonPin, INPUT);
@@ -367,6 +375,20 @@ void capture(void)
currentTime = micros();
checkTimeOverflow();
float measured = scale.get_units();
+
+ currentPosition ++;
+ if (currentPosition >= 90) currentPosition = 0;
+ forces1s[currentPosition] = measured;
+
+ //Calculating the average during 1s
+ float sumForces = 0;
+ for (int i = 0; i<90; i++){
+ sumForces += forces1s[i];
+ }
+
+ meanForce1s = sumForces / 90;
+
+ if (abs(meanForce1s) > abs(maxMeanForce1s)) maxMeanForce1s = meanForce1s;
//RFD stuff start ------>
if (rfdDataPre2Ok) {
@@ -420,7 +442,8 @@ void printOnLcd() {
printLcdFormat (measuredLcdDelayMax, 4, 0, 1);
- printLcdFormat (measuredMax, 4, 1, 1);
+ //printLcdFormat (measuredMax, 4, 1, 1);
+ printLcdFormat (maxMeanForce1s, 4, 1, 1);
int totalTimeInSec = totalTime / 1000000;
printLcdFormat (totalTimeInSec, 10, 0, 0);
@@ -569,6 +592,15 @@ void start_capture()
rfdDataPre2Ok = false;
rfdCalculed = false;
rfdValueMax = 0;
+
+ //filling the array of forces with initial force
+ float measured = scale.get_units();
+ for (int i; i< 90; i++){
+ forces1s[i] = measured;
+ }
+
+ capturing = true;
+ delay(500);
capturing = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]