GY-63_MS5611/libraries/RunningAverage/examples/ra_MinMaxTest/ra_MinMaxTest.ino
2021-12-28 10:13:44 +01:00

51 lines
882 B
C++

//
// FILE: runningAverageMinMaxTest.ino
// AUTHOR: Rob Tillaart
// DATE: 2015-apr-10
// PUPROSE: demo
#include "RunningAverage.h"
RunningAverage myRA(10);
int samples = 0;
void setup(void)
{
Serial.begin(115200);
Serial.println("\nDemo runningAverageMinMaxTest");
Serial.print("Version: ");
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
myRA.clear(); // explicitly start clean
Serial.println("\nCNT\tMIN\tAVG\tMAX");
}
void loop(void)
{
long rn = random(0, 1000);
myRA.addValue(rn * 0.001);
samples++;
Serial.print(samples);
Serial.print("\t");
Serial.print(myRA.getMin(), 3);
Serial.print("\t");
Serial.print(myRA.getAverage(), 3);
Serial.print("\t");
Serial.println(myRA.getMax(), 3);
if (samples == 100)
{
samples = 0;
myRA.clear();
Serial.println("\nCNT\tMIN\tAVG\tMAX");
}
delay(10);
}
// -- END OF FILE --