The idea is to build my final app up from individual modules, starting with a Compass app, an accelerometer app, and location apps. The first few are pretty much completed.
The above screenshots show the compass app. The arrow is rotated according to data received from the handset's magnetometer, and always points North. I used the getRotation() method from the Display class to adjust for different orientations. This means that when the handset is held in landscape mode (as I anticipate it will for most uses) the compass 'face' points out from the back of the phone, rather than the top where the magnetometer is actually situated.
The code is available here.
I have noticed how easily the compass is affected by outside sources, the magnet on its case causes particular problems. The compass is easily recalibrated by moving it in a figure of 8 shape in the air however.
No comments:
Post a Comment