mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
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:
@ -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);
|
||||
});
|
||||
|
Reference in New Issue
Block a user