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