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

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

コンソール:

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.

コンソールによると、加速度値は平均で 14 マイクロ秒ごとに更新されます

私は更新間隔を明示的に指定したキューを使用していないので、デフォルトの更新間隔は約 14 マイクロ秒であると仮定する必要があります (このコードで具体的に示した方法で while ループ内から新しい値を要求する場合)。

それとも、これは「偶然」であり、それに頼るべきではありませんか? 私はそれを数回テストしたことを意味し、更新間隔は常に13〜14ミリ秒ですが、(更新間隔を明示的に設定しない場合)プロセッサがその時、何らかの理由でたまたま「忙しい」(通常より..)..?

助けてくれてありがとう

4

1 に答える 1

1

この間隔に依存しないでください。UIAccelerometerクラス リファレンスが原因です。最大更新間隔は利用可能なハードウェアに基づいているため、Apple が将来のデバイスで Accelerometer チップを更新すると、頻度が変わる可能性があります (現在の iPad と iPhone では異なる場合もあります)。

于 2012-08-03T13:14:59.647 に答える