Hexiwear heart rate sensor demo

Dependencies:   MAX30101

Fork of Hexi_Accelero_Magneto_Example by Hexiwear

Files at this revision

API Documentation at this revision

Comitter:
GregC
Date:
Mon Aug 15 23:22:48 2016 +0000
Parent:
1:6da908234299
Child:
3:9f60cb7455c4
Commit message:
Accelerometer and Magnetometer program example for Hexiwear

Changed in this revision

FXOS8700.lib Show annotated file Show diff for this revision Revisions of this file
FXOS8700CQ.lib 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/FXOS8700.lib	Mon Aug 15 23:22:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AswinSivakumar/code/FXOS8700/#98ea52282575
--- a/FXOS8700CQ.lib	Sat Aug 13 15:59:34 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/users/trm/code/FXOS8700CQ/#e2fe752b881e
--- a/main.cpp	Sat Aug 13 15:59:34 2016 +0000
+++ b/main.cpp	Mon Aug 15 23:22:48 2016 +0000
@@ -1,31 +1,46 @@
 #include "mbed.h"
-#include "FXOS8700CQ.h"
+#include "FXOS8700.h"
 
-/*  Check out the full featured example application for interfacing to the 
- *  Accelerometer/Magnetometer device at the following URL
- *  https://developer.mbed.org/users/trm/code/fxos8700cq_example/
-*/
+//  Check out the full featured example application for interfacing to the 
+//  Accelerometer/Magnetometer device at the following URL
+//  https://developer.mbed.org/users/trm/code/fxos8700cq_example/
 
-DigitalOut led1(LED1);
+DigitalOut led1(LED_GREEN);
+
+// Initialize Serial port
+Serial pc(USBTX, USBRX);
 
 // Pin connections & address for Hexiwear
-FXOS8700CQ fxos(PTC11, PTC10, FXOS8700CQ_SLAVE_ADDR0); // SDA, SCL, (addr << 1)
-// Storage for the data from the sensor
-SRAWDATA accel_data;
-SRAWDATA magn_data;
+FXOS8700 accel(PTC11, PTC10);
+FXOS8700 mag(PTC11, PTC10);
 
 // main() runs in its own thread in the OS
 // (note the calls to Thread::wait below for delays)
 int main() {
     
-    fxos.enable();
-    while (true) {
+    // Configure Accelerometer FXOS8700, Magnetometer FXOS8700
+    accel.accel_config();
+    mag.mag_config();
+
+    float accel_data[3]; float accel_rms=0.0;
+    float mag_data[3];   float mag_rms=0.0;
+
+    printf("Begin Data Acquisition from FXOS8700 and FXAS21002....\r\n\r\n");
+    wait(0.5);
+    
+    while (1) {
         led1 = !led1;
         // Example data printing
-        fxos.get_data(&accel_data, &magn_data);
-        printf("A X:%5d,Y:%5d,Z:%5d   M X:%5d,Y:%5d,Z:%5d\r\n",
-                 accel_data.x, accel_data.y, accel_data.z,
-                 magn_data.x, magn_data.y, magn_data.z);
+      
+      accel.acquire_accel_data_g(accel_data);
+      accel_rms = sqrt(((accel_data[0]*accel_data[0])+(accel_data[1]*accel_data[1])+(accel_data[2]*accel_data[2]))/3);
+      printf("Accelerometer \tX-Axis %4.2f \tY-Axis %4.2f \tZ-Axis %4.2f \tRMS %4.2f\n\r",accel_data[0],accel_data[1],accel_data[2],accel_rms);
+      wait(0.01);
+      
+      mag.acquire_mag_data_uT(mag_data);
+      mag_rms = sqrt(((mag_data[0]*mag_data[0])+(mag_data[1]*mag_data[1])+(mag_data[2]*mag_data[2]))/3);
+      printf("Magnetometer \tX-Axis %4.2f \tY-Axis %4.2f \tZ-Axis %4.2f \tRMS %4.2f\n\n\r",mag_data[0],mag_data[1],mag_data[2],mag_rms);
+      wait(0.01);
         
         Thread::wait(500);
     }