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.h@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 | #ifndef LOWPASSFILTER_H |
| rvt | 0:33bc88c4ab31 | 2 | #define LOWPASSFILTER_H |
| rvt | 0:33bc88c4ab31 | 3 | #include "mbed.h" |
| rvt | 0:33bc88c4ab31 | 4 | #include "AnalogFilterInterface.h" |
| rvt | 0:33bc88c4ab31 | 5 | |
| rvt | 1:5b2ab44eb31f | 6 | /** |
| rvt | 1:5b2ab44eb31f | 7 | * A simple First Order Low Pass filter for analog input's |
| rvt | 1:5b2ab44eb31f | 8 | * This is a IIR filter based on http://en.wikipedia.org/wiki/Iir_filter |
| rvt | 1:5b2ab44eb31f | 9 | */ |
| rvt | 0:33bc88c4ab31 | 10 | class LowPassFilter : public AnalogFilterInterface { |
| rvt | 0:33bc88c4ab31 | 11 | private: |
| rvt | 0:33bc88c4ab31 | 12 | double _alpha; |
| rvt | 0:33bc88c4ab31 | 13 | double smoothedValue; |
| rvt | 0:33bc88c4ab31 | 14 | public: |
| rvt | 1:5b2ab44eb31f | 15 | /* |
| rvt | 1:5b2ab44eb31f | 16 | chain : a interface to AnalogFilterInterface in case you want to chain several filters |
| rvt | 1:5b2ab44eb31f | 17 | alpha : Filter coefficient. The lower the value of alpha, the less filtering is done |
| rvt | 1:5b2ab44eb31f | 18 | */ |
| rvt | 0:33bc88c4ab31 | 19 | LowPassFilter(AnalogFilterInterface *chain, double alpha); |
| rvt | 0:33bc88c4ab31 | 20 | ~LowPassFilter(); |
| rvt | 0:33bc88c4ab31 | 21 | virtual void setData(long data); |
| rvt | 5:a0bb17c379ce | 22 | virtual long getData() const; |
| rvt | 0:33bc88c4ab31 | 23 | }; |
| rvt | 0:33bc88c4ab31 | 24 | |
| rvt | 0:33bc88c4ab31 | 25 | #endif |
