Built from datasheet for 9-DOF sensor stick from SparkFun.

Dependents:   9Dof_unit_testing sparkfun6dof Seeed_Grove_Digital_Compass_Example CompassTest ... more

Files at this revision

API Documentation at this revision

Comitter:
tylerjw
Date:
Thu Nov 01 18:43:52 2012 +0000
Parent:
1:8a1357c351c6
Child:
3:14d274e0f9de
Commit message:
adxl345 unit test created, built in self test written (not tested)

Changed in this revision

HMC5883L.cpp Show annotated file Show diff for this revision Revisions of this file
HMC5883L.h Show annotated file Show diff for this revision Revisions of this file
--- a/HMC5883L.cpp	Wed Oct 31 05:06:34 2012 +0000
+++ b/HMC5883L.cpp	Thu Nov 01 18:43:52 2012 +0000
@@ -133,15 +133,15 @@
 {
     int raw_data[3];
     getXYZ(raw_data);
-    double heading = atan2(raw_data[1], raw_data[0]); // heading = arctan(Y/X)
+    double heading = atan2(static_cast<double>(raw_data[1]), static_cast<double>(raw_data[0])); // heading = arctan(Y/X)
     
     // TODO: declenation angle compensation
     
     if(heading < 0.0) // fix sign
-        heading += 2PI;
+        heading += PI2;
         
-    if(heading > 2PI) // fix overflow
-        heading -= 2PI;
+    if(heading > PI2) // fix overflow
+        heading -= PI2;
         
     return heading;
 }
\ No newline at end of file
--- a/HMC5883L.h	Wed Oct 31 05:06:34 2012 +0000
+++ b/HMC5883L.h	Thu Nov 01 18:43:52 2012 +0000
@@ -79,7 +79,7 @@
 #define M_PI 3.1415926535897932384626433832795
 #endif
 
-#define 2PI         (2*M_PI)
+#define PI2         (2*M_PI)
 #define RAD_TO_DEG  (180.0/M_PI)
 #define DEG_TO_RAD  (M_PI/180.0)