123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
-
-
-
-
-
-
- var analogGyro = require('jsupm_enc03r');
-
- var myGyro = new analogGyro.ENC03R(0);
-
- var CALIBRATION_SAMPLES = 1000;
-
- console.log("Please place the sensor in a stable location,\n" +
- "and do not move it while calibration takes place.\n" +
- "This may take a couple of minutes.");
-
- myGyro.calibrate(CALIBRATION_SAMPLES);
- console.log("Calibration complete. Reference value: " +
- myGyro.calibrationValue());
-
-
-
- setInterval(function()
- {
- var gyroVal = myGyro.value();
- var outputStr = "Raw value: " + gyroVal + ", " +
- "angular velocity: " +
- roundNum(myGyro.angularVelocity(gyroVal), 5) + " deg/s";
- console.log(outputStr);
- }, 100);
-
- function roundNum(num, decimalPlaces)
- {
- var extraNum = (1 / (Math.pow(10, decimalPlaces) * 1000));
- return (Math.round((num + extraNum) * (Math.pow(10, decimalPlaces))) /
- Math.pow(10, decimalPlaces));
- }
-
-
- process.on('SIGINT', function()
- {
- console.log("Exiting...");
- process.exit(0);
- });
|