Files at this revision

API Documentation at this revision

Comitter:
ssozonoff
Date:
Fri Jun 17 22:35:48 2011 +0000
Parent:
1:bdf678f27614
Commit message:
Fixed issue with Pitch and Roll negative values

Changed in this revision

HMC6343.cpp Show annotated file Show diff for this revision Revisions of this file
HMC6343.h Show annotated file Show diff for this revision Revisions of this file
diff -r bdf678f27614 -r 2645c4d75671 HMC6343.cpp
--- a/HMC6343.cpp	Sun May 01 13:51:14 2011 +0000
+++ b/HMC6343.cpp	Fri Jun 17 22:35:48 2011 +0000
@@ -39,6 +39,8 @@
  */
 #include "HMC6343.h"
 
+short h, r, p;
+
 template<class TYPE> inline TYPE BIT(const TYPE & x) {
     return TYPE(1) << x;
 }
@@ -68,10 +70,14 @@
     wait_ms(1);
 
     i2c_->read((HMC6343_I2C_ADDRESS << 1) | 0x01, rx, 6, true);
+    
+    h = ((((int)rx[0] << 8) | (int)rx[1]));
+    r = ((((int)rx[4] << 8) | (int)rx[5]));
+    p = ((((int)rx[2] << 8) | (int)rx[3]));
 
-    p_heading->heading = (double)((((int)rx[0] << 8) | (int)rx[1])) / 10;
-    p_heading->roll = (double)((((int)rx[4] << 8) | (int)rx[5])) / 10;
-    p_heading->pitch = (double)((((int)rx[2] << 8) | (int)rx[3])) / 10;
+    p_heading->heading = (float)h / 10;
+    p_heading->roll = (float)r / 10;
+    p_heading->pitch = (float)p / 10;
 }
 
 
diff -r bdf678f27614 -r 2645c4d75671 HMC6343.h
--- a/HMC6343.h	Sun May 01 13:51:14 2011 +0000
+++ b/HMC6343.h	Fri Jun 17 22:35:48 2011 +0000
@@ -112,9 +112,9 @@
 
 
 struct Heading {
-    double heading;
-    double pitch;
-    double roll;
+    float heading;
+    float pitch;
+    float roll;
 };
 
 /**