Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Seeed_Grove_Digital_Compass_Example
Fork of HMC5883L by
Revision 5:6a47ae8ee7ea, committed 2018-10-03
- Comitter:
- tichise
- Date:
- Wed Oct 03 13:30:54 2018 +0000
- Parent:
- 4:bc4e1201e092
- Commit message:
- corrected a fatal defect that can not be oriented properly
Changed in this revision
| HMC5883L.cpp | Show annotated file Show diff for this revision Revisions of this file | 
diff -r bc4e1201e092 -r 6a47ae8ee7ea HMC5883L.cpp
--- a/HMC5883L.cpp	Tue Nov 06 17:35:51 2012 +0000
+++ b/HMC5883L.cpp	Wed Oct 03 13:30:54 2018 +0000
@@ -85,7 +85,7 @@
 char HMC5883L::getConfigurationB()
 {
     char cmd[2];
-    cmd[0] = CONFIG_A_REG; // register b address
+    cmd[0] = CONFIG_B_REG; // register b address
     i2c_.write(I2C_ADDRESS, cmd, 1, true);
     i2c_.read(I2C_ADDRESS, &cmd[1], 1, false);
     return cmd[1];
@@ -133,7 +133,7 @@
 {
     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[2]), static_cast<double>(raw_data[0])); // heading = arctan(Y/X)
     
     // TODO: declenation angle compensation
     
    