Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
SimpleFilter/SimpleFilter.cpp@25:bb5356402687, 2018-11-30 (annotated)
- Committer:
- shimniok
- Date:
- Fri Nov 30 16:11:53 2018 +0000
- Revision:
- 25:bb5356402687
- Parent:
- 0:a6a169de725f
Initial publish of revised version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | #include "SimpleFilter.h" |
shimniok | 0:a6a169de725f | 2 | |
shimniok | 0:a6a169de725f | 3 | SimpleFilter::SimpleFilter(short shift): _filter_value(0), _shift(shift) { |
shimniok | 0:a6a169de725f | 4 | // nothing to do here, really |
shimniok | 0:a6a169de725f | 5 | } |
shimniok | 0:a6a169de725f | 6 | |
shimniok | 0:a6a169de725f | 7 | short SimpleFilter::filter(short value) { |
shimniok | 0:a6a169de725f | 8 | |
shimniok | 0:a6a169de725f | 9 | _filter_value += (value - (_filter_value >> _shift)); |
shimniok | 0:a6a169de725f | 10 | |
shimniok | 0:a6a169de725f | 11 | return _filter_value >> _shift; |
shimniok | 0:a6a169de725f | 12 | } |
shimniok | 0:a6a169de725f | 13 | |
shimniok | 0:a6a169de725f | 14 | short SimpleFilter::value(void) { |
shimniok | 0:a6a169de725f | 15 | return _filter_value >> _shift; |
shimniok | 0:a6a169de725f | 16 | } |