我正在使用齿轮S3,更新后的加速度计非常慢。在更新之前,我在30年代注册了20-25个样本。现在,我注册了10-12个样本。有人知道为什么麻烦吗?
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);
取决于您可能需要使用ACCELERATION
或LINEAR_ ACCELERATION
的设备。您可以通过致电tizen.sensorservice.getAvailableSensors();
来检查可用的传感器,如果我的情况是LINEAR_ACCELERATION
(三星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);
}
这是文档