Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
Revision 22:d191c27f917d, committed 2016-10-06
- Comitter:
- mfr16
- Date:
- Thu Oct 06 11:35:53 2016 +0000
- Parent:
- 21:0e7c08f5386f
- Commit message:
- Example to simulate photoplethysmography for heart rate and transmit via BLE
Changed in this revision
| X_NUCLEO_6180XA1.lib | 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_6180XA1.lib Thu Oct 06 11:35:53 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/ST/code/X_NUCLEO_6180XA1/#663a22f7c44d
--- a/main.cpp Wed Oct 05 09:16:58 2016 +0000
+++ b/main.cpp Thu Oct 06 11:35:53 2016 +0000
@@ -17,10 +17,16 @@
#include "mbed.h"
#include "ble/BLE.h"
#include "ble/services/HeartRateService.h"
+#include "x_nucleo_6180xa1.h"
+
+#define VL6180X_I2C_SDA D14
+#define VL6180X_I2C_SCL D15
+
+static X_NUCLEO_6180XA1 *board=NULL;
DigitalOut led1(LED1, 1);
-const static char DEVICE_NAME[] = "HRM1";
+const static char DEVICE_NAME[] = "HRMFR16";
static const uint16_t uuid16_list[] = {GattService::UUID_HEART_RATE_SERVICE};
static volatile bool triggerSensorPolling = false;
@@ -63,9 +69,12 @@
ble.gap().onDisconnection(disconnectionCallback);
/* Setup primary service. */
- uint8_t hrmCounter = 60; // init HRM to 60bps
+ uint8_t hrmCounter = 100; // init HRM to 100bps
HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
+ uint32_t lux, dist;
+ uint32_t luxThreshold = 250;
+
/* Setup advertising. */
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
@@ -81,13 +90,13 @@
if (triggerSensorPolling && ble.getGapState().connected) {
triggerSensorPolling = false;
- // Do blocking calls or whatever is necessary for sensor polling.
- // In our case, we simply update the HRM measurement.
- hrmCounter++;
+ board->sensor_top->GetDistance(&dist);
+ board->sensor_top->GetLux(&lux);
- // 60 <= HRM bps <= 100
- if (hrmCounter == 100) {
- hrmCounter = 60;
+ if (lux<=luxThreshold) {
+ hrmCounter = 95;
+ } else {
+ hrmCounter = 65;
}
// update bps
@@ -100,8 +109,17 @@
int main(void)
{
+ int status;
+
Ticker ticker;
ticker.attach(periodicCallback, 1); // blink LED every second
+
+ DevI2C *device_i2c =new DevI2C(VL6180X_I2C_SDA, VL6180X_I2C_SCL);
+ /* creates the 6180XA1 expansion board singleton obj */
+ board=X_NUCLEO_6180XA1::Instance(device_i2c, NC,NC,NC,NC);//A3, A2, D13, D2);
+ /* init the 6180XA1 expansion board with default values */
+ status=board->InitBoard();
+ if(status) { printf("Failed to init board!\n\r"); return 0; }
BLE::Instance().init(bleInitComplete);
}
