Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBDevice mbed-rtos mbed
Fork of JoyStick by
LowPassFilter.cpp@5:a0bb17c379ce, 2016-06-22 (annotated)
- Committer:
- rvt
- Date:
- Wed Jun 22 12:50:16 2016 +0000
- Revision:
- 5:a0bb17c379ce
- Parent:
- 1:5b2ab44eb31f
Latest
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rvt | 0:33bc88c4ab31 | 1 | #include "LowPassFilter.h" |
| rvt | 0:33bc88c4ab31 | 2 | |
| rvt | 0:33bc88c4ab31 | 3 | LowPassFilter::LowPassFilter(AnalogFilterInterface *chain,double alpha) : AnalogFilterInterface(chain) { |
| rvt | 0:33bc88c4ab31 | 4 | _alpha = alpha; |
| rvt | 0:33bc88c4ab31 | 5 | smoothedValue = 0.0; |
| rvt | 0:33bc88c4ab31 | 6 | } |
| rvt | 0:33bc88c4ab31 | 7 | |
| rvt | 0:33bc88c4ab31 | 8 | LowPassFilter::~LowPassFilter() { |
| rvt | 0:33bc88c4ab31 | 9 | } |
| rvt | 0:33bc88c4ab31 | 10 | |
| rvt | 0:33bc88c4ab31 | 11 | |
| rvt | 0:33bc88c4ab31 | 12 | void LowPassFilter::setData(long dataPoint) { |
| rvt | 0:33bc88c4ab31 | 13 | getChain()->setData(dataPoint); |
| rvt | 1:5b2ab44eb31f | 14 | smoothedValue = (getChain()->getData() * (1.0 - _alpha)) + (smoothedValue * _alpha); |
| rvt | 0:33bc88c4ab31 | 15 | } |
| rvt | 0:33bc88c4ab31 | 16 | |
| rvt | 5:a0bb17c379ce | 17 | long LowPassFilter::getData() const { |
| rvt | 0:33bc88c4ab31 | 18 | return smoothedValue; |
| rvt | 0:33bc88c4ab31 | 19 | } |
| rvt | 0:33bc88c4ab31 | 20 |
