Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "nodeimu", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Native addon for accessing IMU/pressure/humidity/temperature sensors using RTIMULib2", | ||
@@ -5,0 +5,0 @@ "license": "BSD-2-Clause-FreeBSD", |
@@ -17,2 +17,3 @@ # nodeimu | ||
node test.js | ||
node testSync.js | ||
``` |
13
test.js
@@ -6,5 +6,10 @@ var util = require('util') | ||
var num = 0; | ||
var numStop = 100; | ||
console.time("async"); | ||
var tic = new Date(); | ||
var callb = function (e, data) { | ||
var toc = new Date(); | ||
if (e) { | ||
@@ -14,2 +19,3 @@ console.log(e); | ||
} | ||
var sx = data.accel.x >= 0 ? ' ' : ''; | ||
@@ -22,7 +28,8 @@ var sy = data.accel.y >= 0 ? ' ' : ''; | ||
num++; | ||
if (num == 100) { | ||
if (num == numStop) { | ||
console.timeEnd("async"); | ||
} else { | ||
setTimeout(function() { IMU.getValue(callb); } , 50); | ||
setTimeout(function() { tic = new Date(); IMU.getValue(callb); } , 50 - (toc - tic)); | ||
} | ||
@@ -32,1 +39,3 @@ } | ||
IMU.getValue(callb); | ||
@@ -6,7 +6,10 @@ var util = require('util') | ||
var num = 0; | ||
var numStop = 100; | ||
console.time("sync"); | ||
function dispAccel() { | ||
function dispAccel() { | ||
var tic = new Date(); | ||
var data = IMU.getValueSync(); | ||
var toc = new Date(); | ||
var sx = data.accel.x >= 0 ? ' ' : ''; | ||
@@ -19,9 +22,10 @@ var sy = data.accel.y >= 0 ? ' ' : ''; | ||
num++; | ||
if (num == 100) { | ||
clearInterval(intv); | ||
if (num == numStop) { | ||
console.timeEnd("sync"); | ||
} else { | ||
setTimeout(dispAccel, 50 - (toc - tic)); | ||
} | ||
} | ||
var intv = setInterval(dispAccel, 50); | ||
dispAccel(); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2438961
65
19