航空研究会 / HMC5883L

Dependents:   HMC5883L_test

Files at this revision

API Documentation at this revision

Comitter:
TUATBM
Date:
Wed Feb 06 11:53:18 2019 +0000
Parent:
4:bc4e1201e092
Commit message:
a

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	Tue Nov 06 17:35:51 2012 +0000
+++ b/HMC5883L.cpp	Wed Feb 06 11:53:18 2019 +0000
@@ -129,11 +129,11 @@
         output[i] = int16_t(((unsigned char)data[i*2] << 8) | (unsigned char)data[i*2+1]);
 }
 
-double HMC5883L::getHeadingXY()
+double HMC5883L::getHeadingXY(int Calib_x,int Calib_y)
 {
     int16_t raw_data[3];
     getXYZ(raw_data);
-    double heading = atan2(static_cast<double>(raw_data[1]), static_cast<double>(raw_data[0])); // heading = arctan(Y/X)
+    double heading = atan2(static_cast<double>(raw_data[1]+Calib_x), static_cast<double>(raw_data[0])+Calib_y); // heading = arctan(Y/X)
     
     // TODO: declenation angle compensation
     
--- a/HMC5883L.h	Tue Nov 06 17:35:51 2012 +0000
+++ b/HMC5883L.h	Wed Feb 06 11:53:18 2019 +0000
@@ -217,7 +217,7 @@
     * 
     * @returns heading in radians
     */
-    double getHeadingXY();
+    double getHeadingXY(int Calib_x,int Calib_y);
     
     /**
     * Function for getting degree heading using 2-dimensional calculation.
@@ -229,8 +229,8 @@
     * 
     * @returns heading in degrees
     */
-    double getHeadingXYDeg() {
-        return (getHeadingXY() * RAD_TO_DEG);
+    double getHeadingXYDeg(int Calib_x,int Calib_y) {
+        return (getHeadingXY(Calib_x,Calib_y) * RAD_TO_DEG);
     }
 
 private: