JavaScript utilities for firmata/nodejs.
First call will determine the number of elements to average.
Subsequent calls will return the average of all of the non-null elements.
const mAvg = require('./js-utils/movingAverage.js'); // Include the script in your nodejs code
var tempAverageC = mAvg.Avg(60); // Return a function to Average over 60 elements
var avgC = tempAverageC(20.1); // Return the current average when you pass in the
// next value to average
console.log('Temp Average: ' + avgC.toFixed(1) + '\xB0C');
Temp Average: 20.1°C
Return a random number between min and max
const random = require('./js-utils/getRandom.js'); // Include the script in your nodejs code
console.log('Random number: ' + random.getRandom(1, 10)); // Show a random number between
// 1 and 10 (inclusive)
Random number: 3