Prevent mirroring of compass heading across North/South axis

The tilt compensation algorithm previously mirrored the compass heading value
across a North/South axis i.e. West measured as East and vice versa. This
patch corrects the calculation.
This commit is contained in:
Joe Finney 2018-09-13 14:51:50 +01:00
parent d3d64283a7
commit 50bb8d9458

View file

@ -471,7 +471,7 @@ int MicroBitCompass::tiltCompensatedBearing()
float bearing = (360*atan2(x*cosTheta + y*sinTheta*sinPhi + z*sinTheta*cosPhi, z*sinPhi - y*cosPhi)) / (2*PI);
// Handle the 90 degree offset caused by the NORTH_EAST_DOWN based calculation.
bearing = bearing - 90;
bearing = 90 - bearing;
// Ensure the calculated bearing is in the 0..359 degree range.
if (bearing < 0)