[chronojump/michrolab] Added fields to jumpTypes and improved compatibility with SD
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] Added fields to jumpTypes and improved compatibility with SD
- Date: Wed, 3 Aug 2022 13:27:46 +0000 (UTC)
commit 22ab3467ec3eb7f11dc3c5d28d15d96d8d46dbf2
Author: Xavier Padullés <x padulles gmail com>
Date: Wed Aug 3 15:27:06 2022 +0200
Added fields to jumpTypes and improved compatibility with SD
arduino/michrolab/SDExample/JumpType.txt | 19 ++++++++++---------
arduino/michrolab/exercsiseManage.ino | 29 +++++++++++++++++++++++++++--
arduino/michrolab/michrolab.ino | 19 ++++++++++++-------
arduino/michrolab/personsManage.ino | 4 ++--
4 files changed, 51 insertions(+), 20 deletions(-)
---
diff --git a/arduino/michrolab/SDExample/JumpType.txt b/arduino/michrolab/SDExample/JumpType.txt
index 3af78bb5a..48fa8ee33 100644
--- a/arduino/michrolab/SDExample/JumpType.txt
+++ b/arduino/michrolab/SDExample/JumpType.txt
@@ -1,9 +1,10 @@
-1,Free,1
-1,SJ,1
-3,SJl,1
-4,CMJ,1
-5,CMJl,1
-6,slCMJleft,1
-7,slCMJright,1
-8,ABK,1
-10,DJa,0
+#id, name, jumpLimit,timeLimit, hardTimeLimit, percentBodyWeight, fall, startIn
+1,Free,1,0,0,0,0,1
+2,SJ,1,0,0,0,0,1
+3,SJl100,1,0,0,100,0,1
+4,CMJ,1,0,0,0,0,1
+5,CMJl,1,0,0,100,0,1
+6,slCMJleft,1,0,0,0,0,1
+7,slCMJright,1,0,0,0,0,1
+8,ABK,1,0,0,0,0,1
+10,DJa,1,0,0,0,0,0
diff --git a/arduino/michrolab/exercsiseManage.ino b/arduino/michrolab/exercsiseManage.ino
index b54c790b0..12c394267 100644
--- a/arduino/michrolab/exercsiseManage.ino
+++ b/arduino/michrolab/exercsiseManage.ino
@@ -9,6 +9,26 @@ void addJump(String row)
nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
jumpTypes[currentJumpType].name = row.substring(prevComaIndex + 1 , nextComaIndex);
prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ jumpTypes[currentJumpType].jumpLimit = row.substring(prevComaIndex + 1, nextComaIndex).toInt();
+ prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ jumpTypes[currentJumpType].timeLimit = row.substring(prevComaIndex + 1, nextComaIndex).toFloat();
+ prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ jumpTypes[currentJumpType].hardTimeLimit = (row.substring(prevComaIndex + 1 , nextComaIndex) == 1);
+ prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ jumpTypes[currentJumpType].fall = row.substring(prevComaIndex + 1, nextComaIndex).toFloat();
+ prevComaIndex = nextComaIndex;
nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
jumpTypes[currentJumpType].startIn = (row.substring(prevComaIndex + 1 , nextComaIndex) == "1");
@@ -34,7 +54,7 @@ void readJumpTypesFile()
readString = readString + readChar;
pos++;
}
- //Check that it is a valid row
+ //Check that it is a valid row.
if ( isDigit(readString[0]) )
{
numRows++;
@@ -52,7 +72,12 @@ void printJumpTypesList()
for (unsigned int i = 0; i < totalJumpTypes; i++)
{
Serial.print(jumpTypes[i].id);
- Serial.print("," + jumpTypes[i].name + ",");
+ Serial.print("," + jumpTypes[i].name + " ,");
+ Serial.print(String( jumpTypes[i].jumpLimit , 2) + " ,");
+ Serial.print(String( jumpTypes[i].timeLimit ) + "s ,");
+ Serial.print(String( jumpTypes[i].hardTimeLimit) + " ,");
+ Serial.print(String( jumpTypes[i].percentBodyWeight , 2) + "% ,");
+ Serial.print(String( jumpTypes[i].fall , 2) + "cm ,");
Serial.println(jumpTypes[i].startIn);
}
}
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index 717d0b208..31f78853c 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -306,8 +306,13 @@ unsigned int totalPersons = 0;
personType persons[100];
struct jumpType {
- int id;
+ unsigned int id;
String name;
+ unsigned int jumpLimit;
+ float timeLimit;
+ bool hardTimeLimit;
+ float percentBodyWeight;
+ float fall;
bool startIn; //If the time of contact is required, start outside or start inside but make a previous
jump
};
@@ -1443,7 +1448,7 @@ void dropJumpsCapture()
float graphRange = 50;
fileName = String("D") + "-S" + String(setNumber);
String fullFileName = "/" + dirName + "/" + fileName + ".txt";
- File dataFile = SD.open(fullFileName, FILE_WRITE);
+ File dataFile = SD.open(fullFileName.c_str(), FILE_WRITE);
lastRcaState = !digitalRead(rcaPin);
rcaFlag = false;
bool jumpStart = rcaState;
@@ -1612,7 +1617,7 @@ void saveSD(String fileName)
return;
}
String fullFileName = "/" + dirName + "/" + fileName + sensorString + ".txt";
- File dataFile = SD.open(fullFileName, FILE_WRITE);
+ File dataFile = SD.open(fullFileName.c_str(), FILE_WRITE);
dataFile.println(String(lastSampleTime) + ";" + String(measured));
dataFile.close();
}
@@ -1646,8 +1651,8 @@ String createNewDir()
dirNumber = countDirs() + 1;
dirName = "ML";
dirName = dirName + addLeadingZeros(dirNumber, 4) + "G" + String(group);
- SD.mkdir(dirName);
- return (dirName);
+ SD.mkdir(dirName.c_str());
+ return (dirName.c_str());
}
String addLeadingZeros(int number, int totalDigits)
@@ -1725,7 +1730,7 @@ void selectPerson()
void saveSimpleJump(float lastPhaseTime)
{
String fullFileName = "/" + dirName + "/" + fileName + ".txt";
- File dataFile = SD.open(fullFileName, FILE_WRITE);
+ File dataFile = SD.open(fullFileName.c_str(), FILE_WRITE);
if ( !rcaState)
{
dataFile.print(String(currentPerson) + ";" + jumpTypes[currentJumpType].id + ";" + String(lastPhaseTime,
6) );
@@ -1741,7 +1746,7 @@ void saveDropJump(float lastPhaseTime)
{
Serial.println(waitingFirstPhase);
String fullFileName = "/" + dirName + "/" + fileName + ".txt";
- File dataFile = SD.open(fullFileName, FILE_WRITE);
+ File dataFile = SD.open(fullFileName.c_str(), FILE_WRITE);
if (waitingFirstPhase)
{
//Starts the previous jump
diff --git a/arduino/michrolab/personsManage.ino b/arduino/michrolab/personsManage.ino
index 518e376de..41b1ea7f9 100644
--- a/arduino/michrolab/personsManage.ino
+++ b/arduino/michrolab/personsManage.ino
@@ -61,7 +61,7 @@ void readPersonsFile()
String row = "";
char readChar;
String filename = "group"+String(group)+".txt";
- File personsFile = SD.open(filename);
+ File personsFile = SD.open(filename.c_str());
if (personsFile)
{
currentPerson = 0;
@@ -94,7 +94,7 @@ unsigned int getTotalPerson()
char readChar;
String readString = "";
String filename = "group"+String(group)+".txt";
- File personsFile = SD.open(filename);
+ File personsFile = SD.open(filename.c_str());
if (personsFile)
{
//Start reading from the last byte
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]