GY-63_MS5611/libraries/RunningAverage/examples/fillValue/fillValue.ino
rob tillaart 9cbe3bf5f9 + update version 0.2.04
+ added getElement() (not released 0.2.03 version)
+ added getSize()    (not released 0.2.03 version)
+ added getCount()   (not released 0.2.03 version)
+ updated keywords.txt
+ added memory protection if there is not enough memory to allocate.
+ added return NAN instead of 0  for getAverage()
+ reduced _size, _cnt, _idx to uint8_t
+ changed extensions of example code to .ino
2014-07-03 22:00:45 +02:00

38 lines
657 B
C++

//
// FILE: fillValue.pde
// AUTHOR: Rob Tillaart
// DATE: 2012-12-30
//
// PUPROSE: show working of fillValue
//
#include "RunningAverage.h"
RunningAverage myRA(10);
int samples = 0;
void setup(void)
{
Serial.begin(115200);
Serial.print("Demo RunningAverage lib - fillValue ");
Serial.print("Version: ");
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
myRA.fillValue(100,5);
}
void loop(void)
{
long rn = random(0, 100);
myRA.addValue(rn/100.0);
samples++;
Serial.print("Running Average: ");
Serial.println(myRA.getAverage(), 4);
if (samples == 300)
{
samples = 0;
myRA.fillValue(100, 10);
}
delay(100);
}