a

Dependents:   wheelchaircontrol wheelchaircontrol2 wheelchaircontrol3 wheelchaircontrol4 ... more

Revision:
1:f57640259245
Parent:
0:5c2ad81551aa
Child:
2:2a173fdae3ca
--- a/QEI.cpp	Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.cpp	Wed Jul 25 22:51:54 2018 +0000
@@ -185,11 +185,6 @@
 
 }
 
-int QEI::getRevolutions(void) {
-
-    return revolutions_;
-
-}
 
 // +-------------+
 // | X2 Encoding |
@@ -275,13 +270,23 @@
 
             pulses_ -= change;
         }
-
     }
-
     prevState_ = currState_;
 
 }
 
+float QEI::getRevolutions(){
+    if (encoding_ == X2_ENCODING)
+        return (float) ((float)pulses_ /(pulsesPerRev_));
+    else
+        return (float) (pulses_ / 4 * pulsesPerRev_);
+}
+
+float QEI::getDistance(float radius)
+{
+    return getRevolutions()*radius*3.1415926*2;
+}
+
 void QEI::index(void) {
 
     revolutions_++;