Page 1 of 1

mobileEnableAccelerometer question...

Posted: Sun Mar 24, 2013 12:20 pm
by paulsr
Greetings:

I am wondering, is there an error in the documentation.
Syntax:
mobileEnableAccelerometer [interval]

The mobileEnableAccelerometer command enables the accelerometer on the device.

The interval is specified in seconds and is the approximate time between delivery of messages.
The way I read that, it means I can define how often I want the accelerationChanged handler to send me updates. But, no matter what value I set for "interval" I seem to get an instant update any time there is any kind of movement.

I only have to tap my iPad to get an acceleration changed message. In fact, I only need to tap my desk.

The documentation says the interval is in seconds, but shows an example of 100. So, I guessing it means milliseconds. I've tried setting 2000, but still get an instant reading from the accelerometer.

Am I right in thinking the "interval" value does nothing?

TIA...

--paul

Re: mobileEnableAccelerometer question...

Posted: Sun Mar 24, 2013 9:36 pm
by Simon
Hi Paul,
Form the dictionary:
Note: The interval is constrained by hardware-specific minimums and maximums (which are left unspecified by Apple).
Nice, unspecified... No way of knowing what an interval is.
Probably best you just read the accelerationChanged message when you want the information not the other way around.

Simon

Re: mobileEnableAccelerometer question...

Posted: Mon Mar 25, 2013 2:44 am
by paulsr
Yeah, thanks Simon ... I did spot that, but assumed LC would only give me an acceleration changed notification if the iPad's interval was greater than the one I had requested. (If that makes any sense.) So, I think I'm right in saying the "interval" parameter doesn't do anything.

I'm trying to detect the motion of a vehicle (from rest) and on reflection, I think this is perhaps best done with locationChanged. I encountered a problem with this method, in that, if the GPS' horizontal accuracy changes while the vehicle is stationary, the "position" returned by locationChanged also changes, making it seem like the vehicle moved, when it didn't. But I guess I can program around that :)

--paul