خرید بک لینک

Vote count: 0

hi guys i have javascript function to get acceleration and it givs result like that and my problem is to get speed using the acceleration is someone can help me plz ps : in my platform there is no speed api

function getDataFromSensor() {
  //call js.call to get data FROM accelerometer  
  var rt = js.call('api.sensors.getAccelerometer()', {});
  // parse JSONObject
  var obj = JSON.parse(rt);
  //get value of axe x
  var x = obj.accelerometerX;
  //get value of axe y 
  var y = obj.accelerometerY;
  //get value of axe z
  var z = obj.accelerometerZ;
  // use gravity according to your place in this example I Choose 9 
  var result = (x * x + y * y + z * z) / (9 * 9);
  //If mobile move any direction then the following condition will become true 
  if (result > 2) {
    //Generate random number between 0 and 1 every time and display on text view

    js.setProperty('menu.Text_1', 'text', "err");
  } else {
    js.setProperty('menu.Text_1', 'text', "result:" + result);
  }

}
asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 29 ارديبهشت 1395 ساعت: 8:13

صفحه بندی