Languages

Menu
Sites
Language
I want to get gyroscope sensor values
X: <div id="gyroX"></div>
Y: <div id="gyroY"></div>
Z: <div id="gyroZ"></div>
var gyroscopeSensor = tizen.sensorservice.getDefaultSensor("GYROSCOPE");
function onGetSuccessCB(sensorData) {
document.getElementById("gyroX").innerHTML = sensorData.x;
document.getElementById("gyroY").innerHTML = sensorData.y;
document.getElementById("gyroZ").innerHTML = sensorData.z;
}
function onsuccessCB() {
gyroscopeSensor.getGyroscopeSensorData(onGetSuccessCB);
}
gyroscopeSensor.start(onsuccessCB);
The x, y and z are fixed at 1 or -1, not change.
 

 

 

Edited by: ahjin lee on 17 Sep, 2020

Responses

1 Replies
Erik van Gompel

This worked OK for me on my Galaxy Watch Active.

    	window.addEventListener('devicemotion', function(e) {
			var gyroX = e.accelerationIncludingGravity.x;
			var gyroY = e.accelerationIncludingGravity.y;
			var gyroZ = e.accelerationIncludingGravity.z;

			document.getElementById('gyroX').innerHTML = gyroX;
			document.getElementById('gyroY').innerHTML = gyroY;
			document.getElementById('gyroZ').innerHTML = gyroZ;
		}, true);