richtr/Full-Tilt — pull request #5 by dorukeker (2014-11-18 20:36:30+00:00)
Title: Availability check

Added new functions to DeviceMotion and DeviceOrientation classes.
After the promise resolves you can check on the availability of sensor data.
For device orientation:

var promise = new FULLTILT.getDeviceOrientation({ 'type': 'world' });
promise.then(function(deviceOrientation) {

deviceOrientation.isAvailable(); // returns true if alpha, beta and gamma values exist and not null

});

and for DeviceMotion:

var promise = new FULLTILT.getDeviceMotion({ 'type': 'world' });
promise.then(function(deviceMotion) {

deviceMotion.isAvailable(deviceMotion.ACCELERATION);
// returns true if acceleration values exist and not null

deviceMotion.isAvailable(deviceMotion.ACCELERATION_INCLUDING_GRAVITY);
// returns true if acceleration including gravity values exist and not null

deviceMotion.isAvailable(deviceMotion.ROTATION_RATE);
// returns true if rotation rate values exist and not null

deviceMotion.isAvailable();
// returns an object for the availability of the sensor data
/*
{
acceleration:,
accelerationIncludingGravity:,
rotationRate:
}
*/

});

You can see a sample usage in the data_display.html in the examples.
Let me know what you think.
Cheers!