CPS-Lab* / Mbed 2 deprecated lab6

Dependencies:   ADXL362 mbed MPL3115A2

Files at this revision

API Documentation at this revision

Comitter:
htdoughe
Date:
Fri Feb 23 16:47:22 2018 +0000
Parent:
15:5ce9c63e7da2
Child:
17:6a08357dbb3f
Commit message:
moving code around

Changed in this revision

MPL3115A2.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/MPL3115A2.lib	Fri Feb 23 16:47:22 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/sophtware/code/MPL3115A2/#7c7c1ea6fc33
--- a/main.cpp	Fri Feb 23 02:53:00 2018 +0000
+++ b/main.cpp	Fri Feb 23 16:47:22 2018 +0000
@@ -1,10 +1,11 @@
 #include "mbed.h"
 #include "ADXL362.h"
 #include "string.h"
+#include "MPL3115A2.h"
 
 DigitalOut led1(LED3);
 
-//map of register values and names
+//map of register values and names for the adxl
 int regids[34];
 char* regnames[34];
 //populating the map
@@ -128,17 +129,8 @@
     return 0;
 }
 
-int main() {
-    initmap();
-    adxl362.reset();
-    wait_ms(600); // we need to wait at least 500ms after ADXL362 reset
-    adxl362.set_mode(ADXL362::MEASUREMENT);
+void knocks(){
     int8_t x,y,z, initx, inity, initz; 
-    int start, length;
-    start = 0;
-    length = 5;
-    adxl362_reg_print(start, length);
-    
     //initial values of x, y, and z.
     //These values are the baseline for the accelerometer; knocks are detected
     // in relation to these initial values
@@ -160,7 +152,22 @@
             wait_ms(2000);
             led1 = 0;
         }
-        printf("x = %d y = %d z = %d\r\n",x,y,z);
+        //printf("x = %d y = %d z = %d\r\n",x,y,z);
         wait_ms(100);
     }
 }
+
+int main() {
+    initmap();
+    adxl362.reset();
+    wait_ms(600); // we need to wait at least 500ms after ADXL362 reset
+    adxl362.set_mode(ADXL362::MEASUREMENT);
+    int start, length;
+    start = 0;
+    length = 0;
+    while(1){
+        adxl362_reg_print(start, length);
+    }
+    knocks();
+    
+}