New QEI library with position (angle) outputs

Fork of QEI_modified by Chun Feng Huang

Revision:
5:4682b3d415bd
Parent:
4:9699a757d4ed
--- a/QEI.h	Tue Oct 25 13:05:41 2016 +0000
+++ b/QEI.h	Thu Mar 30 07:53:34 2017 +0000
@@ -141,7 +141,7 @@
 public:
 
     volatile int pulses_;
-    
+
     int angularvelocity;
     int *countArray;
     uint8_t arrayPtr;
@@ -208,11 +208,16 @@
      * @return Number of revolutions which have occured on the index channel.
      */
     int getRevolutions(void);
-    
+
     void Calculate(void);
-    
+
+    // Get results
+    // Rotational speed
     double getAngularSpeed(void);
     double getAngularSpeed_deg_s(void);
+    // Angle
+    double getAngle(bool is_ranged); // rad, if is_ranged, return 0~2*PI
+    double getAngle_deg(bool is_ranged); // deg, if is_ranged, return 0~360
 
 private:
 
@@ -241,8 +246,14 @@
     int          pulsesPerRev_;
     int          prevState_;
     int          currState_;
+    
+    // Unit transformation
+    // Rotational speed
     double        count_2_rad_s;
     double        count_2_deg_s;
+    // Angle
+    double       count_2_rad;
+    double       count_2_deg;
 
 //    volatile int pulses_;
     volatile int revolutions_;