0
-(void)play
{
    CMMotionManager *motionManager = [[CMMotionManager alloc] init];
    [motionManager startDeviceMotionUpdates];

    while(!self.stopButtonPressed)
    {
        NSLog(@"Y-Axis acceleration is %f", motionManager.deviceMotion.userAcceleration.y);
    }
}

console:

2012-08-03 13:06:10.798 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.803 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.805 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.807 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.808 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.810 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.812 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.814 MyProject[8896:3a03] Y-Axis acceleration is 0.000000
2012-08-03 13:06:10.817 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.820 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.822 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.824 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.826 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.828 MyProject[8896:3a03] Y-Axis acceleration is 0.013498
2012-08-03 13:06:10.831 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.833 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.835 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.837 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.840 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.842 MyProject[8896:3a03] Y-Axis acceleration is -0.082339
2012-08-03 13:06:10.846 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.848 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.850 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.852 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.855 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.857 MyProject[8896:3a03] Y-Axis acceleration is -0.099570
2012-08-03 13:06:10.859 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.862 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.864 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.866 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.868 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.870 MyProject[8896:3a03] Y-Axis acceleration is -0.120698
2012-08-03 13:06:10.873 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.875 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.877 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.879 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.881 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.882 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.884 MyProject[8896:3a03] Y-Axis acceleration is -0.125984
2012-08-03 13:06:10.888 MyProject[8896:3a03] Y-Axis acceleration is -0.083223
....etc.

According to the console, the acceleration values are updated every 14 microseconds on average

I'm not using a queue with an update interval explicitly, so should I assume that the default update interval is around 14 microseconds (when asking for new values from inside a while loop the way I have in this code specifically)?

Or is this "accidental" and I shouldn't rely on that ? I mean I have tested it a few times and the update interval is always between 13-14 ms, but is it possible (if I don't set an update interval explicitly) that the update interval changes significantly in some later testing if the processor happens to be "busier" (than normally..) for some reason at the time..?

Thank you for any help

4

1 回答 1

1

You should not rely on this interval, cause from UIAccelerometer class reference - maximum update interval is based on the available hardware, so when Apple will update Accelerometer chip in future devices, frequency may change ( it also can be different on current iPads and iPhones)

于 2012-08-03T13:14:59.647 回答