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.
Fork of HMC5883L by
Diff: HMC5883L.cpp
- Revision:
- 2:8eb755577f83
- Parent:
- 1:8a1357c351c6
- Child:
- 3:14d274e0f9de
diff -r 8a1357c351c6 -r 8eb755577f83 HMC5883L.cpp
--- 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
