Reiko Randoja
/
ut_bbr_2018
Firmware for UT Robotex 2018 basketball robot
Diff: QED/qed.h
- Revision:
- 0:ef6268629f0b
diff -r 000000000000 -r ef6268629f0b QED/qed.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QED/qed.h Fri Sep 28 10:46:57 2018 +0000 @@ -0,0 +1,28 @@ +#ifndef QED_H +#define QED_H + +#include "mbed.h" + +#define PREV_MASK 0x1 //Mask for the previous state in determining direction of rotation. +#define CURR_MASK 0x2 //Mask for the current state in determining direction of rotation. +#define INVALID 0x3 //XORing two states where both bits have changed. + +class QED { +public: + QED(PinName channelA, PinName channelB); + + int read(); + +private: + void decode(); + + InterruptIn interruptA; + InterruptIn interruptB; + + volatile int pulses; + + int prevState; + int currState; +}; + +#endif \ No newline at end of file