int smoothValue(...){
...
return workingTotal;
return workingIndex;
return average;
}
newTotal, newReadIndex, newAverage = smoothValue(...);
Is this some new C syntax that I have missed out on? A function declared as int can only return one integer, not three. workingTotal gets assigned to newAverage and the others are basically ignored by the compiler.
Look up pass-by-reference. The function can accept references to those variables and modify them in-place.
A better way to do it is to use a class. That way the internal storage can be kept in the object instead of passed into the function every time you use the function. You can get fancy with a .begin() method to start the array with zeroes and make up your own names for the actions of putting a new value into the average or getting the result back out.