ULTRAVIOLET : 'ULTRAVIOLET',
HRM_RAW : 'HRM_RAW',
GRAVITY : 'GRAVITY',
+ GYROSCOPE : 'GYROSCOPE',
+ GYROSCOPE_ROTATION_VECTOR : 'GYROSCOPE_ROTATION_VECTOR',
};
var ProximityState = {
'ULTRAVIOLET' : {},
'HRM_RAW' : {},
'GRAVITY' : {},
+ 'GYROSCOPE' : {},
+ 'GYROSCOPE_ROTATION_VECTOR' : {},
};
var _listener = function(object) {
return new HRMRawSensor();
} else if (_supportedSensors[index] === SensorType.GRAVITY) {
return new GravitySensor();
+ } else if(_supportedSensors[index] === SensorType.GYROSCOPE){
+ return new GyroscopeSensor();
+ } else if(_supportedSensors[index] === SensorType.GYROSCOPE_ROTATION_VECTOR){
+ return new GyroscopeRotationVectorSensor();
}
};
_sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
};
+
+
+//// GyroscopeSensor
+var GyroscopeSensor = function(data) {
+ Sensor.call(this, SensorType.GYROSCOPE);
+};
+
+GyroscopeSensor.prototype = new Sensor();
+
+GyroscopeSensor.prototype.constructor = Sensor;
+
+GyroscopeSensor.prototype.getGyroscopeSensorData = function() {
+ var args = validator_.validateArgs(arguments, [
+ {
+ name : 'successCallback',
+ type : types_.FUNCTION
+ },
+ {
+ name : 'errorCallback',
+ type : types_.FUNCTION,
+ optional : true,
+ nullable : true
+ }
+ ]);
+
+ _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
+};
+
+//// GyroscopeRotationVectorSensor
+var GyroscopeRotationVectorSensor = function(data) {
+ Sensor.call(this, SensorType.GYROSCOPE);
+};
+
+GyroscopeRotationVectorSensor.prototype = new Sensor();
+
+GyroscopeRotationVectorSensor.prototype.constructor = Sensor;
+
+GyroscopeRotationVectorSensor.prototype.getGyroscopeRotationVectorSensorData = function() {
+ var args = validator_.validateArgs(arguments, [
+ {
+ name : 'successCallback',
+ type : types_.FUNCTION
+ },
+ {
+ name : 'errorCallback',
+ type : types_.FUNCTION,
+ optional : true,
+ nullable : true
+ }
+ ]);
+
+ _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
+};
+
////////////////////// Sensor Data classes/////////////////////////////////////////////////////
////Base SensorData class
var SensorData = function () {
SensorGravityData);
+
+//// SensorGyroscopeData
+var SensorGyroscopeData = function(data) {
+ SensorData.call(this);
+ Object.defineProperties(this, {
+ x : {value: data.x, writable: false, enumerable: true},
+ y : {value: data.y, writable: false, enumerable: true},
+ z : {value: data.z, writable: false, enumerable: true},
+ });
+};
+
+SensorGyroscopeData.prototype = new SensorData();
+
+SensorGyroscopeData.prototype.constructor = SensorData;
+
+_sensorListeners[SensorType.GYROSCOPE] = new SensorListener(SensorType.GYROSCOPE,
+ SensorGyroscopeData);
+
+//// SensorGyroscopeRotationVectorData
+var SensorGyroscopeRotationVectorData = function(data) {
+ SensorData.call(this);
+ Object.defineProperties(this, {
+ x : {value: data.x, writable: false, enumerable: true},
+ y : {value: data.y, writable: false, enumerable: true},
+ z : {value: data.z, writable: false, enumerable: true},
+ w : {value: data.w, writable: false, enumerable: true},
+ });
+};
+
+SensorGyroscopeRotationVectorData.prototype = new SensorData();
+
+SensorGyroscopeRotationVectorData.prototype.constructor = SensorData;
+
+_sensorListeners[SensorType.GYROSCOPE_ROTATION_VECTOR] = new SensorListener(SensorType.GYROSCOPE_ROTATION_VECTOR,
+ SensorGyroscopeRotationVectorData);
+
// Exports
exports = new SensorService();
(*out)["z"] = picojson::value(static_cast<double>(sensor_event->values[2]));
break;
}
+ case SENSOR_GYROSCOPE: {
+ (*out)["x"] = picojson::value(static_cast<double>(sensor_event->values[0]));
+ (*out)["y"] = picojson::value(static_cast<double>(sensor_event->values[1]));
+ (*out)["z"] = picojson::value(static_cast<double>(sensor_event->values[2]));
+ break;
+ }
+ case SENSOR_GYROSCOPE_ROTATION_VECTOR: {
+ (*out)["x"] = picojson::value(static_cast<double>(sensor_event->values[0]));
+ (*out)["y"] = picojson::value(static_cast<double>(sensor_event->values[1]));
+ (*out)["z"] = picojson::value(static_cast<double>(sensor_event->values[2]));
+ (*out)["w"] = picojson::value(static_cast<double>(sensor_event->values[3]));
+ break;
+ }
default: {
LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Unsupported type"), out);
return;
AddSensor(new SensorData(instance, SENSOR_ULTRAVIOLET, "ULTRAVIOLET"));
AddSensor(new HrmSensorData(instance));
AddSensor(new SensorData(instance, SENSOR_GRAVITY, "GRAVITY"));
+ AddSensor(new SensorData(instance, SENSOR_GYROSCOPE, "GYROSCOPE"));
+ AddSensor(new SensorData(instance, SENSOR_GYROSCOPE_ROTATION_VECTOR, "GYROSCOPE_ROTATION_VECTOR"));
}
SensorService::~SensorService() {