Ries Twisk / Mbed 2 deprecated JoyStick

Dependencies:   USBDevice mbed-rtos mbed

Fork of JoyStick by Ries Twisk

Committer:
rvt
Date:
Fri Aug 30 01:37:49 2013 +0000
Revision:
2:ae7a31a3c618
Better PushButton handling

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rvt 2:ae7a31a3c618 1 #ifndef SIMPLEBUTTONDECODER_H
rvt 2:ae7a31a3c618 2 #define SIMPLEBUTTONDECODER_H
rvt 2:ae7a31a3c618 3
rvt 2:ae7a31a3c618 4 #include "mbed.h"
rvt 2:ae7a31a3c618 5 #include "AnalogInFiltered.h"
rvt 2:ae7a31a3c618 6
rvt 2:ae7a31a3c618 7 /**
rvt 2:ae7a31a3c618 8 ButtonDecoder.
rvt 2:ae7a31a3c618 9 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)
rvt 2:ae7a31a3c618 10 so I bought some 5% resitors but they didn'0t work well enough. So this decoder sinply decoder the end value and this
rvt 2:ae7a31a3c618 11 it means only one button at a timn can be detected reliable.
rvt 2:ae7a31a3c618 12 */
rvt 2:ae7a31a3c618 13 class SimpleButtonDecoder {
rvt 2:ae7a31a3c618 14 private:
rvt 2:ae7a31a3c618 15 AnalogInFiltered *_analogIn;
rvt 2:ae7a31a3c618 16 int _value;
rvt 2:ae7a31a3c618 17 int _fuzzyFactor;
rvt 2:ae7a31a3c618 18 bool _isChanged;
rvt 2:ae7a31a3c618 19 short _deBounceRuns;
rvt 2:ae7a31a3c618 20 short _debounceCount;
rvt 2:ae7a31a3c618 21
rvt 2:ae7a31a3c618 22 bool _pulseUp;
rvt 2:ae7a31a3c618 23 bool _pulseDown;
rvt 2:ae7a31a3c618 24 bool _status;
rvt 2:ae7a31a3c618 25 public:
rvt 2:ae7a31a3c618 26 /**
rvt 2:ae7a31a3c618 27 filter : Failter chain
rvt 2:ae7a31a3c618 28 pin : Analog input to read
rvt 2:ae7a31a3c618 29 */
rvt 2:ae7a31a3c618 30 SimpleButtonDecoder(AnalogInFiltered *_analogIn, int value, short deBounceRuns);
rvt 2:ae7a31a3c618 31 ~SimpleButtonDecoder();
rvt 2:ae7a31a3c618 32
rvt 2:ae7a31a3c618 33 // Process the buttons status information
rvt 2:ae7a31a3c618 34 // Call this function for the button to updates it's state
rvt 2:ae7a31a3c618 35 void process();
rvt 2:ae7a31a3c618 36
rvt 2:ae7a31a3c618 37 // Returns the current button status
rvt 2:ae7a31a3c618 38 // This state will be updated after each 'process' call
rvt 2:ae7a31a3c618 39 bool getStatus();
rvt 2:ae7a31a3c618 40
rvt 2:ae7a31a3c618 41 // Test if the input value is changed based on a offset
rvt 2:ae7a31a3c618 42 // This state will be updated after each 'process' call
rvt 2:ae7a31a3c618 43 bool getIsChanged();
rvt 2:ae7a31a3c618 44
rvt 2:ae7a31a3c618 45 // Return's TRUE if the button was pressed
rvt 2:ae7a31a3c618 46 // This state will be updated after each 'process' call
rvt 2:ae7a31a3c618 47 bool getIsPressed();
rvt 2:ae7a31a3c618 48
rvt 2:ae7a31a3c618 49 // Returns TRUE if the button was just released,
rvt 2:ae7a31a3c618 50 // This state will be updated after each 'process' call
rvt 2:ae7a31a3c618 51 bool getIsReleased();
rvt 2:ae7a31a3c618 52
rvt 2:ae7a31a3c618 53 };
rvt 2:ae7a31a3c618 54
rvt 2:ae7a31a3c618 55 #endif