AverageList Library for Arduino
Author:  Alexander Brevig
Contact: alexanderbrevig@gmail.com

Under Construction


Navigation


Current version

 1.2 2009-07-04: Added remove() and print()

History

 1.2 2009-07-04: Added remove() and print()
1.1 2009-05-21: Added getMax and getMin, @request retrolefty
1.0 2009-05-21: Initial Release

Description

AverageList is a library for the Arduino.

It is created to help simplify averaging values.


Download, install and import

Download here: Attach:AverageList.zip

Put the Button folder in "hardware\libraries\".
In the Arduino IDE, create a new sketch (or open one) and select from the menubar "Sketch->Import Library->AverageList".
Once the library is imported, an '#include <AverageList.h>' line will appear at the top of your sketch.


Creation

AverageList<datatype> variableName = AverageList<datatype>( storage , size );


Functions

//under construction, see .h file

void addValue

datatype getMax

datatype getMin

datatype getAverage

datatype getTotalAverage

void reset

void debug


Example

  1. #include <AverageList.h>
  2.  
  3. typedef float sample; //change float to the datatype you want to use
  4. const byte MAX_NUMBER_OF_READINGS = 10;
  5. sample storage[MAX_NUMBER_OF_READINGS] = {0};
  6.  
  7. AverageList<sample> list = AverageList<sample>( storage, MAX_NUMBER_OF_READINGS );
  8.  
  9. void setup() {
  10.   Serial.begin(9600);
  11. }
  12.  
  13. void loop() {  
  14.   sample rand = random(1,100)/1.5;
  15.   list.addValue( rand );
  16.  
  17.   list.debug("list",Serial); //print contents to serial console
  18.  
  19.   Serial.print("average: ");
  20.   sizeof(sample)==1 ? Serial.println(list.getAverage(),DEC) : Serial.println(list.getAverage()); //print bytes and chars as ints
  21.  
  22.   delay(500);
  23. }


FAQ

//contact me


Information about this page

Part of AlphaBeta Libraries.
Last Modified: October 04, 2012, at 03:49 PM
By: BartLamboo

Share