mini glider FSG

Fork of QEI by Aaron Berk

Files at this revision

API Documentation at this revision

Comitter:
CodyMarquardt
Date:
Mon Aug 13 18:49:19 2018 +0000
Parent:
0:5c2ad81551aa
Commit message:
also mini glider

Changed in this revision

QEI.cpp Show annotated file Show diff for this revision Revisions of this file
QEI.h Show annotated file Show diff for this revision Revisions of this file
--- a/QEI.cpp	Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.cpp	Mon Aug 13 18:49:19 2018 +0000
@@ -127,6 +127,8 @@
  * Includes
  */
 #include "QEI.h"
+#include "PololuHBridge.hpp"
+#include "mbed.h"
 
 QEI::QEI(PinName channelA,
          PinName channelB,
@@ -170,16 +172,27 @@
 
     pulses_      = 0;
     revolutions_ = 0;
+}
 
+void QEI::check(float BE_array[], float _BE_mm){
+    BE_array[4] = BE_array[3];
+    BE_array[3] = BE_array[2];
+    BE_array[2] = BE_array[1];
+    BE_array[1] = BE_array[0];
+    BE_array[0] = _BE_mm;
+    if (BE_array[4] - BE_array[0] == 0){
+        BE_array[0] = 999;
+    }
 }
 
+
 int QEI::getCurrentState(void) {
 
     return currState_;
 
 }
 
-int QEI::getPulses(void) {
+float QEI::getPulses(void) {
 
     return pulses_;
 
@@ -250,14 +263,14 @@
         if ((prevState_ == 0x3 && currState_ == 0x0) ||
                 (prevState_ == 0x0 && currState_ == 0x3)) {
 
-            pulses_++;
+            pulses_--;
 
         }
         //10->01->10->01 is clockwise rotation or "backward".
         else if ((prevState_ == 0x2 && currState_ == 0x1) ||
                  (prevState_ == 0x1 && currState_ == 0x2)) {
 
-            pulses_--;
+            pulses_++;
 
         }
 
--- a/QEI.h	Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.h	Mon Aug 13 18:49:19 2018 +0000
@@ -199,7 +199,7 @@
      *
      * @return Number of pulses which have occured.
      */
-    int getPulses(void);
+    float getPulses(void);
 
     /**
      * Read the number of revolutions recorded by the encoder on the index channel.
@@ -207,6 +207,9 @@
      * @return Number of revolutions which have occured on the index channel.
      */
     int getRevolutions(void);
+    float BE_array;
+    char _input1;
+    void check(float BE_array[], float _BE_mm);
 
 private: