Open judaco opened 7 years ago
//
// ViewController.m
// Core Motion
//
// Created by hackeru on 11/06/2017.
// Copyright © 2017 juda. All rights reserved.
//
#import "ViewController.h"
#import <CoreMotion/CoreMotion.h>
@interface ViewController ()
@end
@implementation ViewController
{
CMMotionManager * motionManager;
double max;
}
- (void)viewDidLoad {
[super viewDidLoad];
//Gyroscope
motionManager = [[CMMotionManager alloc] init];
if (motionManager.accelerometerAvailable) {
[motionManager startAccelerometerUpdatesToQueue:[[NSOperation alloc] init] withHandler:^(CMAccelerometerData * _Nullable data, NSError * _Nullable error) {
if (data.acceleration.z > max) {
max = data.acceleration.z;
NSLog(@"%f", data.acceleration.z);
}
NSLog(@"%f %f %f", data.acceleration.x, data.acceleration.y, data.acceleration.z);
}];
}
if (motionManager.gyroAvailable) {
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end