Control project for the Lift-arm. Works with ROS Melodic

Dependencies:   mbed Servo ros_lib_melodic ULN2003_StepperDriver Async_4pin_Stepper

Revision:
1:7c355adbc977
Parent:
0:441289ea4e29
Child:
3:4b6080e86761
--- a/src/encoder.cpp	Thu May 27 18:36:23 2021 +0000
+++ b/src/encoder.cpp	Thu May 27 18:53:26 2021 +0000
@@ -10,7 +10,6 @@
  * 
  */
  
-#include "QEI.h"
 #include "encoder.h"
  
  
@@ -21,49 +20,45 @@
     bool c,
     double p,
     double ec
-    ) : channelA_(channelA, PullUp),
-        channelB_(channelB, PullUp),
+    ) : channelA_(chanA, PullUp),
+        channelB_(chanB, PullUp),
         c_d(c),
         period(p),
         enc_const(ec) {
                         
     pulses_       = 0;
-    revolutions_  = 0;
     pulsesPerRev_ = CPR;
     tot_clicks    = 0;
     click_rate    = 0;
     temp_tot      = 0;
     
     //Workout what the current state is.
-    int chanA = channelA_.read();
-    int chanB = channelB_.read();
+    int channA = channelA_.read();
+    int channB = channelB_.read();
     
     //2-bit state.
-    currState_ = (chanA << 1) | (chanB);
+    currState_ = (channA << 1) | (channB);
     prevState_ = currState_;
     
     //X4 encoding uses interrupts on channel A,
     //and on channel B.
-    channelA_.rise(callback(this, &QEI::encode));
-    channelA_.fall(callback(this, &QEI::encode));
-    channelB_.rise(callback(this, &QEI::encode));
-    channelB_.fall(callback(this, &QEI::encode));
+    channelA_.rise(callback(this, &encoder::encode));
+    channelA_.fall(callback(this, &encoder::encode));
+    channelB_.rise(callback(this, &encoder::encode));
+    channelB_.fall(callback(this, &encoder::encode));
 }
 
-void encode::reset(void) {
-
+void encoder::reset(void) {
     pulses_      = 0;
-    revolutions_ = 0;
-
 }
 
-int encode::getCurrentState(void) {
+int encoder::getCurrentState(void) {
 
     return currState_;
 
 }
 
-int encode::getPulses(void) {
+int encoder::getPulses(void) {
 
     return pulses_;