Quadrature encoder interface library with distance function

Dependents:   QEI_with_distance wheelchaircontrol wheelchaircontrolRos wheelchaircontrol ... more

Fork of QEI by Aaron Berk

Revision:
2:2a173fdae3ca
Parent:
1:f57640259245
Child:
3:0035b165ecc4
--- a/QEI.cpp	Wed Jul 25 22:51:54 2018 +0000
+++ b/QEI.cpp	Fri Aug 03 20:28:47 2018 +0000
@@ -277,14 +277,16 @@
 
 float QEI::getRevolutions(){
     if (encoding_ == X2_ENCODING)
-        return (float) ((float)pulses_ /(pulsesPerRev_));
+    {
+        return (float)pulses_ / pulsesPerRev_;
+    }
     else
-        return (float) (pulses_ / 4 * pulsesPerRev_);
+        return (float)pulses_ / (4 * pulsesPerRev_);
 }
 
-float QEI::getDistance(float radius)
+float QEI::getDistance(float diameter)
 {
-    return getRevolutions()*radius*3.1415926*2;
+    return getRevolutions()*diameter*3.1415926;
 }
 
 void QEI::index(void) {