iOS iPhone 5 CMMotion deviceMotionUpdateInterval issue

747 Views Asked by At

I have been using CMMotionManager successfully with iOS 6.0 and 4th generation iPhone and iPod touch. The new iPhone 5 seems to run at an update interval that is twice as long as specified. If the kTIME_INTERVAL is 0.0125, I see actual intervals of about 0.021.

When I set the interval to 0.0125 / 2.0, the actual timer intervals are close to 0.013 which is what I want.

Is anyone seeing similar behavior with CMMotionManager on iPhone 5?

CMMotionManager *motion;

motion.deviceMotionUpdateInterval = kTIME_INTERVAL; // iPhone 4 and 4th gen devices

if (isDevice5thGeneration) {
    // iPhone 5 iOS 6 seems to run motion at twice the update interval (half as fast), so need to set interval at half to get desired interval
    motion.deviceMotionUpdateInterval = motion.deviceMotionUpdateInterval / 2.0; // iPhone 5 KLUDGE 
}
NSLog(@"Start motion recording deviceMotionUpdateInterval: %f", motion.deviceMotionUpdateInterval);

NSOperationQueue *queue = [[NSOperationQueue currentQueue] retain];

CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *deviceMotion, NSError *error) {
    //NSLog(@"motion handler");
    if (isRecordingMotion) {
        [self processMotion:deviceMotion];
    }
};
[motion startDeviceMotionUpdatesToQueue:queue withHandler:motionHandler];

Thanks in advance!

0

There are 0 best solutions below