added main and defined M_PI

Dependencies:   BNOWrapper

Files at this revision

API Documentation at this revision

Comitter:
t1jain
Date:
Wed Aug 07 18:50:14 2019 +0000
Parent:
9:08937d4564e5
Commit message:
Updated Wrapper to be compatible with new code

Changed in this revision

BNOWrapper.lib Show annotated file Show diff for this revision Revisions of this file
Watchdog/Watchdog.cpp Show annotated file Show diff for this revision Revisions of this file
Watchdog/Watchdog.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/BNOWrapper.lib	Wed Aug 07 17:26:41 2019 +0000
+++ b/BNOWrapper.lib	Wed Aug 07 18:50:14 2019 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/Affordable-Smart-Wheelchair/code/BNOWrapper/#dbe6d8d0ceb1
+https://os.mbed.com/teams/Affordable-Smart-Wheelchair/code/BNOWrapper/#f013530d8358
--- a/Watchdog/Watchdog.cpp	Wed Aug 07 17:26:41 2019 +0000
+++ b/Watchdog/Watchdog.cpp	Wed Aug 07 18:50:14 2019 +0000
@@ -28,9 +28,10 @@
 #include "mbed.h"
 #include "Watchdog.h"
 #include "BNO080.h"
+#include <BNO080Wheelchair.h>
 
 /// Watchdog gets instantiated at the module level
-Watchdog::Watchdog(BNO080 *imu)
+Watchdog::Watchdog(BNO080Wheelchair *imu)
 {
 #ifdef LPC
     wdreset = (LPC_WDT->WDMOD >> 2) & 1;    // capture the cause of the previous reset
@@ -84,7 +85,7 @@
     } else if ((timeout * (LsiFreq/32)) < 0xFF0) {
         PrescalerCode = IWDG_PRESCALER_32;
         Prescaler = 32;
-        if(imu1->begin()) {
+        if(imu1->setup()) {
             IWDG->KR = 0xAAAA;    //Reload IWDG
             IWDG->KR = 0xCCCC;    //Start IWDG
             Service();
--- a/Watchdog/Watchdog.h	Wed Aug 07 17:26:41 2019 +0000
+++ b/Watchdog/Watchdog.h	Wed Aug 07 18:50:14 2019 +0000
@@ -20,6 +20,7 @@
 #define WATCHDOG_H
 #include "mbed.h"
 #include "BNO080.h"
+#include <BNO080Wheelchair.h>
 /// The Watchdog class provides the interface to the Watchdog feature
 ///
 /// Embedded programs, by their nature, are usually unattended. If things
@@ -56,7 +57,7 @@
     /// @code
     /// Watchdog wd;    // placed before main
     /// @endcode
-    Watchdog(BNO080 *imu);
+    Watchdog(BNO080Wheelchair *imu);
     
     /// Configure the timeout for the Watchdog
     ///
@@ -96,7 +97,7 @@
     bool WatchdogCausedReset();
 private:
     bool wdreset;
-    BNO080 *imu1;
+    BNO080Wheelchair *imu1;
 };
 
 #endif // WATCHDOG_H
\ No newline at end of file
--- a/main.cpp	Wed Aug 07 17:26:41 2019 +0000
+++ b/main.cpp	Wed Aug 07 18:50:14 2019 +0000
@@ -1,6 +1,7 @@
 #include <mbed.h>
 #include <BNO080.h>
 #include "Watchdog.h"
+#include <BNO080Wheelchair.h>
 
 int main()
 {
@@ -10,35 +11,32 @@
     //BNO080 imu(&pc, D4, D5, D12, D10, 0x4b, 100000);
 
     //NUCLEO- F767ZI
-    BNO080 imu(&pc, D2, D4, D13, D15, 0x4b, 100000);
+    BNO080Wheelchair imu(&pc, D2, D4, D13, D15, 0x4b, 100000);
 
 
     Watchdog dog(&imu);
     dog.Configure(4);         //need to find the time for entire program to run
-    imu.begin();
+    imu.setup();
     // Tell the IMU to report rotation every 100ms and acceleration every 200ms
 
-    imu.enableReport(BNO080::TOTAL_ACCELERATION, 100);
-    imu.enableReport(BNO080::ROTATION, 100);
+    // imu.enableReport(BNO080::TOTAL_ACCELERATION, 100);
+    // imu.enableReport(BNO080::ROTATION, 100);
 
     while (true) {
         wait(.001f);
 
         // poll the IMU for new data -- this returns true if any packets were received
-        if(imu.updateData()) {
+        if(imu.hasNewData(BNO080::TOTAL_ACCELERATION)) {
             // now check for the specific type of data that was received (can be multiple at once)
-            if (imu.hasNewData(BNO080::TOTAL_ACCELERATION) || imu.hasNewData(BNO080::ROTATION)) {
-                pc.printf("TAcc: ");
-                imu.totalAcceleration.print(pc, true);
+
+            pc.printf("Acc in X: %f\n", imu.accel_x());
 
-                pc.printf(", Rot:");
-                TVector3 eulerRadians = imu.rotationVector.euler();
-                TVector3 eulerDegrees = eulerRadians * (180.0 / M_PI);
-                eulerDegrees.print(pc, true);
-                pc.printf("\n");
-
-                dog.Service();
-            }
+            pc.printf("Rot in X: ");
+            TVector4 eulerRadians = imu.rotation();
+            TVector4 eulerDegrees = eulerRadians * (180.0 / M_PI);
+            eulerDegrees.print(pc, true);
+            pc.printf("\n");
+            dog.Service();
 
         }
     }