Skip to content

Instantly share code, notes, and snippets.

@zapsleep
Last active December 20, 2015 01:49
Show Gist options
  • Save zapsleep/6051927 to your computer and use it in GitHub Desktop.
Save zapsleep/6051927 to your computer and use it in GitHub Desktop.
Gist for updateMotionData method
- (void)updateMotionData {
//1
CMAcceleration acceleration = self.motionManager.deviceMotion.userAcceleration;
self.accelerationXVal.text = [NSString stringWithFormat:@"%.3f", acceleration.x];
self.accelerationYVal.text = [NSString stringWithFormat:@"%.3f", acceleration.y];
self.accelerationZVal.text = [NSString stringWithFormat:@"%.3f", acceleration.z];
//
//2
CMAcceleration gravity = self.motionManager.deviceMotion.gravity;
self.gravityXVal.text = [NSString stringWithFormat:@"%.3f", gravity.x];
self.gravityYVal.text = [NSString stringWithFormat:@"%.3f", gravity.y];
self.gravityZVal.text = [NSString stringWithFormat:@"%.3f", gravity.z];
//
//3
CMRotationRate rotation = self.motionManager.deviceMotion.rotationRate;
self.rotationXVal.text = [NSString stringWithFormat:@"%.3f", rotation.x];
self.rotationYVal.text = [NSString stringWithFormat:@"%.3f", rotation.y];
self.rotationZVal.text = [NSString stringWithFormat:@"%.3f", rotation.z];
//
//4
CMAttitude *attitude = self.motionManager.deviceMotion.attitude;
self.pitch.text = [NSString stringWithFormat:@"%.3f", attitude.pitch];
self.roll.text = [NSString stringWithFormat:@"%.3f", attitude.roll];
self.yaw.text = [NSString stringWithFormat:@"%.3f", attitude.yaw];
//
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment