Ben Gordon
/
ELEC351_GroupA_alternate
temp
Diff: Button.hpp
- Revision:
- 0:2a4af0cb6e8d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Button.hpp Thu Dec 06 15:38:09 2018 +0000 @@ -0,0 +1,18 @@ +#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; +}; +