Bayley Wang
/
foc-ed_in_the_bot_compact
robot
Embed:
(wiki syntax)
Show/hide line numbers
Filter.cpp
00001 #include "mbed.h" 00002 #include "math.h" 00003 #include "Filter.h" 00004 00005 MedianFilter::MedianFilter(int length) { 00006 buf = new fCircularBuffer(length, true); 00007 } 00008 00009 float MedianFilter::update(float x) { 00010 buf->add(x); 00011 return buf->median(); 00012 } 00013 00014 MovingAverageFilter::MovingAverageFilter(int length) { 00015 buf = new fCircularBuffer(length, false); 00016 } 00017 00018 float MovingAverageFilter::update(float x) { 00019 buf->add(x); 00020 return buf->mean(); 00021 }
Generated on Tue Jul 12 2022 17:58:39 by 1.7.2