This is a repository for code relating to mbed Fitness Tracker

Dependencies:   mbed PulseSensor2 SCP1000 mbed-rtos 4DGL-uLCD-SE LSM9DS1_Library_cal PinDetect FatFileSystemCpp GP-20U7

Files at this revision

API Documentation at this revision

Comitter:
memig3
Date:
Thu Apr 23 00:27:32 2020 +0000
Parent:
31:3363c6923beb
Child:
33:48b2c87faecc
Commit message:
added step count goal to setup menu

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Apr 22 20:00:57 2020 +0000
+++ b/main.cpp	Thu Apr 23 00:27:32 2020 +0000
@@ -30,7 +30,7 @@
 float distance = 0.0;
 float calories = 0;
 int oldSteps = 0;
-const int stepGoal = 100;
+int stepGoal = 100;
 float stride_length = 0.0;
 
 unsigned long pressure;
@@ -74,7 +74,7 @@
 void next() {
     oldScreen = screen;
     screen++;
-    if(screen == 4) {
+    if(screen == 5) {
         setup_state = false;
     }
 }
@@ -162,13 +162,14 @@
                 uLCD.text_width(2);
                 uLCD.text_height(2);
                 uLCD.puts("Weight");
-                weight = 0.45 * (90 + pot.read() * 210);
+                weight = (90 + pot.read() * 210);
                 char weight_string[3];
                 if(weight < 100) {
                     sprintf(weight_string, " %d", weight);
                 } else {
                     sprintf(weight_string, "%d", weight);
                 }
+                weight = 0.45*weight;
                 uLCD.text_width(3);
                 uLCD.text_height(3);
                 uLCD.locate(2, 3);
@@ -193,6 +194,37 @@
                 uLCD.puts(age_string);
                 uLCD.line(40, 100, 90, 100, WHITE);
                 break;
+            case 4:
+                //Step goal
+                uLCD.color(WHITE);
+                uLCD.locate(2, 2);
+                uLCD.text_width(1);
+                uLCD.text_height(1);
+                uLCD.puts("Daily Step Goal");
+                char step_string[5];
+                if(pot.read() < 0.2) {
+                    stepGoal = 500;
+                    sprintf(step_string, "  %d", stepGoal);
+                }else if(pot.read() < 0.4) {
+                    stepGoal = 1000;
+                    sprintf(step_string, " %d", stepGoal);
+                }else if(pot.read() < 0.6) {
+                    stepGoal = 5000;
+                    sprintf(step_string, " %d", stepGoal);
+                }else if(pot.read() < 0.8) {
+                    stepGoal = 10000;
+                    sprintf(step_string, "%d", stepGoal);
+                }else {
+                    stepGoal = 20000;
+                    sprintf(step_string, "%d", stepGoal);
+                }
+                uLCD.text_width(2);
+                uLCD.text_height(2);
+                uLCD.locate(2, 4);
+                uLCD.color(GREEN);
+                uLCD.puts(step_string);
+                uLCD.line(30, 85, 100, 85, WHITE);
+                break;
         }
         serial_mtx.unlock();
         Thread::wait(100);
@@ -210,9 +242,9 @@
         switch(mode) {
             case 1:
                 //Step count
-                //uLCD.media_init();
-                //uLCD.set_sector_address(0x0000, 0x0005);
-                //uLCD.display_image(50, 45);
+                uLCD.media_init();
+                uLCD.set_sector_address(0x0000, 0x0005);
+                uLCD.display_image(50, 45);
                 uLCD.filled_rectangle(10, 110, 118, 115, BLACK);
                 uLCD.locate(3, 11);
                 uLCD.text_height(1);
@@ -223,9 +255,9 @@
                 break;
             case 2:
                 // Heart rate
-                //uLCD.media_init();
-                //uLCD.set_sector_address(0x0000, 0x000A);
-                //uLCD.display_image(50, 45);
+                uLCD.media_init();
+                uLCD.set_sector_address(0x0000, 0x000A);
+                uLCD.display_image(50, 45);
                 uLCD.locate(5, 11);
                 uLCD.text_height(1);
                 uLCD.text_width(1);
@@ -234,9 +266,9 @@
                 break;
             case 3:
                 //Distance
-                //uLCD.media_init();
-                //uLCD.set_sector_address(0x0000, 0x000F);
-                //uLCD.display_image(50, 45);
+                uLCD.media_init();
+                uLCD.set_sector_address(0x0000, 0x000F);
+                uLCD.display_image(50, 45);
                 uLCD.locate(6, 11);
                 uLCD.text_height(1);
                 uLCD.text_width(1);
@@ -245,9 +277,9 @@
                 break;
             case 4:
                 //Calories
-                //uLCD.media_init();
-                //uLCD.set_sector_address(0x0000, 0x0000);
-                //uLCD.display_image(50, 45);
+                uLCD.media_init();
+                uLCD.set_sector_address(0x0000, 0x0000);
+                uLCD.display_image(50, 45);
                 uLCD.locate(4, 11);
                 uLCD.text_height(1);
                 uLCD.text_width(1);
@@ -256,9 +288,9 @@
                 break;
             case 5:
                 //Floors
-                //uLCD.media_init();
-                //uLCD.set_sector_address(0x0000, 0x0014);
-                //uLCD.display_image(50, 45);
+                uLCD.media_init();
+                uLCD.set_sector_address(0x0000, 0x0014);
+                uLCD.display_image(50, 45);
                 uLCD.locate(4, 11);
                 uLCD.text_height(1);
                 uLCD.text_width(1);