Hello!
I see that I posted some unexplained code 
I'll try to explain:
The first thing we need to clear out of the way is the use of the name sample.
This is just an alias selected by me, bacuase the AverageList library need to operate on the same kind of variable, so instead of writing int or byte (or something else) I created a type definition with the keyword typedef.
This makes for a more maintainable code. If, for instance, you where to change the datatype from say bytes to ints, you would only need to change the typedef line, as opposed to changing every instance of byte or int in your code.
I absolutely see now that I should've explained this, but I forgot it.
In the meantime, I read the sketch and found some sentences I haven´t seen before. Want to be sure I understand them.
For instance, you wrote:
AverageList list = AverageList( storage, MAX_NUMBER_OF_READINGS );
What is the meaning of "" ?
This wierd thing tells the compiler what kind of data you are going to be averaging.
If you see the line: typedef float sample; //change float to the datatype you want to use
You might guess that saple is exactly the same as float.
And of the complete sentence?
My intuition tells me that you mean "AverageList" is a subset of "list", which is stored in storage [ ] ? Wrong?
Imagine this simple code:
int var = 5;
Here you say: create an integer called var and set it to 5.
The same sentance applies to the much more strangelooking:
AverageList<sample> list = AverageList<sample>( storage, MAX_NUMBER_OF_READINGS );
Here you can say: create an AverageList called list and set it to an AverageList that uses the storage array as storage, and has the size equal to MAX_NUMBER_OF_READINGS, which is 10.
The storage is just an array that allocates some memory that AverageList will use to store data.
Another sample of my ignorance: you wrote:
sizeof(sample)==1 ? Serial.println(list.getAverage(),DEC) : Serial.println(list.getAverage());
First of all "sizeof(sample)==1 ?" please explain this. Is it "?" part of the command or a typo mistake?
The ? is called the ternary operator, and is just a way of writing an if-else using as little typing time as possible.
condition ? code1 : code2;
Translates to: is condition true ? if yes execute code1 else execute code2
This: sizeof(sample)==1 ? Serial.println(list.getAverage(),DEC) : Serial.println(list.getAverage());
is exactly the same as:
if (sizeof(sample)==1){
Serial.println(list.getAverage(),DEC);
} else {
Serial.println(list.getAverage());
}
Furthermore, in the command:
Serial.println(list.getAverage())
First you tell the AverageList called list to calculate the average of the values currently logged, then you tell the Serial object to print them to the serial bus.
Please don´t send me the sketch for the 7 simultaneous sampling, as I wouldn´t understand it. Instead, I would thank you if you help me familiarise with one variable sampling, to find a way of programming the 7 sampling in the fastest way possible. Hopefully, make a funtion in my program that call some of your sample routine commands.
I changed the example to something simpler, let me know if something is unclear
:
#include <AverageList.h>
const byte MAX_NUMBER_OF_READINGS = 10;
float storage[MAX_NUMBER_OF_READINGS] = {0};
AverageList list = AverageList( storage, MAX_NUMBER_OF_READINGS );
void setup() {
Serial.begin(9600);
}
void loop() {
// ============ generates random numbers for testing ======
float rand = random(1,100)/1.5;
list.addValue( rand );
list.debug("list",Serial); //print contents to serial console
Serial.print("average: ");
Serial.println(list.getAverage());
delay(500);
}