Question

I am building a simple accelerometer app in PhoneGap primarily targeted to Android, and depending on what I set the frequency to, I get very inconsistent readings. If I set the frequency to 100, I get 10 measurements a second. However if I try something like frequency of 50ms or 40 or 10, I get very inconsistent readings of anything from 18 to 27 readings a second.

Was it helpful?

Solution

I think it comes down to the fact that setInterval is not guaranteed to fire at the interval that you provide. Since JavaScript is single threaded it may be busy doing something else when the interval time is reached. This would account for the variable readings you are getting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top