Pull request for i.a. sensor buffer template
Dependencies: BLE_API MPU6050 mbed nRF51822
Diff: main.cpp
- Revision:
- 6:ed0dc0647c01
- Parent:
- 5:614164945894
- Child:
- 7:d92f1383bd81
--- a/main.cpp Wed Sep 19 19:49:39 2018 +0000 +++ b/main.cpp Tue Oct 16 18:46:28 2018 +0000 @@ -10,6 +10,7 @@ #include "BatteryService.h" #include "DeviceInformationService.h" #include "TemperatureService.h" +//#include "AccelerationService.h" #define LOG(...) { pc.printf(__VA_ARGS__); } @@ -169,6 +170,7 @@ BatteryService battery(ble); DeviceInformationService deviceInfo(ble, MANUFACTURER, MODELNUMBER, SERIALNUMBER, HARDWAREREVISION, FIRMWAREREVISION, SOFTWAREREVISION); TemperatureService tempService(ble); + //AccelerationService accelerationService(ble); ble.setAdvertisingInterval(160); /* 100ms; in multiples of 0.625ms. */ ble.gap().startAdvertising(); @@ -183,19 +185,28 @@ batteryVoltageChanged = false; } else if (startMeasure == true) { - float a[3]; - mpu.getAccelero(a); - LOG("Acceleration %.2f;%.2f;%.2f\n", a[0], a[1], a[2]); - startMeasure = false; + //float a[3]; + //mpu.getAccelero(a); + //LOG("Acceleration %.2f;%.2f;%.2f\n", a[0], a[1], a[2]); + /* + int a[3]; + mpu.getAcceleroRaw(a); + accelerationService.addAcceleration((int16_t*)a); + LOG("Acceleration %d;%d;%d\n", a[0], a[1], a[2]); + */ float temp = mpu.getTemp(); LOG("Temp = %.01f\n", temp); int16_t tempRaw = mpu.getTempRaw(); + // convert into 0.1 degrees Celsius tempRaw *= 10; tempRaw += 5210; tempRaw /= 340; tempRaw += 350; + // update BLE tmperature tempService.updateTemperature(tempRaw); + + startMeasure = false; } } }