GY-63_MS5611/libraries/RunningAverage/examples/fillValue/fillValue.ino

65 lines
1000 B
Arduino
Raw Normal View History

//
2020-11-27 05:33:55 -05:00
// FILE: fillValue.ino
// AUTHOR: Rob Tillaart
// DATE: 2012-12-30
2020-11-27 05:33:55 -05:00
// PUPROSE: demo + timing of fillValue
2021-11-24 04:03:41 -05:00
#include "RunningAverage.h"
RunningAverage myRA(10);
int samples = 0;
2020-11-27 05:33:55 -05:00
uint32_t start, stop;
void setup(void)
{
Serial.begin(115200);
Serial.print("Demo RunningAverage lib - fillValue ");
Serial.print("Version: ");
Serial.println(RUNNINGAVERAGE_LIB_VERSION);
2020-11-27 05:33:55 -05:00
delay(10);
for (int i = 0; i < 15; i++)
{
measure_duration(i);
}
Serial.println();
}
2021-11-24 04:03:41 -05:00
void loop(void)
{
long rn = random(0, 100);
2020-11-27 05:33:55 -05:00
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);
2020-11-27 05:33:55 -05:00
}
2021-11-24 04:03:41 -05:00
2020-11-27 05:33:55 -05:00
void measure_duration(int n)
{
start = micros();
myRA.fillValue(100, n);
stop = micros();
Serial.print("fillValue(100, ");
Serial.print(n);
Serial.print("): ");
Serial.println(stop - start);
delay(10);
}
2021-11-24 04:03:41 -05:00
2020-11-27 05:33:55 -05:00
// -- END OF FILE --
2021-11-24 04:03:41 -05:00