[chronojump/michrolab] Created select person dialog



commit 2f9109ce277e052984a92f3e28877f5df2f123c8
Author: xpadulles <x padulles gmail com>
Date:   Thu Aug 25 19:34:55 2022 +0200

    Created select person dialog

 arduino/michrolab/michrolab.ino     |  6 ++--
 arduino/michrolab/personsManage.ino | 66 +++++++++++++++++++++++++++++++------
 2 files changed, 58 insertions(+), 14 deletions(-)
---
diff --git a/arduino/michrolab/michrolab.ino b/arduino/michrolab/michrolab.ino
index 5c9bf1740..b67dd8d4c 100644
--- a/arduino/michrolab/michrolab.ino
+++ b/arduino/michrolab/michrolab.ino
@@ -420,7 +420,7 @@ void setup() {
   currentExerciseType = 0;
 
   tft.fillScreen(BLACK);
-
+  
   drawMenuBackground();
   backMenu();
   showMenuEntry(currentMenuIndex);
@@ -1256,6 +1256,7 @@ void startEncoderCapture(void)
   lastVelocity = 0;
   readExercisesFile(gravitatory);
   //currentExerciseType = 0;
+  Serial.println("Starting. CurrentPerson: " + String(currentPerson));
   selectPersonDialog();
   selectExerciseType(gravitatory);
   selectValueDialog("Select the load you are\ngoing to move", "0,5,20,200", "0.5,1,5", 1);
@@ -1411,9 +1412,6 @@ void jumpsCapture()
   redrawAxes(tft, 30, 200, 290, 200, 290, 200, 0, graphRange, graphRange / 10, "", "", "", WHITE, GREY, 
WHITE, WHITE, BLACK, RED, true);
   redButton.update();
 
-  
-  currentPerson = 0;
-  Serial.println("currentPerson set to 0");
   updatePersonJump(totalJumps);
 
   //Print summary results
diff --git a/arduino/michrolab/personsManage.ino b/arduino/michrolab/personsManage.ino
index a1215c7e3..1be0cc0dd 100644
--- a/arduino/michrolab/personsManage.ino
+++ b/arduino/michrolab/personsManage.ino
@@ -60,7 +60,7 @@ void readPersonsFile()
   */
   String row = "";
   char readChar;
-  String filename = "group"+String(group)+".txt";
+  String filename = "group" + String(group) + ".txt";
   File  personsFile = SD.open(filename.c_str());
   if (personsFile)
   {
@@ -87,13 +87,14 @@ void readPersonsFile()
     // if the file didn't open, print an error:
     Serial.println("error opening " + filename);
   }
+  currentPerson = 0;
 }
 
 unsigned int getTotalPerson()
 {
   char readChar;
   String readString = "";
-  String filename = "group"+String(group)+".txt";
+  String filename = "group" + String(group) + ".txt";
   File  personsFile = SD.open(filename.c_str());
   if (personsFile)
   {
@@ -146,14 +147,9 @@ void updatePersonJump(int totalJumps)
   tft.fillRect(141, 207, 127, 24, BLACK);
 
   //Writing new string
-  tft.setTextSize(1);
-  tft.setTextColor(WHITE);
-  tft.setCursor(141, 207);
-  tft.print(jumpTypes[currentExerciseType].name);
-  tft.setCursor(195,207);
-  tft.print("Person: " + addLeadingZeros(currentPerson, 2));
-  tft.setCursor(141, 223);
-  tft.print(persons[currentPerson].name + " " + persons[currentPerson].surname);
+  printTftText(jumpTypes[currentExerciseType].name, 141, 207, WHITE, 1);
+  printTftText("Person: " + addLeadingZeros(currentPerson, 2), 195, 207, WHITE, 1);
+  printTftText(persons[currentPerson].name + " " + persons[currentPerson].surname, 141, 223, WHITE, 1);
   tft.setTextSize(2);
 }
 void selectGroup()
@@ -167,3 +163,53 @@ void selectGroup()
   menuItemsNum = systemMenuItems;
   showMenuEntry(currentMenuIndex);
 }
+
+void selectPersonDialog()
+{
+  tft.fillScreen(BLACK);
+  showPersonList(WHITE);
+
+  drawLeftButton("Next", WHITE, BLUE);
+  drawRightButton("Accept", WHITE, RED);
+
+  blueButton.update();
+  redButton.update();
+  while (!redButton.fell())
+  {
+    if (blueButton.fell())
+    {
+      //Deleting last list
+      showPersonList(BLACK);
+      
+      currentPerson = (currentPerson + 1) % totalPersons;
+
+      //Printing new list
+      showPersonList(WHITE);
+    }
+    blueButton.update();
+    redButton.update();
+  }
+}
+
+void showPersonList(unsigned int color)
+{
+  int xPosos = 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,
+                   xPosos, currentY, color, 2);
+    }
+  }
+  printTftText("[" + persons[currentPerson].name + " " + persons[currentPerson].surname + "]",
+               xPosos, midYPos, color, 3);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]