1

Does anyone know how to adjust the iPhone's compass reading to adjust if you use it in landscape mode? The heading is always taken from the top of the device, but a true reading should be available if recalculations are made with the accelerometer data.

ACBurk
  • 4,418
  • 4
  • 34
  • 50

1 Answers1

2

I find the best way is to offset the heading by the number of degrees of tilt of the X axis.

I.e. straight up (home button at bottom), offset is 0. Tilt 90 degrees to right, add 90 degrees etc.

This will give you the correct heading to within ~3 degrees

Source: I'm making an AR satellite tracking app for the iPhone 3GS currently.

Alex Taylor
  • 7,128
  • 2
  • 26
  • 22
  • Hey Chaos, thanks for good trick. I have related problem that when the user move device to top of head with portrait mode, heading goes 0 to 360 but I have to keep it near 0. How did you solve this problem ? – fyasar Jul 20 '11 at 13:24
  • I recorded the angle (Y-tilt) that the compass flips over (about 68 degrees, if I recall correctly). Then, I subtract 180 degrees from the compass value, until they reach the vertical. – Alex Taylor Jul 23 '11 at 08:41