Closed RobTillaart closed 3 years ago
I agree. I would also like the possibility to limit the number of samples to do average on, while running. Like the way you can do on a Spectrum Analyzer. As an example, if I reserve 256 samples, I could choose to use only 64 of them. Ok if a change of that number clears all data.
@Teddyz
So you mean that initially you allocate 256 samples, but runtime you can adjust the part that is used, to increase performance (whatever reason) without reallocating memory.
RunningAverage myRA(256);
...
myRA.usePartial(64); // condition n <= size else use all
Q: What would be a good function name to indicate only a subset of the allocated MAXSIZE elements is used?
Q: Should it just use element [0...n-1] (my preference) , or should it use [start .. start+n-1]
Started develop branch
Thanks, you have understood my intention correctly.
What name to use is not easy for me to say. My favourite is setWindowSize(64)
but it is rather long and might lead someone to think it can be used to increase the allocated memory.
Use element from [0...n-1].
What shall happen when size is changed? Easy and predictable to clear all data. Or a fancy design that tries to save as much data as possible? I think clearing data is easier and will never go wrong.
@Teddyz No new example code tested yet, but no existing code seems broken - https://github.com/RobTillaart/RunningAverage/actions So if you have time to spare feel free to do some tests
What shall happen when size is changed?
Clears all, it is only impossible to go beyond the initial size given in the constructor.
added two basic examples
merged 0.4.0
Tested OK and is now used in my experiments. Thank you!
I also read the code and the implementation seems bulletproof to me.
Please include setPartial
and getPartial
in keywords.txt if you make a future release.
Good to hear it works well. Keywords will be updated asap
Thanks for testing
Updated keywords.txt in master branch, reordered them so they match the order in the runningAverage.h file
idea: a script that extracts keywords.txt from the .h file.
Some applications need to handle larger sets of values to define their running average. Investigate how to handle 16 bit's sizes.