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
Diff: main.cpp
- Revision:
- 91:f838d9a5b596
- Parent:
- 90:26a08de1a0ac
- Child:
- 92:bb36c4bedb8e
--- a/main.cpp Thu Sep 24 20:21:34 2015 +0000 +++ b/main.cpp Tue Sep 29 02:01:37 2015 +0000 @@ -145,7 +145,7 @@ void log_data() { logg.detach(); - logg.attach(&log_data, logInerval); + logg.attach(&log_data, logInerval-0.5); // reading and logging data must take significintly less than 0.5s. This can be increased. RTC.get_time(); secondsD = RTC.seconds; while(fmod(secondsD,logInerval)!=0) { @@ -226,7 +226,7 @@ int main() { uint8_t temp_crr; -Restart: + RGB_LED.set_led(1,1,1); // 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 @@ -265,19 +265,20 @@ 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 || RTC.OSF()) { + } else if(RunReady == 0 ) { RGB_LED.set_led(0,1,1); // error code/color //pc.printf("Fix RTC\r\n"); - while(RunReady == 0 || RTC.OSF()) { + while(RunReady == 0 ) { 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,5,5); // error code/color + RGB_LED.set_led(0,3,3); // 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); } if((Menu.crr & 0x08) != 0) { // crr bit 3, power down prepared to sample 24hr when powered on RunReady = 1; 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 + pbKill = 0; } } @@ -300,7 +301,7 @@ } } // Compare function for 519(UBCUO) mode to have it wait for the start time to start - if((Menu.crr & 0x04) != 0) { + if(((Menu.crr & 0x04) != 0) && ((Menu.crr & 0x08) == 0)) { 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 @@ -324,6 +325,7 @@ 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); if((Menu.crr & 0x10) != 0) { //crr bit 4 uses Demo values @@ -335,7 +337,7 @@ 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 wait(0.5); RTC.get_time(); //debug - pc.printf("%02d:%02d:%02d on %d/%d/%d) \r\n",RTC.hour, RTC.minutes, RTC.seconds, RTC.month, RTC.date, RTC.year);//debig + pc.printf("%02d:%02d:%02d on %d/%d/%d) \r\n",RTC.hour, RTC.minutes, RTC.seconds, RTC.month, RTC.date, RTC.year);//debug //pc.printf("Waiting to start\r\n"); // serial print a count down?? }