temp

Button.hpp

Committer:
BenRJG
Date:
2018-12-06
Revision:
0:2a4af0cb6e8d

File content as of revision 0:2a4af0cb6e8d:

#include "mbed.h"
#include "General.hpp"

// Class BUTTON polls a button for detection of edge
class BUTTON {
    public:
        BUTTON(PinName pin) : IN(pin){state = FALLEN;}
        BYTE poll(void);
				BYTE rise(void);
				//BYTE fall(void);
    private:
        enum State {FALLEN, RISING, RISEN, FALLING};
        State state;
        DigitalIn IN;
        INT_16 OUTPUT; //Output is 1 if button is rising and 2 if button is falling
        Timer timer;
};