I am currently developing mobile web apps that make an extensive use of the deviceOrientation and deviceMotion HTML5 APIs. In most mobile browsers, the event fires every 50 millisecond which is too slow for the precision I need: is there a way to get the motion data at a higher rate?
I looked at the W3C DeviceOrientation Event Specification, and I noticed that the firing rate was given by the interval
property of the devicemotion
event, which is unfortunately readonly
(plus, I am not sure whether this is only an indicator of the refresh rate as implemented by the browser, or if this actually sets the refresh rate of the browser). I saw that the initAccelerometerEvent
method might allow to change this value, but I couldn't find how to use it directly in my Javascript code.
Alternatively, I thought we might be able to get the current value of the accelerometers / gyroscope: if such a method existed, we could use it in a setInterval
method so that we would set the refresh rate we want. Unfortunately, I couldn't find such a method.
So, any advice to have the motion values at a higher rate would be most welcome. Thank you very much for your help!