[chronojump/michrolab] Minor changes in showing list
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/michrolab] Minor changes in showing list
- Date: Fri, 2 Sep 2022 19:06:19 +0000 (UTC)
commit ff3d359cfaf9474a3e4713f02db420437426011d
Author: Xavier Padullés <testing chronojump org>
Date: Fri Sep 2 21:05:54 2022 +0200
Minor changes in showing list
arduino/michrolab/exercsiseManage.ino | 47 +++++++++++++++++++++++++++++++++
arduino/michrolab/menus.ino | 49 -----------------------------------
arduino/michrolab/michrolab.ino | 29 +++++++++++++++++++--
arduino/michrolab/personsManage.ino | 44 +++++++++++--------------------
4 files changed, 89 insertions(+), 80 deletions(-)
---
diff --git a/arduino/michrolab/exercsiseManage.ino b/arduino/michrolab/exercsiseManage.ino
index 2e9f76c47..cc387b7ab 100644
--- a/arduino/michrolab/exercsiseManage.ino
+++ b/arduino/michrolab/exercsiseManage.ino
@@ -272,3 +272,50 @@ void printInertTypesList()
Serial.println(String( inertTypes[i].percentBodyWeight , 2) + "%, ");
}
}
+
+void selectExerciseType(exerciseType mode)
+{
+ tft.fillScreen(BLACK);
+ if (mode == jumps) {
+ printTftText("Jump type", 40, 20, WHITE, 3);
+ printTftText(jumpTypes[currentExerciseType].name, 50, 100);
+ }
+ else if (mode == gravitatory) {
+ 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);
+
+ blueButton.update();
+ redButton.update();
+ while(!redButton.fell())
+ {
+ if(blueButton.fell())
+ {
+
+ if (mode == jumps) {
+ printTftText(jumpTypes[currentExerciseType].name, 50, 100, BLACK);
+ currentExerciseType = (currentExerciseType + 1) % totalJumpTypes;
+ printTftText(jumpTypes[currentExerciseType].name, 50, 100);
+ }
+ else if (mode == gravitatory) {
+ printTftText(gravTypes[currentExerciseType].name, 50, 100, BLACK);
+ 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/menus.ino b/arduino/michrolab/menus.ino
index 673e3b553..bea2eba0a 100644
--- a/arduino/michrolab/menus.ino
+++ b/arduino/michrolab/menus.ino
@@ -207,55 +207,6 @@ float selectValueDialog(String description, String rangesString, String incStrin
return value;
}
-void selectExerciseType(exerciseType mode)
-{
- tft.fillScreen(BLACK);
- if (mode == jumps) {
- printTftText("Jump type", 40, 20, WHITE, 3);
- printTftText(jumpTypes[currentExerciseType].name, 50, 100);
- }
- else if (mode == gravitatory) {
- 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);
-
- blueButton.update();
- redButton.update();
- while(!redButton.fell())
- {
- if(blueButton.fell())
- {
-
- //Deleting last exercise type text and
- //Printing new exersise type text
- if (mode == jumps) {
- printTftText(jumpTypes[currentExerciseType].name, 50, 100, BLACK);
- currentExerciseType = (currentExerciseType + 1) % totalJumpTypes;
- printTftText(jumpTypes[currentExerciseType].name, 50, 100);
- }
- else if (mode == gravitatory) {
- printTftText(gravTypes[currentExerciseType].name, 50, 100, BLACK);
- 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();
- }
-}
-
bool yesNoDialog(String message, float x, float y) {
return yesNoDialog(message, x, y, 2);
}
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index 4cf00a821..d085fde0f 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -378,6 +378,8 @@ int sampleNum = 0;
String fileBuffer; //Text mode
//char fileBuffer[100]; //binary mode. Using char type cannot write speeds greater than +-127 pulses/mm
+String textList[7] = {"First", "Second", "Thirth", "Fourth", "Fifth", "Sixtth", "Seventh"} ;
+
void setup() {
//Attention: some SD cards fails to initalize after uploading the firmware
// See if the card is present and can be initialized:
@@ -454,7 +456,9 @@ void setup() {
//TODO: Read exercises only if necessary
currentExerciseType = 0;
+
tft.fillScreen(BLACK);
+
drawMenuBackground();
backMenu();
showMenuEntry(currentMenuIndex);
@@ -1382,7 +1386,7 @@ void startInertEncoderCapture()
sensor = incRotEncoder;
if (!calibratedInertial) calibrateInertial();
- readExercisesFile(inertial);
+ if(totalInertTypes == 0) readExercisesFile(inertial);
selectExerciseType(inertial);
load = selectValueDialog("Select the amount of extra loads attached to the machine", "0,18", "1", 0);
startEncoderCapture();
@@ -1392,7 +1396,7 @@ void startGravitEncoderCapture()
{
inertialMode = false;
sensor = incLinEncoder;
- readExercisesFile(gravitatory);
+ if(totalGravTypes == 0) readExercisesFile(gravitatory);
selectExerciseType(gravitatory);
load = selectValueDialog("Select the load you are\ngoing to move", "0,5,20,200", "0.5,1,5", 1);
startEncoderCapture();
@@ -2077,3 +2081,24 @@ void readInertMachineFile()
}
machinesFile.close();
}
+
+void showList(int color)
+{
+ int xPos = 10;
+ int midYPos = 110;
+ int currentY = 0;
+ for (int i = -3; i <= 3; i++) {
+ if (i == 0) {
+ //Do nothing
+ } else {
+ if (i < 0 ) {
+ currentY = midYPos + i * 16 - 3;
+ } else if (i > 0) {
+ currentY = midYPos + i * 16 + 8;
+ }
+ printTftText(textList[i+3], xPos, currentY, color, 2);
+ }
+ }
+ tft.fillRoundRect(0, midYPos -1 ,320, 25, 5, RED);
+ printTftText(textList[3], xPos, midYPos, color, 3);
+}
diff --git a/arduino/michrolab/personsManage.ino b/arduino/michrolab/personsManage.ino
index da8a2b255..00fd7c244 100644
--- a/arduino/michrolab/personsManage.ino
+++ b/arduino/michrolab/personsManage.ino
@@ -162,7 +162,14 @@ void selectGroup()
void selectPersonDialog()
{
tft.fillScreen(BLACK);
- showPersonList(WHITE);
+ printTftText("Select person", 40, 20, WHITE, 3);
+ for (int i = -3; i <= 3; i++)
+ {
+ textList[i+3] = persons[ (i + totalPersons) % totalPersons].name + " " + persons[ (i + totalPersons) %
totalPersons].surname;
+ }
+
+ //showPersonList(WHITE);
+ showList(WHITE);
drawLeftButton("Next", WHITE, BLUE);
drawRightButton("Accept", WHITE, RED);
@@ -174,45 +181,24 @@ void selectPersonDialog()
if (blueButton.fell())
{
//Deleting last list
- showPersonList(BLACK);
+ showList(BLACK);
currentPerson = (currentPerson + 1) % totalPersons;
+ for (int i = -3; i <= 3; i++)
+ {
+ textList[i+3] = persons[ (currentPerson + i + totalPersons) % totalPersons].name + " " + persons[
(currentPerson + i + totalPersons) % totalPersons].surname;
+ }
+
Serial.println("Changed to " + String(currentPerson));
//Printing new list
- showPersonList(WHITE);
+ showList(WHITE);
}
blueButton.update();
redButton.update();
}
}
-void showPersonList(unsigned int color)
-{
- int xPos = 10;
- int midYPos = 110;
- int currentY = 0;
- printTftText("Select person", 40, 20, color, 3);
- for (int i = -3; i <= 3; i++) {
- if (i == 0) {
- //Do nothing
- } else {
- if (i < 0 ) {
- currentY = midYPos + i * 16 - 3;
- } else if (i > 0) {
- currentY = midYPos + i * 16 + 8;
- }
- printTftText(persons[(currentPerson + totalPersons + i) % totalPersons].name + " " +
persons[(currentPerson + totalPersons + i) % totalPersons].surname,
- xPos, currentY, color, 2);
- }
- }
- // printTftText("[" + (persons[currentPerson].name + " " +
persons[currentPerson].surname).substring(0,14) + "]",
- // xPos, midYPos, color, 3);
- tft.fillRoundRect(0, midYPos -1 ,320, 25, 5, RED);
- printTftText((persons[currentPerson].name + " " + persons[currentPerson].surname).substring(0, 17),
- xPos, midYPos, color, 3);
-}
-
void setGroup(String parameters)
{
group = parameters.substring(0, parameters.lastIndexOf(";")).toInt();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]