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

Dependents:   WRS_mechanamu_test

Revision:
0:bffc97496048
Child:
1:6fa863d09d45
Child:
2:62821df48957
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.h	Mon Aug 20 04:54:24 2018 +0000
@@ -0,0 +1,35 @@
+#ifndef QEI_H
+#define QEI_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 QEI {
+
+public:
+    
+    QEI(PinName A, PinName B, int ppr);
+    
+    float getAngle();
+
+private:
+
+    void encode(void);
+
+    InterruptIn channelA;
+    InterruptIn channelB;
+    float angle;
+    int currState;
+    int prevState;
+    int position;
+    float _ppr;
+};
+
+#endif