Answer the question
In order to leave comments, you need to log in
How to make a compass on Android when the phone is held vertically?
In the horizontal position, everything is obvious and simple, but if you turn the phone vertically, problems appear. you need to use an accelerometer, but I can’t figure out how and what to count. Maybe there are open source examples? Or what article about it?
Answer the question
In order to leave comments, you need to log in
If you turn the phone vertically, you need to use a different axis of the compass. If she is, of course. For example, Honeywell's widely used HMC5883L compass has 3 axes. Accordingly, when you turn the compass "on the butt" - another axis works (well, for example, not Z, but Y). You can track turns using the accelerometer.
If the compass has only one axis, then the axel will not help you. You can fish out some data about the direction if the phone is not rotated quite vertically - but there will be no accuracy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question