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

Dependents:   WRS_mechanamu_test

Revision:
2:62821df48957
Parent:
0:bffc97496048
--- a/QEI.h	Mon Aug 20 04:54:24 2018 +0000
+++ b/QEI.h	Mon Mar 02 06:23:11 2020 +0000
@@ -3,33 +3,37 @@
 
 #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, 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 getAngle();
+    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