Skip to content

Instantly share code, notes, and snippets.

@aheze
Created April 25, 2020 23:38
Show Gist options
  • Save aheze/7dbfe664308cd1998f163e91cd26a2e4 to your computer and use it in GitHub Desktop.
Save aheze/7dbfe664308cd1998f163e91cd26a2e4 to your computer and use it in GitHub Desktop.
/// This is how often we will get device motion updates
/// 0.03 is more than often enough and is about the rate that the video frame changes!
motionManager.deviceMotionUpdateInterval = 0.03
motionManager.startDeviceMotionUpdates(to: .main) {
[weak self] (data, error) in
guard let data = data, error == nil else {
return
}
/// This function will be called every 0.03 seconds
self?.updateHighlightOrientations(attitude: data.attitude)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment