Are there any good examples of how to use accelerometers in iPhone OS?

I think there are some issues with Gravity Earth, so I wonder if there are any examples where accelerometers work by subtracting them.

+1


source to share


2 answers


(Too bad you can't log a bug on planet Earth to fix her gravity problem!)

There are several examples, listed in the "Related Code Sample" section of UIAcceleration Class Reference .



As stated in this document, 1.0 is roughly + 1g. So if you point the iPhone directly in portrait orientation, you'll see something like <0, -1, 0>. When you rotate the phone around, the magnitude of the acceleration vector sqrt(x*x+y*y+z*z)

should remain around 1.

+3


source


The Apple AccelerometerGraph demo includes sample code that implements a high-pass filter — effectively filters out the effect of gravity. It's pretty easy to just grab it and change it to suit your needs.



+2


source







All Articles