【发布时间】:2013-08-29 19:17:26
【问题描述】:
我正在使用推送方法收集加速度计和陀螺仪数据(startDeviceMotionUpdatesToQueue:withHandler: 和 startGyroUpdatesToQueue:[NSOperationQueue mainQueue] 我将这些原始数据与某些阈值进行比较,如果它满足阈值,我确实将标签计数器增加一,我的问题是当我开始检测即读取方法并将其与阈值进行比较时,计数器增加得如此之快,我已经阅读在 (Simple iPhone motion detect) 中说“如果条件对于每个动作都会变为真两次”,所以如果这是发生在我身上的事情,我该如何解决这个问题,我的代码很简单
检查数据{
if ( ( acc_2 >= 0.03885) && (gyro_3 >= 0.0003) && (gyro_3 <= 0.00838))
{
i=i+1;
//then Label data
_Counter.text=[NSString stringWithFormat:@"%d",i];
}
else if (( acc_2>= 0.01103) && ( gyro_3 >= 0.00851))
{
/
//update the counter
i=i+1;
_Counter.text=[NSString stringWithFormat:@"%d",i];
}
...... same other conditions
}
然后我在 startDeviceMotionUpdatesToQueue:withHandler: 块中调用此方法。
[自检数据];
我可以做些什么来解决这个问题,你能指导我吗? }
【问题讨论】:
标签: ios objective-c accelerometer gyroscope threshold