GY-63_MS5611/libraries/RunningMedian/examples/RunningMedian2/RunningMedian2.ino

83 lines
1.5 KiB
Arduino
Raw Normal View History

//
// FILE: RunningMedian2.ino
// AUTHOR: Rob Tillaart ( kudos to Sembazuru)
2020-11-27 05:33:55 -05:00
// PURPOSE: demo most functions
// DATE: 2013-10-17
2020-11-27 05:33:55 -05:00
// URL: https://github.com/RobTillaart/RunningMedian
2021-12-28 04:25:17 -05:00
#include "RunningMedian.h"
RunningMedian samples = RunningMedian(100);
long count = 0;
2021-12-28 04:25:17 -05:00
void setup()
{
Serial.begin(115200);
Serial.print(F("Running Median Version: "));
Serial.println(RUNNING_MEDIAN_VERSION);
}
2021-12-28 04:25:17 -05:00
void loop()
{
test1();
}
2021-12-28 04:25:17 -05:00
void test1()
{
2021-12-28 04:25:17 -05:00
if (count % 20 == 0)
2020-11-27 05:33:55 -05:00
{
Serial.println(F("\nmsec \tAnR \tSize \tCnt \tLow \tAvg \tAvg(7) \tAvg(3) \tMed \tHigh \tPre(1) \tPre(2)"));
}
count++;
long x = analogRead(A0);
samples.add(x);
float l = samples.getLowest();
float m = samples.getMedian();
float a = samples.getAverage();
float a7 = samples.getAverage(7);
float a3 = samples.getAverage(3);
float h = samples.getHighest();
int s = samples.getSize();
int c = samples.getCount();
float p1 = samples.predict(1);
float p2 = samples.predict(2);
Serial.print(millis());
Serial.print('\t');
Serial.print(x);
Serial.print('\t');
Serial.print(s);
Serial.print('\t');
Serial.print(c);
Serial.print('\t');
Serial.print(l);
Serial.print('\t');
Serial.print(a, 2);
Serial.print('\t');
Serial.print(a7, 2);
Serial.print('\t');
Serial.print(a3, 2);
Serial.print('\t');
Serial.print(m);
Serial.print('\t');
Serial.print(h);
Serial.print('\t');
Serial.print(p1, 2);
Serial.print('\t');
Serial.println(p2, 2);
delay(100);
}
2021-12-28 04:25:17 -05:00
// -- END OF FILE --