driver for incremental encoder

decoder.h

Committer:
ianaherne
Date:
2019-03-28
Revision:
6:2fdce74d2a7b
Parent:
5:1a5772466668

File content as of revision 6:2fdce74d2a7b:

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



class decoder{
    
    public:
    
       
    
        decoder(PinName channelA,PinName channelB);
        
        void isr();
        
        int8_t getDirection();
        int16_t getCount();
        void setLimits(int8_t lower, int8_t upper);
        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;
        int8_t _lowerLimit;
        int8_t _upperLimit;
        
        
    
    
};

#endif