Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to calibrate iPhone 3Gs Compass within an App?

I'm writing an app that's using the compass heading events.
I'm having a problem every now and then though with the app giving me -1 constantly as the heading until I exit, open Apple's compass App, then start my app again. It immediately starts working when I do that.

This problem doesn't happen all the time, but every now and then while I'm testing or after a day, it'll happen again. And it seems to be a calibration issue, and Apple's compass App is obviously able to do it instantly.

Another thing I noticed when this happens is if you open the Apple Compass App when I'm getting -1 values, for a split second Apple's compass will show 0 degrees, then the right one.


It must be doing some calibration when you start their app. Does anyone know how to perform that same calibration in an app? I looked through the CoreLocationManager documentation and couldn't find anything that said anything about calibrating, except for this:

+- (void)dismissHeadingCalibrationDisplay+

+Core Location uses the heading calibration panel to calibrate the available heading hardware as needed. The display of this view is automatic, assuming your delegate supports displaying the view at all. If the view is displayed, you can use this method to dismiss it after an appropriate amount of time to ensure that your application’s user interface is not unduly disrupted.+

So that's to dismiss the calibration display, but how do display the heading calibration panel or have it called?

And the way I implement the heading is as follows:

locationController = [[MyCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingHeading];


locationController is a MyCLController which is the class in Apple's LocateMe Sample App.

And I implement these two functions:
- (void)locationErrorNSError *)error
- (void)headingUpdateCLHeading *)heading

which get the events from the CLLocationManager delegate

Any ideas how to do this?

Macbook Pro 13", Mac OS X (10.5.8), Leopard

Posted on Sep 3, 2009 9:52 AM

Reply
3 replies

Sep 6, 2009 7:25 PM in response to K T

Thanks for the reply K T,

What if you need a simple calibration to just get any heading readings though?

It says in the documentation that there's a way to allow your delegate to accept the calibration dialog window. Anyone know how that's done?

I have a problem now where an entire feature of my app doesn't work unless you quit, open up the Compass up, and then re-open mine. That just seems silly.


-Ash

Sep 6, 2009 9:24 PM in response to Ash12345

What if you need a simple calibration to just get any heading readings though?


Same answer. Because the resources aren't as reliable as you planned for.

Would you prefer to give users the ability to machine-gun calibrations over and over, then get frustrated and blame you and Apple instead?

How to calibrate iPhone 3Gs Compass within an App?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.