I'm trying to detect the tilt direction of a device using it's gyroscope. At the moment I'm using jquery mobiles's \[code\]deviceorientation\[/code\] event. Testing with the alpha results, I'm unable to get a stable responce from the phone, even why it's laid down flat, it still throws lots of values and quite spikey ones at that. Here's the code I'm currently using unsuccessfully. I can get a stable up/ down:\[code\]function gyroDirection() {var oldAlpha = 0;var initAlpha;var firstRun = true;$(window).on('deviceorientation', function(event) { if(firstRun) { oldAlpha = Math.round(event.originalEvent.alpha/ 10) * 10 ; firstRun = false; } var newAlpha = Math.round(event.originalEvent.alpha/ 10) * 10; if (newAlpha > oldAlpha) { console.log('up' , newAlpha) } else { console.log('down', newAlpha) } oldAlpha = newAlpha;})\[/code\]}