Gravity
Handle operation on gravity sensor.
Usage
gravity
keyword is needed to instanciate this sting.
var gravity = require('gravity');
Data accessors
Methods
Events
Full Example
var gravity = require('gravity');
var recorder = require('recorder');
var dataResult = gravity.data();
recorder.save({
'accuracy' : gravity.accuracy(),
'model' : gravity.model(),
'BACK Position' : gravity.isPosition(gravity.BACK),
'timestamp' : gravity.timestamp(),
'vendor' : gravity.vendor(),
'version' : gravity.version(),
'x' : gravity.x(),
'y' : gravity.y(),
'z' : gravity.z(),
'json' : gravity.data()
});
gravity.onPositionChanged(exampleValue, function(data) {
recorder.save(data);
recorder.sync();
});
accuracy
Retrieve the Sensor’s current accuracy.
accuracy();
Parameters
- None.
Return
- accuracy : SensorAccuracy, Sensor’s current accuracy
isPosition
Test the current position value against the given one.
isPosition(value);
Parameters
- value : GravityPosition, type of position to test.
Return
- Boolean
model
Retrieve the Sensor’s model name.
model();
Parameters
- None.
Return
- model : String, Sensor’s model name
position
Retrieve the A human readable description of the device part oriented towards the ground.
position();
Parameters
- None.
Return
- position : GravityPosition, A human readable description of the device part oriented towards the ground
timestamp
Retrieve the represents the time of the operation..
timestamp();
Parameters
- None.
Return
- timestamp : Long, represents the time of the operation.
vendor
Retrieve the Sensor’s vendor name.
vendor();
Parameters
- None.
Return
- vendor : String, Sensor’s vendor name
version
Retrieve the Version of this sensor.
version();
Parameters
- None.
Return
- version : Integer, Version of this sensor
x
Retrieve the Gravity force along the x axis.
x();
Parameters
- None.
Return
- x : Double, Gravity force along the x axis
y
Retrieve the Gravity force along the y axis.
y();
Parameters
- None.
Return
- y : Double, Gravity force along the y axis
z
Retrieve the Gravity force along the z axis.
z();
Parameters
- None.
Return
- z : Double, Gravity force along the z axis
data
Returns every available seed.
data();
Parameters
- None.
Returns
onPositionChanged
Starts a listener on the gravity position and executes some actions when it changes.
onPositionChanged(filters, callback);
Parameters
- filters : JSON, defines the filters. Can be empty.
- callback : Method executed when event triggered, returns GravityData object.
Return
- token : Token used for canceling event listener.