Ries Twisk / Mbed 2 deprecated JoyStick

Dependencies:   USBDevice mbed-rtos mbed

Fork of JoyStick by Ries Twisk

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AutoScale.h Source File

AutoScale.h

00001 #ifndef AUTOSCALE_H
00002 #define AUTOSCALE_H
00003 
00004 #include "mbed.h"
00005 #include "AnalogFilterInterface.h"
00006 
00007 /**
00008 Auto scale a analog input to it's desired min/max values
00009 This is handy of you connect a potentiometer to a analog input where you cannot make the full values, but
00010 your flight simulator expects full values
00011 **/
00012 class AutoScale : public AnalogFilterInterface
00013 {
00014 private:
00015     const long _expectedMax;
00016     const long _expectedMin;
00017     long _currentMax;
00018     long _currentMin;
00019     long _current;
00020     double _a;
00021     double _b;
00022     double _mul;
00023 public:
00024     AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax);
00025     AutoScale(AnalogFilterInterface *chain,long expectedMin, long expectedMax, double multiplier);
00026     ~AutoScale();
00027 
00028     virtual void setData(long data);
00029     virtual long getData() const;
00030 private:
00031     void reCalc();
00032 };
00033 
00034 #endif