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
AutoScale.h@5:a0bb17c379ce, 2016-06-22 (annotated)
- Committer:
- rvt
- Date:
- Wed Jun 22 12:50:16 2016 +0000
- Revision:
- 5:a0bb17c379ce
Latest
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rvt | 5:a0bb17c379ce | 1 | #ifndef AUTOSCALE_H |
| rvt | 5:a0bb17c379ce | 2 | #define AUTOSCALE_H |
| rvt | 5:a0bb17c379ce | 3 | |
| rvt | 5:a0bb17c379ce | 4 | #include "mbed.h" |
| rvt | 5:a0bb17c379ce | 5 | #include "AnalogFilterInterface.h" |
| rvt | 5:a0bb17c379ce | 6 | |
| rvt | 5:a0bb17c379ce | 7 | /** |
| rvt | 5:a0bb17c379ce | 8 | Auto scale a analog input to it's desired min/max values |
| rvt | 5:a0bb17c379ce | 9 | This is handy of you connect a potentiometer to a analog input where you cannot make the full values, but |
| rvt | 5:a0bb17c379ce | 10 | your flight simulator expects full values |
| rvt | 5:a0bb17c379ce | 11 | **/ |
| rvt | 5:a0bb17c379ce | 12 | class AutoScale : public AnalogFilterInterface |
| rvt | 5:a0bb17c379ce | 13 | { |
| rvt | 5:a0bb17c379ce | 14 | private: |
| rvt | 5:a0bb17c379ce | 15 | const long _expectedMax; |
| rvt | 5:a0bb17c379ce | 16 | const long _expectedMin; |
| rvt | 5:a0bb17c379ce | 17 | long _currentMax; |
| rvt | 5:a0bb17c379ce | 18 | long _currentMin; |
| rvt | 5:a0bb17c379ce | 19 | long _current; |
| rvt | 5:a0bb17c379ce | 20 | double _a; |
| rvt | 5:a0bb17c379ce | 21 | double _b; |
| rvt | 5:a0bb17c379ce | 22 | double _mul; |
| rvt | 5:a0bb17c379ce | 23 | public: |
| rvt | 5:a0bb17c379ce | 24 | AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax); |
| rvt | 5:a0bb17c379ce | 25 | AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax, double multiplier); |
| rvt | 5:a0bb17c379ce | 26 | ~AutoScale(); |
| rvt | 5:a0bb17c379ce | 27 | |
| rvt | 5:a0bb17c379ce | 28 | virtual void setData(long data); |
| rvt | 5:a0bb17c379ce | 29 | virtual long getData() const; |
| rvt | 5:a0bb17c379ce | 30 | private: |
| rvt | 5:a0bb17c379ce | 31 | void reCalc(); |
| rvt | 5:a0bb17c379ce | 32 | }; |
| rvt | 5:a0bb17c379ce | 33 | |
| rvt | 5:a0bb17c379ce | 34 | #endif |
