I am creating an application for determining the location on the territory with iBeacons, but I use many iPhone sensors to get an accurate representation of movement (speed, direction, etc.). I am currently looping on the CoreMotion pedometer, and this is a step counting property. I have a piece of code that simply counts the steps and prints them on a shortcut, and I noticed that it takes about 10 steps before the device registers my movement and then updates the label every third or fourth step. These updates in the βwalkingβ state are wonderful, but Iβm interested in knowing whether it is possible to speed up the initial response and go from stationary β walking, and instead of 10, reduce 5 to an acceptable one. This is the code for counting steps:
if(CMPedometer.isStepCountingAvailable()){
self.pedoMeter.queryPedometerDataFromDate(NSDate(), toDate: NSDate()) { (data : CMPedometerData!, error) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if(error == nil){
self.steps.text = "\(data.numberOfSteps)"
}
})
}
self.pedoMeter.startPedometerUpdatesFromDate(NSDate()) { (data: CMPedometerData!, error) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if(error == nil){
self.steps.text = "\(data.numberOfSteps)"
}
})
}
}
}
manager.deviceMotionUpdateInterval = 0
,
let activityManager = CMMotionActivityManager()
let manager = CMMotionManager()
let pedoMeter = CMPedometer()