[iphone] Removing the influence of gravity on accelerometer readings
I'd like to combine the data from another axis (X I believe, I don't have the diagram handy) to negate this effect.
For example, if the phone is laying flat on its back, the Y axis should read 0 and the X axis should read 1g. If one end of the phone is then lifted, the reading on the Y axis should increase (if the top of the device is lifted) and the X axis should decrease.
So I should be able to combine these values mathematically and filter this effect from the "real" acceleration data I'm interested in the Y axis, correct?
I think there would be limits since I imagine beyond a certain point of deflection the readings from the Y accelerometer will become too inaccurate, but if I could compensate for minor changes in device angle that would be sufficient for my application.
I've tried a few approaches to this but either my math skills or some nonlinearity of the accelerometer are leading to unexpected results.
Is this possible, or is there an easier answer to this problem? Any ideas are appreciated.
Thanks!
iPod Touch, Mac OS X (10.5.5)