Code supports writing to the SD card as well as working with the Volckens group smartphone apps for the mbed HRM1017

Dependencies:   ADS1115 BLE_API BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed nRF51822

Fork of UPAS_BLE_and_USB by Volckens Group Sensors

Revision:
89:047e8558fd09
Parent:
88:9142f21a4715
Child:
90:26a08de1a0ac
--- a/main.cpp	Wed Sep 23 19:54:09 2015 +0000
+++ b/main.cpp	Thu Sep 24 19:45:17 2015 +0000
@@ -225,7 +225,8 @@
 
 int main()
 {
-
+    uint8_t temp_crr;
+Restart:
 // Setup and Initialization
 //---------------------------------------------------------------------------------------------//
     Menu.read_menu(E2PROM, logInerval,refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, RunReady, serial_num);   //Read all data from the EEPROM here
@@ -257,8 +258,8 @@
     //    RunReady = 0;
     //}
 Reopen:
-    uint8_t temp_crr = Menu.crr;
-    if((Menu.crr &0x01) == 0) { // crr bit 0, should the menu be optional
+    temp_crr = Menu.crr;
+    if((Menu.crr &0x01) != 0x01) { // crr bit 0, should the menu be optional
         RGB_LED.set_led(1,1,1);
         wait(5);
         RGB_LED.set_led(1,1,0);
@@ -270,7 +271,7 @@
         while(RunReady == 0 || RTC.OSF()) {
             RGB_LED.set_led(0,1,1);   // error code/color
             RunReady = Menu.Start(pc, E2PROM, RTC, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, Menu.menu_ops, 0.25, serial_num, calibrations);  //Forces you to open the menu
-            RGB_LED.set_led(0,10,10); // error code/color
+            RGB_LED.set_led(0,5,5); // error code/color
             bleMenu.open_menu(txPayload, rxCharacteristic, E2PROM, RTC, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, Menu.menu_ops ,RunReady, 0.25, serial_num, calibrations);
         }
 
@@ -309,11 +310,18 @@
             goto Reopen;
         }
     }
-    pc.printf("You're done, you can now disconect the USB cable.\r\n");
     
-    if(bleMenu.crr != temp_crr) {
+    if(bleMenu.crr != temp_crr ) { 
         Menu.crr = bleMenu.crr; // if this was changed in the UBM move it to the primary USM before saving
+        Menu.save_menu(E2PROM, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, RunReady, serial_num);       //Save all data to the EEPROM
     }
+    if(Menu.crr != temp_crr) {
+        Menu.save_menu(E2PROM, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, RunReady, serial_num);       //Save all data to the EEPROM
+        //RunReady = ?;
+        goto Restart;
+    }
+    
+    pc.printf("You're done, you can now disconect the USB cable.\r\n");
     RunReady = 0;
     Menu.save_menu(E2PROM, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, RunReady, serial_num);       //Save all data to the EEPROM
     RGB_LED.set_led(1,1,0);