Skip to content

theChroma/StreamAverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arduino-library-badge PlatformIO Registry

StreamAverage

Single Header C++ / Arduino Stream-Average-Library

Disclaimer: This is not a moving average, instead it accumulates the average of the values you add

Installation

PlatformIO

Go to PlatformIO Home, click on Libraries and search for StreamAverage

Arduino Library Manager

Open the library manager by clicking on Tools > Manage Libraries and search for StreamAverage. Then click install.

From Github

In this Repository go to Releases. There choose the Version you like an download the library as .zip just the .h file.

Documentation

First create a StreamAverage object of your desired type by passing as template argument.

StreamAverage<float> average;

You can get values into the average by using the add() method

average.add(newValue);

or the shift operator

average << newValue;

Both methods return the new value of the average, including the newValue

float newAverage;
newAverage = average.add(2);
newAverage = average << 4;
// new Average now contains 3

You can get the current average using get()

float currentAverage = average.get();

or get it implicitly

float currentAverage = average;

You can get the maximum and minimum value the average holds, by calling getMax() and getMin()

average << 5.5;
average << 43.27;
average << -19.3;
average << 0.02;
float maximum = average.getMax(); // 43.27
float minimum = average.getMin(); // -19.3 

To find out how many values have been added to the average, use getNumValues()

size_t num = average.getNumValues();

After calling the reset() method, get(), getMax(), getMin(), getNumValues() will evalueate to 0

average.reset();

About

Library for averaging without having huge data Buffers consuming all your memory.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages