The problem is that when I flip my phone, the compass flips too, but I don’t want it to. I would like it to give the same reading no matter what the pitch or roll of the device is. What I need this for is to calibrate the gyroscope. Overall the gyroscope is quite accurate, but over time it drifts on the yaw axis and I would like to use the compass to calibrate it, but when at the time of calibration the device is upside down it would calibrate the gyroscope to point in exactly the opposite direction.
I tried searching the internet for how to handle the raw data, but failed to find anything that I could wrap my head around.
What would be the best way of dealing with this problem?
Thanks in advance.