driver for incremental encoder

Revision:
6:2fdce74d2a7b
Parent:
5:1a5772466668
--- a/decoder.cpp	Thu Mar 14 16:05:28 2019 +0000
+++ b/decoder.cpp	Thu Mar 28 16:28:55 2019 +0000
@@ -16,7 +16,10 @@
     _channelA.rise(this, &decoder::isr);   
    
     _count = 0;
-    _direction = 0;   
+    _direction = 0;  
+    
+    _lowerLimit = 0;
+    _upperLimit = 1; // set as default function must be called to change these values 
     
 }
 
@@ -42,7 +45,7 @@
         
         if(chB == 1){
         
-           if( _count != UPPER_LIMIT){
+           if( _count != _upperLimit){
               _count++;               
             }
             _direction = 1;
@@ -55,7 +58,7 @@
         
         if(chB == 0){
             
-            if(_count != LOWER_LIMIT){
+            if(_count != _lowerLimit){
               _count--;  
             }
             _direction = 0;
@@ -102,6 +105,25 @@
 }
 
 /**
+* @brief    setLimits()
+* @details  sets the limits of the encoder counting
+* @param    lower limit and upper limit
+* @return   
+* @warning  set to 0 and 1 by default by constructor user must change as required
+* 
+*/
+
+
+
+void decoder :: setLimits(int8_t lower, int8_t upper){
+    
+    _lowerLimit = lower;
+    _upperLimit = upper;
+    
+    
+}
+
+/**
 * @brief    reset()
 * @details  function to reset all internal counting and directional variables
 * @param    NA