How to count steps using an Accelerometer?

前端 未结 2 757
死守一世寂寞
死守一世寂寞 2020-12-24 00:01

I have to develop the same functionality as of this Pedometer App

I have observed this Pedometer app in very high detail.

It\'s not a perfect pedometer app.

2条回答
  •  暖寄归人
    2020-12-24 00:20

            var motionManager = CMMotionManager()
            motionManager.deviceMotionUpdateInterval = 0.1
            motionManager.startDeviceMotionUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler:{
                deviceManager, error in
    
                var accelerationThreshold:Double = 1;
                var userAcceleration:CMAcceleration = deviceManager.userAcceleration;
                if(fabs(userAcceleration.x) > accelerationThreshold) || (fabs(userAcceleration.y) > accelerationThreshold) || (fabs(userAcceleration.z) > accelerationThreshold)
                {
                    println("LowPassFilterSignal")
                }
            })
    

提交回复
热议问题