[chronojump/michrolab] Added inertial exercices management
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] Added inertial exercices management
- Date: Thu, 1 Sep 2022 17:41:26 +0000 (UTC)
commit ee53b60a02ad2e67bcfa5829d61668a8378ddab4
Author: xpadulles <x padulles gmail com>
Date: Thu Sep 1 19:40:44 2022 +0200
Added inertial exercices management
arduino/michrolab/SDExample/INERTYPE.TXT | 6 +++
arduino/michrolab/commandExamples.txt | 11 ++++++
arduino/michrolab/exercsiseManage.ino | 67 ++++++++++++++++++++++++++++++++
arduino/michrolab/menus.ino | 9 +++++
arduino/michrolab/michrolab.ino | 48 +++++++++++++++++------
5 files changed, 130 insertions(+), 11 deletions(-)
---
diff --git a/arduino/michrolab/SDExample/INERTYPE.TXT b/arduino/michrolab/SDExample/INERTYPE.TXT
new file mode 100644
index 000000000..f09f65733
--- /dev/null
+++ b/arduino/michrolab/SDExample/INERTYPE.TXT
@@ -0,0 +1,6 @@
+#id, name, description, percentBodyWeight
+0,Pull,Pulling with one hand,0.0
+1,Squat,Squat movement,100
+2,Lateral displacement,Lateral movements,100.0
+3,Frontal displacement,The rope pulls from the back,100.0
+4,Backward displacement,The rope pulls from the front,100.0
diff --git a/arduino/michrolab/commandExamples.txt b/arduino/michrolab/commandExamples.txt
index 32874b0e7..6a3111b0c 100644
--- a/arduino/michrolab/commandExamples.txt
+++ b/arduino/michrolab/commandExamples.txt
@@ -41,6 +41,17 @@ addGravitatoryType:5,Bench Press,Typical Bench press with a barbell,0,0.185;
getGravitatoryTypes: //Shows the gravitatory exercises types
saveGravitatoryTypes: //Saves the gravitatory exercises types to the GRAVTYPES.TXT
file in the SD
+ ## Inertial ##
+
+readExercisesFile:inertial; //Reads the INERTYPES.TXT and adds each row as a inertial exercise
type
+deleteInertialTypes: //Delete inertial exercise types in memory. It doesn't delete from
SD
+
+#addInertialType:id,name,description,percentBodyWeight;
+addInertialType:0,Pull,Pulling with one hand,0.0; //Adds a inertial exercise type. It doesn't save it
to SD
+
+getInertialTypes: //Shows the inertial exercises types
+saveInertialTypes: //Saves the inertial exercises types to the INERTYPES.TXT file in
the SD
+
## Force sensosr ##
start_capture: //Starts the acquiring process
diff --git a/arduino/michrolab/exercsiseManage.ino b/arduino/michrolab/exercsiseManage.ino
index da7bb1a7f..2e9f76c47 100644
--- a/arduino/michrolab/exercsiseManage.ino
+++ b/arduino/michrolab/exercsiseManage.ino
@@ -114,10 +114,58 @@ void saveGravitatoryList()
Serial.println("Saved " + String(totalGravTypes) + " to GRAVTYPE.TXT");
}
+void addInertial(String row)
+{
+ int prevComaIndex = row.indexOf(":");
+ int nextComaIndex = row.indexOf(",");
+ //totalInertTypes = row.substring(prevComaIndex + 1, nextComaIndex).toInt();
+ inertTypes[totalInertTypes].id = row.substring(prevComaIndex + 1, nextComaIndex).toInt();
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ inertTypes[totalInertTypes].name = row.substring(prevComaIndex + 1 , nextComaIndex);
+ prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ inertTypes[totalInertTypes].description = row.substring(prevComaIndex + 1, nextComaIndex);
+ prevComaIndex = nextComaIndex;
+
+ prevComaIndex = nextComaIndex;
+ nextComaIndex = row.indexOf(",", prevComaIndex + 1 );
+ inertTypes[totalInertTypes].percentBodyWeight = row.substring(prevComaIndex + 1 , nextComaIndex).toFloat();
+ prevComaIndex = nextComaIndex;
+
+ totalInertTypes++;
+}
+
+
+void saveInertialList()
+{
+ SD.remove("INERTYPE.TXT");
+
+ File inertFile = SD.open("INERTYPE.TXT", FILE_WRITE);
+
+// if(gravFile) Serial.println("File created");
+// else Serial.println("Error creating file");
+
+ for (unsigned int i = 0; i < totalInertTypes; i++)
+ {
+ inertFile.print(jumpTypes[i].id);
+ inertFile.print("," + String(gravTypes[i].name));
+ inertFile.print("," + gravTypes[i].description );
+ inertFile.print("," + String(gravTypes[i].percentBodyWeight));
+ inertFile.println("," + String(gravTypes[i].speed1Rm));
+ }
+ inertFile.close();
+ Serial.println("Saved " + String(totalInertTypes) + " to GRAVTYPE.TXT");
+}
+
void readExercisesFile(String parameters){
parameters = parameters.substring(0, parameters.lastIndexOf(";"));
if ( parameters == "jumps" ) readExercisesFile(jumps);
else if ( parameters == "gravitatory" ) readExercisesFile(gravitatory);
+ else if ( parameters == "inertial" ) readExercisesFile(inertial);
else Serial.print("Not a valid parameter");
}
void readExercisesFile(exerciseType mode)
@@ -136,6 +184,10 @@ void readExercisesFile(exerciseType mode)
//Serial.println("G");
file = "GRAVTYPE.TXT";
}
+ else if (mode == inertial) {
+ //Serial.println("G");
+ file = "INERTYPE.TXT";
+ }
File exercisesFile = SD.open(file);
@@ -167,6 +219,9 @@ void readExercisesFile(exerciseType mode)
} else if (mode == gravitatory) {
addGravitatory(readString);
totalGravTypes = numRows;
+ } else if (mode == inertial) {
+ addInertial(readString);
+ totalInertTypes = numRows;
}
}
}
@@ -205,3 +260,15 @@ void printGravTypesList()
Serial.println(String( gravTypes[i].speed1Rm , 2) + "m/s");
}
}
+
+void printInertTypesList()
+{
+ Serial.println("id, name, description, percentBodyWeight");
+ for (unsigned int i = 0; i < totalInertTypes; i++)
+ {
+ Serial.print(String(inertTypes[i].id) + ", ");
+ Serial.print(inertTypes[i].name + ", ");
+ Serial.print(inertTypes[i].description + ", ");
+ Serial.println(String( inertTypes[i].percentBodyWeight , 2) + "%, ");
+ }
+}
diff --git a/arduino/michrolab/menus.ino b/arduino/michrolab/menus.ino
index ab4f196d6..94f6cbec4 100644
--- a/arduino/michrolab/menus.ino
+++ b/arduino/michrolab/menus.ino
@@ -215,6 +215,10 @@ void selectExerciseType(exerciseType mode)
printTftText("Gravit. type", 40, 20, WHITE, 3);
printTftText(gravTypes[currentExerciseType].name, 50, 100);
}
+ else if (mode == inertial) {
+ printTftText("Inertt. type", 40, 20, WHITE, 3);
+ printTftText(inertTypes[currentExerciseType].name, 50, 100);
+ }
drawLeftButton("Next", WHITE, BLUE);
drawRightButton("Accept", WHITE, RED);
@@ -238,6 +242,11 @@ void selectExerciseType(exerciseType mode)
currentExerciseType = (currentExerciseType + 1) % totalGravTypes;
printTftText(gravTypes[currentExerciseType].name, 50, 100);
}
+ else if (mode == inertial) {
+ printTftText(inertTypes[currentExerciseType].name, 50, 100, BLACK);
+ currentExerciseType = (currentExerciseType + 1) % totalInertTypes;
+ printTftText(inertTypes[currentExerciseType].name, 50, 100);
+ }
}
blueButton.update();
redButton.update();
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index 9cd971ae1..20df69ee3 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -348,6 +348,17 @@ struct gravitType {
gravitType gravTypes[100];
unsigned int totalGravTypes = 0;
+
+struct inertType {
+ unsigned int id;
+ String name;
+ String description;
+ float percentBodyWeight;
+};
+
+inertType inertTypes[100];
+unsigned int totalInertTypes = 0;
+
IntervalTimer rcaTimer;
String fullFileName;
File dataFile;
@@ -635,7 +646,16 @@ void serialEvent() {
} else if (commandString == "deleteGravitatoryTypes") {
totalGravTypes = 0;
} else if (commandString == "saveGravitatoryTypes") {
- saveGravitatoryList();
+ saveInertialList();
+ } else if (commandString == "getInertialTypes") {
+ printInertTypesList();
+ } else if (commandString == "addInertialType") {
+ addInertial(parameters);
+ //Serial.println("Gravitatory added");
+ } else if (commandString == "deleteInertialTypes") {
+ totalInertTypes = 0;
+ } else if (commandString == "saveInertialTypes") {
+ saveInertialList();
} else {
Serial.println("Not a valid command");
}
@@ -1325,6 +1345,15 @@ void getEncoderDynamics()
}
}
+
+void startInertialEncoderCapture()
+{
+ inertialMode = true;
+ if (!calibratedInertial) calibrateInertial();
+
+ startEncoderCapture();
+}
+
void startEncoderCapture(void)
{
capturing = true;
@@ -1347,9 +1376,14 @@ void startEncoderCapture(void)
avgVelocity = 0;
maxAvgVelocity = 0;
lastVelocity = 0;
- readExercisesFile(gravitatory);
selectPersonDialog();
- selectExerciseType(gravitatory);
+ if (!inertialMode ){
+ readExercisesFile(gravitatory);
+ selectExerciseType(gravitatory);
+ } else if( inertialMode ){
+ readExercisesFile(inertial);
+ selectExerciseType(inertial);
+ }
load = selectValueDialog("Select the load you are\ngoing to move", "0,5,20,200", "0.5,1,5", 1);
//captureRaw();
encoderTimer.begin(saveEncoderSpeed, 1000);
@@ -1795,14 +1829,6 @@ String addLeadingZeros(int number, int totalDigits)
return (fixLenNumber);
}
-void startInertialEncoderCapture()
-{
- inertialMode = true;
- if (!calibratedInertial) calibrateInertial();
-
- startEncoderCapture();
-}
-
void calibrateInertial()
{
printTftText(currentMenu[currentMenuIndex].description, 12, 100, BLACK);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]