Finally found some time to update the runningAverage lib on the playground: - http://playground.arduino.cc//Main/RunningAverage
1) There are some breaking changes in the method names to make them more descriptive;
// clr() => clear()
// add(x) => addValue(x)
// avg() => getAverage()
2) new is the fillValue() function, based upon the trimValue() of Yuval Naveh - see previous post
// fill the average with a value
// the param number determines how often value is added (weight)
// number should preferably be between 1 and size
void RunningAverage::fillValue(float value, int number)
for (int i = 0; i < number; i++)
It fills the internal array with a number of identical values to get a starting value for average.
By adding more than one value, the initial average gets a certain weight.
This extends the original trimValue() so that's why I gave another name.
3) some small refactoring and added comments
as always comments, remarks and ideas are welcome