simple QEI library. no return speed, only return angle.
Dependents: WRS_mechanamu_test
Diff: QEI.h
- Revision:
- 1:6fa863d09d45
- Parent:
- 0:bffc97496048
--- a/QEI.h Mon Aug 20 04:54:24 2018 +0000 +++ b/QEI.h Wed Nov 14 02:18:58 2018 +0000 @@ -3,21 +3,16 @@ #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 QEI { public: - QEI(PinName A, PinName B, int ppr); + QEI(PinName A, PinName B, int ppr, Timer *t); float getAngle(); + float getSpeed(); + float getDisAngle(); + void reset(); private: @@ -25,11 +20,15 @@ InterruptIn channelA; InterruptIn channelB; + Timer *timer; + float angle; int currState; int prevState; int position; + int last_position; float _ppr; + float time; }; #endif