Git Product home page Git Product logo

streamaverage's Introduction

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 cann 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();

streamaverage's People

Contributors

enovalab avatar njh avatar thechroma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.