views:

356

answers:

2

I'm giving the user of an iPhone app the ability to use the tilt controls when standing, sitting, lying down etc. The user adjusts for each position by going to a settings screen, holding the phone at the desired angle, and tapping a save button. What's the best way to do this in the code?

The only thing I'm familiar with is the accelerometer delegate where I can get x, y, and z values.

+1  A: 

First of all, your approach seems rather odd but hey, it is your application...

I can not supply you with a complete solution but just a little hint; You will have to use the accelerometer delegate and filter the values using a low-pass filter to isolate gravity. Once you have the gravity vector, everything else should be rather straight-forward. Sorry for being so vague but thats all I got for you right now.

Till
+1  A: 

The solution you have right now seems to be the best one for calibration.

To do this in code, you just need to save the acceleration values when the button is pressed, then subtract those saved values from any new value to calibrate it.

jtbandes