Thanks, but what are the final digits ? Degree angles ?
I need the compass heading, but not by ORIENTATION sensor at horizontal phone position - but the same compass heading if phne is vertically placed.
Well, it all depends. If you are only using the phone in a perfectly upright position, that's enough. However, users frequently tilt the device, so it mihgt be prudent to use a full orientation.
What you need to do is to use accelerometers to find down. From down, it's easy to find forward, it's 90 degrees off down in the forward/up direction.
Then, you get the three orientation values to get a 3D vector. Project that vector on the forward direction, and you'll have a heading that works regardless of device orientation.
However, be aware that the magnetic sensor is usually extremely fickle, don't rely on it to be accurate, even under the best of circumstances. If the device is moving, you'll get a much more accurate reading from the GPS, which simply calculates the direction between current and previous positions.