simple QEI library. no return speed, only return angle.
Dependents: WRS_mechanamu_test
QEI.h
- Committer:
- sgrsn
- Date:
- 2020-03-02
- Revision:
- 2:62821df48957
- Parent:
- 0:bffc97496048
File content as of revision 2:62821df48957:
#ifndef QEI_H #define QEI_H #include "mbed.h" class QEI { public: QEI(PinName A, PinName B, int ppr); QEI(PinName A, PinName B, PinName Z, int ppr); QEI(PinName A, PinName B, int ppr, Timer *timer); QEI(PinName A, PinName B, PinName Z, int ppr, Timer *timer); float getDegree(); float getSpeed(); bool IsInterruptZ(); private: void init(); void encode(void); void encodeZ(); InterruptIn channelA; InterruptIn channelB; InterruptIn channelZ; Timer *_timer; float angle; int currState; int prevState; int position; float _ppr; bool _IsInterrupt; }; #endif