Built from datasheet for 9-DOF sensor stick from SparkFun.
Fork of HMC5883L by
Diff: HMC5883L.cpp
- Revision:
- 2:8eb755577f83
- Parent:
- 1:8a1357c351c6
- Child:
- 3:14d274e0f9de
--- 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