Set iPhone accelerometer to ±8g mode
Asked Answered
S

2

28

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

Serle answered 28/5, 2012 at 18:52 Comment(2)
For more informations: iphonedevsdk.com/forum/iphone-sdk-development/…. You cannot change the mode with any published feature of the APIs. I guess you'll need a jailbroken device and a way to change the accelerometer mode BEFORE any call to the SDK functions.Selfconscious
don't you know what motion sensor is used on Apple Watch? As I see they have limit +-16gBuyer
R
6

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*)
Remorseless answered 4/6, 2012 at 17:43 Comment(0)
P
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).

Pneumograph answered 3/6, 2012 at 19:36 Comment(2)
I am ok with jailbreaking and tweaking device. What is the name of this tweak and where I can learn more about that?Serle
@EvgenyVinnik Sorry, I cannot remember. I had it on my iPhone because the orientation changed too easily. Now if this is your own app you can also scale the accelerometer output in your own code. i.e. accelOutput.x * 4 = X g forces ranging from -8 to +8. Sorry I can't help you more.Pneumograph

© 2022 - 2024 — McMap. All rights reserved.