有没有办法拿到钛合金的陀螺仪数据?就像提供了一个访问accelerometer数据的应用程序接口一样。
发布于 2014-04-23 22:42:10
目前还没有,但是有一种相对简单的方法可以让您向已经使用CoreMotion的现有模块添加一些代码。
Ben Bahrenburg的模块,可在此处获得:https://github.com/benbahrenburg/Ti.CoreMotion/使用CoreMotion公开一个步长计数器。所以它已经有了引用的框架,以及模块的设置,构建等。这是困难的事情。所以只要把它拉下来,确保你可以自己./build.py它,然后暴露陀螺仪。完成后给他发一份公关,并回馈社区!
static const NSTimeInterval gyroMin = 0.01;
- (id)startGyro:(id)args {
// Determine the update interval
NSTimeInterval delta = 0.005;
NSTimeInterval updateInterval = gyroMin + delta;
// Create a CMMotionManager
CMMotionManager *mManager = [(APLAppDelegate *)[[UIApplication sharedApplication] delegate] sharedManager];
APLGyroGraphViewController * __weak weakSelf = self;
// Check whether the gyroscope is available
if ([mManager isGyroAvailable] == YES) {
// Assign the update interval to the motion manager
[mManager setGyroUpdateInterval:updateInterval];
[mManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMGyroData *gyroData, NSError *error) {
// TODO: Do something with gyroData.rotationRate.x, y, and z.
}];
}
return nil;
}
- (id)stopUpdates:(id)args {
CMMotionManager *mManager = [(APLAppDelegate *)[[UIApplication sharedApplication] delegate] sharedManager];
if ([mManager isGyroActive] == YES) {
[mManager stopGyroUpdates];
}
return nil;
}记住:使用Core Motion,您必须在设备上测试和调试您的应用程序。iOS模拟器中不支持加速度计或陀螺仪数据。
https://stackoverflow.com/questions/23239925
复制相似问题