Fork for https://developer.mbed.org/users/jony1401/code/SenseAirLP8/
Dependencies: BLE_API mbed nRF51822
Fork of SenseAirLP8 by
Revision 5:2c80954571b6, committed 2017-08-28
- Comitter:
- dimion
- Date:
- Mon Aug 28 08:50:49 2017 +0000
- Parent:
- 4:320febe026ed
- Commit message:
- Add a startup delay for measurements to charge the super-capacitor
Changed in this revision
LP8.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LP8.h Mon Aug 21 08:44:33 2017 +0000 +++ b/LP8.h Mon Aug 28 08:50:49 2017 +0000 @@ -67,17 +67,12 @@ bool lp8Init(){ Device.format(8, SerialBase::None, 2); - //Reset LP8 - RES.write( 0 ); //reset - timeIt( 1.0 ); - RES.write( 1 ); //enable - timeIt(0.2); //Enable Sensor VBB_EN.write( 1 ); //power on //wait for rdy signal - timeIt( 0.30 ); //wait for lp8 rdy signal + timeIt( 0.21 ); //wait for lp8 rdy signal // while(RDY.read() != 0 ) { /* wait for rdy to go low */} //transmit first packet @@ -86,9 +81,9 @@ //check response if ( responseCompare() != true){ - //VBB_EN.write( 0 ); + VBB_EN.write(0); return false; - } + } //compute crc CRC = modbusCrc(stateRead, 5); @@ -98,7 +93,7 @@ stateRead[6] = (uint8_t)(CRC >> 8); //crc_h //wait for rdy - timeIt( 0.20 ); // + timeIt( 0.25 ); // // while(RDY.read() != 1 ) { /*wait for rdy to go high */} transmitPacket(stateRead, 7); //transmit packet @@ -147,7 +142,7 @@ //compare to confirmation sequence if ( responseCompare() != true){ - //VBB_EN.write( 0 ); + VBB_EN.write( 0 ); return false; }
--- a/main.cpp Mon Aug 21 08:44:33 2017 +0000 +++ b/main.cpp Mon Aug 28 08:50:49 2017 +0000 @@ -95,8 +95,8 @@ uint8_t sentCCbyte = 0x99; -//setup LP8 object -LP8 *lp8 = new LP8(Device, VBB_EN, RDY, Res, lp8Wait); + //setup LP8 object + LP8 *lp8 = new LP8(Device, VBB_EN, RDY, Res, lp8Wait); //Setup GattService @@ -106,7 +106,7 @@ Vcap, errorFlag, ccByte, sentCCbyte); // lp8Service; -// setup ble advertising parameters + // setup ble advertising parameters ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); //general bluetooth information(only support for ble ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); //service list ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); @@ -114,11 +114,12 @@ ble.gap().setAdvertisingInterval(BLE_ADV_INTERVAL); /* advertising interval in ms. */ ble.gap().startAdvertising(); -// Wait for initialization to complete. + // Wait for initialization to complete. while (ble.hasInitialized() == false) { /* spin loop */ } - + /* Waiting while super-capacitor will charged for a first measurement */ + wait(SENSOR_TIMER); //*************************** start the main loop *********************************** @@ -131,7 +132,7 @@ lp8->responsePurge(50); //purge buffer if ( lp8->lp8Init() != true ) { //initCheck = true; - } + } else { initCheck = false;