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 SimpleButtonDecoder.h Source File

SimpleButtonDecoder.h

00001 #ifndef SIMPLEBUTTONDECODER_H
00002 #define SIMPLEBUTTONDECODER_H
00003 
00004 #include "mbed.h"
00005 #include "AnalogInFiltered.h"
00006 
00007 /**
00008 ButtonDecoder.
00009 I was planning to make a r2R ladder network but I couldn't find any very accurate resitors here in Ecuador (no Señor, no tengo ... sigh)
00010 so I bought some 5% resitors but they didn'0t work well enough. So this decoder sinply decoder the end value and this
00011 it means only one button at a timn can be detected reliable.
00012 */
00013 class SimpleButtonDecoder {
00014     private:
00015         AnalogInFiltered   *_analogIn;
00016         int _value;
00017         int _fuzzyFactor;
00018         bool _isChanged;
00019         short _deBounceRuns;
00020         short _debounceCount;
00021         
00022         bool _pulseUp;
00023         bool _pulseDown;
00024         bool _status;
00025     public:   
00026         /**
00027         filter : Failter chain
00028         pin : Analog input to read
00029         */
00030         SimpleButtonDecoder(AnalogInFiltered *_analogIn, int value, short deBounceRuns);
00031         ~SimpleButtonDecoder();
00032         
00033         // Process the buttons status information
00034         // Call this function for the button to updates it's state
00035         void process();
00036         
00037         // Returns the current button status
00038         // This state will be updated after each 'process' call
00039         bool getStatus();
00040         
00041         // Test if the input value is changed based on a offset
00042         // This state will be updated after each 'process' call
00043         bool getIsChanged();
00044         
00045         // Return's TRUE if the button was pressed
00046         // This state will be updated after each 'process' call
00047         bool getIsPressed();
00048         
00049         // Returns TRUE if the button was just released, 
00050         // This state will be updated after each 'process' call
00051         bool getIsReleased();
00052 
00053 };
00054 
00055 #endif