Accelerometer calibration

I'm using the accelerometer to move something around in X/Y on the screen.

This is easy if the phone starts flat on the table.

I've come up with something in an attempt to be able to start at any given position, and work from there. But it doesn't seem to work naturally.

How do I calibrate things so I can get the difference in orientation from the starting point?

cursorX -= accelerometerCalibrationY - getAccelerometerY();
cursorY += accelerometerCalibrationX - getAccelerometerX();

This works fine for flat on the table, and SOME starting positions. The variables are just getAccelerometerXY at the start.

12
задан PeterJ 22 December 2012 в 03:15
поделиться