driver for incremental encoder

decoder.h

Committer:
ianaherne
Date:
2019-01-09
Revision:
2:b82d31306c4b
Parent:
1:017efde7ab29
Child:
3:4a03a73d7554

File content as of revision 2:b82d31306c4b:

#ifndef DECODER_H
#define DECODER_H
#include "mbed.h"




class decoder{
    
    public:
    
    
        /* These values control the upper and lower limits the the count will go to change limits to suit application*/
        typedef enum{
            
            
            LOWER_LIMIT = 0,
            UPPER_LIMIT = 15
            
            
        }limits_t;
    
        decoder(PinName channelA,PinName channelB);
        
        void isr();
        
        int8_t getDirection();
        int16_t getCount();
        void reset();
         
    
    
    private:
    
        InterruptIn _channelA; // interrupt only required on one channel
        DigitalIn _channelB;   // channelB is only required for comparison to determine direction
        
        
        int8_t _direction;
        int16_t _count;
        int16_t _oldCount;   
    
    
};

#endif