我发现此代码用于计算用户的脚步,但它无法正常工作。它没有显示确切的结果。
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
const float violence = 1.2;
static BOOL beenhere;
BOOL shake = FALSE;
if (beenhere) return;
beenhere = TRUE;
if (acceleration.x > violence || acceleration.x < (-1* violence))
shake = TRUE;
if (acceleration.y > violence || acceleration.y < (-1* violence))
shake = TRUE;
if (acceleration.z > violence || acceleration.z < (-1* violence))
shake = TRUE;
if (shake) {
steps=steps+1;
}
beenhere = false;
}
它也在检测错误的步骤。如何通过应用过滤器删除错误步骤?
几天来我一直在寻找信息,并在这里找到了一些信息:http ://www.analog.com/library/analogDialogue/archives/41-03/pedometer.html ,但我无法应用它。