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

Files at this revision

API Documentation at this revision

Comitter:
caseyquinn
Date:
Wed Sep 16 16:13:22 2015 +0000
Parent:
83:9153d6c3af81
Child:
85:a95dd5f03818
Commit message:
Made some adjustments to the Honduras initialization to ensure the runready is set to 0 and saved once turned on the second time. Start time seems to be fixed now that there is content in the while loop. Stop time now isn't working..

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Sep 16 05:09:07 2015 +0000
+++ b/main.cpp	Wed Sep 16 16:13:22 2015 +0000
@@ -256,6 +256,7 @@
     //if(RTC.OSF()) {                 //Force the menu open if the RTC needs reset.
     //    RunReady = 0;
     //}
+    
     uint8_t temp_crr = Menu.crr;
     if(Menu.crr == 1){  // if in Demo mode allow 1 second for each menu to change out of demo mode
         RGB_LED.set_led(1,1,1);  
@@ -263,7 +264,9 @@
         RGB_LED.set_led(1,1,0);  
         Menu.Start(pc, E2PROM, RTC, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, Menu.menu_ops, 2, serial_num, calibrations);  //Forces you to open the menu
         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, 3, serial_num, calibrations);
-    }else if(RunReady == 0) {
+        volflowSet = 1.0; //L/min
+        logInerval = 10;
+    }else if(RunReady == 0 || RTC.OSF()) {
         RGB_LED.set_led(0,1,1); // error code/color
         //pc.printf("Change Name\r\n");
         while(RunReady == 0 || RTC.OSF()) {
@@ -282,26 +285,32 @@
     // Compare function for 519(UBCUO) mode to have it wait for the start time to start
     if(Menu.menu_ops == 519){
     RTC.get_time();
+    //Need to add in a compare function to check to see if the start time has already passed.
     if(RTC.compare(Menu.f_sec, Menu.f_min, Menu.f_hour, Menu.f_day, Menu.f_month, Menu.f_year)) {  //Don't proceed if it's already time to stop
-        RGB_LED.set_led(1,0,0); // error code/color
+        RGB_LED.set_led(0,1,1); // error code/color
         pc.printf("Please fix the START or STOP times before exiting!\r\n");
         Menu.Start(pc, E2PROM, RTC, logInerval, refreshtime, volflowSet, device_name, dutyUp, dutyDown, home_lat, home_lon, work_lat, work_lon, Menu.menu_ops, 0, serial_num, calibrations);  //Forces you to open the menu
         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
     }
-    pc.printf("You're done, you can now disconect the USB cable.");
+    pc.printf("You're done, you can now disconect the USB cable.\r\n");
 
-    RunReady = 0;
-    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
     }
+    
+    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);
+    
+    if(Menu.menu_ops == 519){
     while(!RTC.compare(Menu.s_sec, Menu.s_min, Menu.s_hour, Menu.s_day, Menu.s_month, Menu.s_year)) {  // this while waits for the start time by looping until the start time
-        pc.printf("%d\r\n",serial_num);
+        wait(0.5);
+        pc.printf("Waiting to start\r\n");
         // serial print a count down??
     }
-   }
-    
+    }
     
     calibrations.initialize(serial_num);
     
@@ -352,7 +361,7 @@
     DigPot.writeRegister(digital_pot_setpoint);
     wait(1);
     blower = 1;
-    if(Menu.crr == 1) {
+    if(Menu.menu_ops == 513) {
         RTC.get_time();
         f_sec = RTC.seconds;
         f_min = RTC.minutes;
@@ -477,13 +486,7 @@
 
 
     //** end of initalization **//
-    //---------------------------------------------------------------------------------------------//
-    //---------------------------------------------------------------------------------------------//
-    if(Menu.crr == 2){  //demo mode never shuts down
-        //default demo mode settings
-        volflowSet = 1.0; //L/min
-        logInerval = 2;
-    }
+
     //---------------------------------------------------------------------------------------------//
     //---------------------------------------------------------------------------------------------//
     // Main Control Loop