Set iPhone accelerometer to ±8g mode

元气小坏坏 提交于 2019-12-20 11:09:49

问题


Is it possible to set iPhone accelerometer to receive data in the ±8g range? (as far as I know ST LIS331DLH accelerometer installed on iPhone supports this mode)

We are looking not only into standard API, but also

  • undocumented functions
  • possible iOS hacks
  • hardware tinkering

Anyway to extend accelerometer range beyond standard ±2g


回答1:


My "answer" doesn't contain direct answer to Evgeny's question. However I found a bunch of undocumented functions which probably can help.

I have searched whithin iOS SDK for functions related to accelerometer. It seems like everything boils down to one of two frameworks (other frameworks rely on one of these): SpringBoardServices (Private) and CoreMotion.

SpingBoardServices API is relatively simple: See also: 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 (methods' signatures are unknown):

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 framework low-level API is C++ API. I won't publish all the API (it's much bigger than SpingBoardServices'), but there are most promising parts:

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*)



回答2:


Unfortunately, there is no native way to do this. On the other hand, if you are willing to Jailbreak, there is a Cydia tweak you can get (I can't remember the name) that reduces the sensitivity of the accelerometer. If you have the sensitivity of it at 25%, it should be able to sense ±8g. FYI, if you are reading the output from your app, it will still range from ±2g but with the tweak, you have to remember that the readings will be scaled down by 1/4. (Meaning 2g in the app = 8g in actual space).



来源:https://stackoverflow.com/questions/10789211/set-iphone-accelerometer-to-%c2%b18g-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!