driver for incremental encoder

decoder.h

Committer:
ianaherne
Date:
2019-03-14
Revision:
5:1a5772466668
Parent:
4:9913990cfd78
Child:
6:2fdce74d2a7b

File content as of revision 5:1a5772466668:

#ifndef DECODER_H
#define DECODER_H
#include "mbed.h"
extern Serial pc;



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 = 19
            
            
        }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;
        
    
    
};

#endif