0

I'm using Gear S3 and after update its accelerometer got very slow. Before updated I registered 20-25 samples in 30s. Now, I register 10-12 samples. Someone knows why trouble?

var t0 = 0;
var cont = 0;

function onDeviceMotion(event){
    var x = event.acceleration.x.toFixed(2);
    var y = event.acceleration.y.toFixed(2);
    var z = event.acceleration.z.toFixed(2);
    var t = ((new Date().getSeconds() + 60) - t0)%60;

    var components = {
    x: x,
    y: y,
    z: z,
    t : t
    }

    counter.innerHTML = cont++;
    start.innerHTML = components.t;

    console.log(components.x + " " + components.y + " " + components.z + " " + components.t+ " " + new Date().getSeconds() );

}


window.addEventListener('devicemotion', onDeviceMotion);
4

1 回答 1

2

根据您可能要使用的设备ACCELERATIONLINEAR_ ACCELERATION. 您可以通过调用来检查可用的传感器tizen.sensorservice.getAvailableSensors();在我的情况下是LINEAR_ACCELERATION(Samsung Gear Sport)。您还可以修改希望传感器回调的频率(1000 是每秒一次)。

function startAccelerometerSensor() {
	var accelerationSensor = tizen.sensorservice
			.getDefaultSensor("LINEAR_ACCELERATION");
	accelerationSensor.setChangeListener(onChangedCBAccelerometer, 1000);
	accelerationSensor.start(onSuccessCBAccelerometer);
}

function onSuccessCBAccelerometer() {
	console.log('Accelerometer service has started successfully.');
}

function onChangedCBAccelerometer(sensorData) {
	console.log("######## Get ACCELEROMETER sensor data ########");
	console.log("X : " + sensorData.x);
	console.log("Y : " + sensorData.y);
	console.log("Z : " + sensorData.z);
}

这是文档

于 2018-04-11T12:26:36.220 回答