enc03r: C port; FTI; C++ wraps C

The API for this driver has changed.  See docs/apichanges.md.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2017-01-27 17:58:35 -07:00
parent f914159e21
commit 1bbb9386b7
15 changed files with 758 additions and 165 deletions

View File

@ -30,8 +30,8 @@ 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.");
"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: " +
@ -41,23 +41,22 @@ console.log("Calibration complete. Reference value: " +
// waiting 0.1 seconds between readings
setInterval(function()
{
var gyroVal = myGyro.value();
var outputStr = "Raw value: " + gyroVal + ", " +
"angular velocity: " +
roundNum(myGyro.angularVelocity(gyroVal), 5) + " deg/s";
console.log(outputStr);
myGyro.update();
var outputStr = "Angular velocity: " +
roundNum(myGyro.angularVelocity(), 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))) /
var extraNum = (1 / (Math.pow(10, decimalPlaces) * 1000));
return (Math.round((num + extraNum) * (Math.pow(10, decimalPlaces))) /
Math.pow(10, decimalPlaces));
}
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
console.log("Exiting...");
process.exit(0);
});