simple QEI library. no return speed, only return angle.

Dependents:   WRS_mechanamu_test

Committer:
sgrsn
Date:
Mon Mar 02 06:23:11 2020 +0000
Revision:
2:62821df48957
Parent:
0:bffc97496048
Add getSpeed()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sgrsn 0:bffc97496048 1 #ifndef QEI_H
sgrsn 0:bffc97496048 2 #define QEI_H
sgrsn 0:bffc97496048 3
sgrsn 0:bffc97496048 4 #include "mbed.h"
sgrsn 0:bffc97496048 5
sgrsn 0:bffc97496048 6 class QEI {
sgrsn 0:bffc97496048 7
sgrsn 0:bffc97496048 8 public:
sgrsn 0:bffc97496048 9
sgrsn 0:bffc97496048 10 QEI(PinName A, PinName B, int ppr);
sgrsn 2:62821df48957 11 QEI(PinName A, PinName B, PinName Z, int ppr);
sgrsn 2:62821df48957 12 QEI(PinName A, PinName B, int ppr, Timer *timer);
sgrsn 2:62821df48957 13 QEI(PinName A, PinName B, PinName Z, int ppr, Timer *timer);
sgrsn 0:bffc97496048 14
sgrsn 2:62821df48957 15 float getDegree();
sgrsn 2:62821df48957 16 float getSpeed();
sgrsn 2:62821df48957 17 bool IsInterruptZ();
sgrsn 0:bffc97496048 18
sgrsn 0:bffc97496048 19 private:
sgrsn 0:bffc97496048 20
sgrsn 2:62821df48957 21 void init();
sgrsn 0:bffc97496048 22 void encode(void);
sgrsn 2:62821df48957 23 void encodeZ();
sgrsn 2:62821df48957 24
sgrsn 0:bffc97496048 25 InterruptIn channelA;
sgrsn 0:bffc97496048 26 InterruptIn channelB;
sgrsn 2:62821df48957 27 InterruptIn channelZ;
sgrsn 2:62821df48957 28 Timer *_timer;
sgrsn 2:62821df48957 29
sgrsn 0:bffc97496048 30 float angle;
sgrsn 0:bffc97496048 31 int currState;
sgrsn 0:bffc97496048 32 int prevState;
sgrsn 0:bffc97496048 33 int position;
sgrsn 0:bffc97496048 34 float _ppr;
sgrsn 2:62821df48957 35
sgrsn 2:62821df48957 36 bool _IsInterrupt;
sgrsn 0:bffc97496048 37 };
sgrsn 0:bffc97496048 38
sgrsn 0:bffc97496048 39 #endif