New QEI library with position (angle) outputs

Fork of QEI_modified by Chun Feng Huang

Revision:
4:9699a757d4ed
Parent:
2:205d0280632a
Child:
5:4682b3d415bd
--- a/QEI.h	Tue May 03 08:04:08 2016 +0000
+++ b/QEI.h	Tue Oct 25 13:05:41 2016 +0000
@@ -123,26 +123,19 @@
  * of pulses per revolution.
  */
 
+//////////////////////////////
 #ifndef QEI_H
 #define QEI_H
 
-/**
- * Includes
- */
 #include "mbed.h"
 
-/**
- * Defines
- */
-#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.
 
-/**
- * Quadrature Encoder Interface.
- */
+#define PREV_MASK 0x1 // Mask for the previous state in determining direction of rotation. (0b01)
+#define CURR_MASK 0x2 // Mask for the current state in determining direction of rotation. (0b10)
+#define INVALID   0x3 // XORing two states where both bits have changed. (0b11)
+
+// QEI
+////////////////////////
 class QEI {
 
 public:
@@ -219,6 +212,7 @@
     void Calculate(void);
     
     double getAngularSpeed(void);
+    double getAngularSpeed_deg_s(void);
 
 private:
 
@@ -247,6 +241,8 @@
     int          pulsesPerRev_;
     int          prevState_;
     int          currState_;
+    double        count_2_rad_s;
+    double        count_2_deg_s;
 
 //    volatile int pulses_;
     volatile int revolutions_;