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:
- 98:d70ff5a0b2e6
- Parent:
- 97:c596f8ed4562
- Child:
- 99:229435dd4cfb
diff -r c596f8ed4562 -r d70ff5a0b2e6 main.cpp --- a/main.cpp Thu Dec 17 05:30:38 2015 +0000 +++ b/main.cpp Sat Jan 09 00:13:17 2016 +0000 @@ -137,12 +137,12 @@ }else if(Handler->charHandle == upasServicePtr->runReadyCharacteristic.getValueAttribute().getHandle()){ uint8_t runData = writeData[0]; - if(runData == 10){ + //if(runData == 10){ RunReady = 10; - }else{ - RunReady = 2; - } + //}else{ + // RunReady = 2; + //} }else if(Handler->charHandle == upasServicePtr->logIntevalCharacteristic.getValueAttribute().getHandle()){ /* Trigger demo mode*/ @@ -151,7 +151,13 @@ }else if(Handler->charHandle == upasServicePtr->flowRateCharacteristic.getValueAttribute().getHandle()){ //RGB_LED.set_led(3,1,0); - E2PROM.write(0x00010,writeData,4); + E2PROM.write(0x00010,writeData,4); + + //float volFlowTester = 0.0; + //uint8_t flowRateTestBytes[4] = {0,}; + //E2PROM.read(0x00010,flowRateTestBytes,4); + //E2PROM.byteToFloat(flowRateTestBytes, &volFlowTester); + } } @@ -314,18 +320,21 @@ } if(RunReady==10){ //Check to see if app is done with configurations - blower = 0; + //blower = 1; + ble.stopAdvertising(); break; } } - + E2PROM.read(0x00015, startAndEndTime, 12); //Grab start and end times from EEPROM while(!RTC.compare(startAndEndTime[0], startAndEndTime[1], startAndEndTime[2], startAndEndTime[3], startAndEndTime[4], startAndEndTime[5])) { // this while waits for the start time by looping until the start time wait(0.5); + RTC.get_time(); } + RGB_LED.set_led(0,1,0); calibrations.initialize(serial_num); blower=1; E2PROM.read(0x00014,logIntervalReadOut,1); @@ -339,26 +348,25 @@ //pbKill = 0; // this is were we shut everything down - - - - - - - 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); + - + calibrations.initialize(serial_num); stop.attach(&check_stop, 30); // check if we should shut down every 9 seconds, starting 60s after the start. + //Update the flow rate value stored in eeprom + uint8_t flowRateBytes[4] = {0,}; + E2PROM.read(0x00010,flowRateBytes,4); + E2PROM.byteToFloat(flowRateBytes, &volflowSet); + if(volflowSet<=1.0) { gainFlow = 100; } else if(volflowSet>=2.0) {