I have code which is written:
if ('DeviceMotionEvent' in window) {
deviceMotion = new DeviceMotionEvent("devicemotion", {interval: 20, acceleration:DeviceMotionEventAcceleration});
window.addEventListener("devicemotion", onDeviceMotion, false);
window.dispatchEvent(deviceMotion);
}
function onDeviceMotion(eventData){
accelerationHandler(eventData.acceleration);
intervalHandler(eventData.interval);
}
function accelerationHandler(acceleration) {
document.getElementById("ac_x").innerHTML = acceleration.x.toFixed(precision);
document.getElementById("ac_y").innerHTML = acceleration.y.toFixed(precision);
document.getElementById("ac_z").innerHTML = acceleration.z.toFixed(precision);
}
function intervalHandler(interval) {
document.getElementById("ac_interval").innerHTML = interval;
}
I want to set the interval as 20 but the above code gives me a default interval 16.
How can i properly set the interval?