ios - 将 iPhone 加速度计设置为 ±8g 模式

标签 ios iphone accelerometer

是否可以将 iPhone 加速度计设置为在 ±8g 范围内接收数据? (据我所知ST LIS331DLH iPhone上安装的加速度计支持此模式)

我们不仅在研究标准 API,还在研究

  • 未记录的函数
  • 可能的 iOS 黑客攻击
  • 硬件修补

无论如何都要将加速度计范围扩展到标准±2g之外

最佳答案

我的“回答”包含对 Evgeny 问题的直接回答。但是我发现了一堆可能有帮助的未记录的功能。

我在 iOS SDK 中搜索了与加速度计相关的函数。似乎一切都归结为两个框架之一(其他框架依赖其中之一):SpringBoardServices(私有(private))和 CoreMotion。

SpingBoardServices API 相对简单: 另请参阅:SBSAccelerometer description

objective-c API:

@interface SBSAccelerometer : XXUnknownSuperclass {
    id<SBSAccelerometerDelegate> _delegate;
    CFRunLoopSourceRef _accelerometerEventsSource;
    CFRunLoopRef _accelerometerEventsRunLoop;
    double _interval;
    NSLock* _lock;
    BOOL _orientationEventsEnabled;
    int _orientationEventsToken;
    NSThread* _orientationEventsThread;
    float _xThreshold;
    float _yThreshold;
    float _zThreshold;
}
@property(assign, nonatomic) id<SBSAccelerometerDelegate> delegate;
@property(assign, nonatomic) BOOL orientationEventsEnabled;
@property(assign, nonatomic) float zThreshold;
@property(assign, nonatomic) float yThreshold;
@property(assign, nonatomic) float xThreshold;
@property(assign, nonatomic) double updateInterval;
@property(assign, nonatomic) BOOL accelerometerEventsEnabled;
-(id)init;
-(void)dealloc;
-(void)_checkIn;
-(void)_checkOut;
-(void)_serverWasRestarted;
-(int)currentDeviceOrientation;
-(id)_orientationEventsThread;
-(void)_orientationDidChange;
@end 

C-API(方法的签名未知):

int SBAccelerometer_server(struct unknown *in, struct unknown *out); //returns 1 on success, 0 otherwise
int SBAccelerometer_server_routine(struct unknown *in); // retuns 0 on error;
(?) SBSetAccelerometerClientEventsEnabled(...);
(?) SBSetAccelerometerDeviceOrientationChangedEventsEnabled(...);
(?) SBSetAccelerometerRawEventsInterval(...);
(?) SBXXDeliverAccelerometerEvent(...);
(NSString* or char*) _SBXXSBAccelerometer_subsystem;

CoreMotion 框架底层 API 是 C++ API。我不会发布所有 API(它比 SpingBoardServices 大得多),但有最有前途的部分:

CLSensorFusionAccelerometerOnly::reset(float)
CLSensorNetworkProtocol::isAccelerometerPacket(__CFData const*)
CLSensorNetworkProtocol::serializeAccelerometerPacket(CLAccelerometer::Sample const&)
CLSensorNetworkProtocol::deserializeAccelerometerPacket(__CFData const*)
CLSensorInterface::setAccelerometerCallbackAndInfo(void (*)(void*, CLMotionTypeVector3 const&, double const&), void*)

关于ios - 将 iPhone 加速度计设置为 ±8g 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10789211/

相关文章:

ios - GCD 主线程崩溃问题(需要解释)?

javascript - 如何使用 EAS BUILD 解决 IOS 应用启动时崩溃的问题

ios - XCODE 8.2 错误地检测到锁定的设备

ios - 如何解决xcode中的循环依赖错误

iphone - 如何在 NSMutableDictionary 中存储自定义对象?

ios - 当设备笔直且不倾斜时,如何让我的加速度计不移动我的节点?

ios - UILocalNotification 和区域监控

ios - 如何在collectionView中嵌入一些具有不同数据的tableView?

iphone - 如何从 iphone 的 X、Y、Z 加速度计读数计算行进方向的加速度/减速度

android - 跨多个设备的不同加速度计值