Bayley Wang
/
foc-ed_in_the_bot_compact
robot
Filter/Filter.cpp@252:38644631ed97, 2018-11-13 (annotated)
- Committer:
- bwang
- Date:
- Tue Nov 13 17:46:23 2018 +0000
- Revision:
- 252:38644631ed97
- Parent:
- 224:90172915d0fb
11/13/2018 12:45 - hitting <return> on empty line prints "\r>", so that hitting enter after intially connecting to the controller generates a prompt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 144:a9e7fa1c98d7 | 1 | #include "mbed.h" |
bwang | 144:a9e7fa1c98d7 | 2 | #include "math.h" |
bwang | 146:296bcc30e65d | 3 | #include "Filter.h" |
bwang | 146:296bcc30e65d | 4 | |
bwang | 146:296bcc30e65d | 5 | MedianFilter::MedianFilter(int length) { |
bwang | 224:90172915d0fb | 6 | buf = new fCircularBuffer(length, true); |
bwang | 146:296bcc30e65d | 7 | } |
bwang | 146:296bcc30e65d | 8 | |
bwang | 146:296bcc30e65d | 9 | float MedianFilter::update(float x) { |
bwang | 146:296bcc30e65d | 10 | buf->add(x); |
bwang | 146:296bcc30e65d | 11 | return buf->median(); |
bwang | 146:296bcc30e65d | 12 | } |
bwang | 146:296bcc30e65d | 13 | |
bwang | 146:296bcc30e65d | 14 | MovingAverageFilter::MovingAverageFilter(int length) { |
bwang | 224:90172915d0fb | 15 | buf = new fCircularBuffer(length, false); |
bwang | 146:296bcc30e65d | 16 | } |
bwang | 146:296bcc30e65d | 17 | |
bwang | 146:296bcc30e65d | 18 | float MovingAverageFilter::update(float x) { |
bwang | 146:296bcc30e65d | 19 | buf->add(x); |
bwang | 146:296bcc30e65d | 20 | return buf->mean(); |
bwang | 146:296bcc30e65d | 21 | } |