Basic library to interface a 2 channel quadrature encoder with mBed
QuadratureEncoder.h
- Committer:
- el15lm
- Date:
- 2017-07-24
- Revision:
- 2:fcb3790af96b
- Parent:
- 1:42d1e211e624
File content as of revision 2:fcb3790af96b:
/** * @file QuadratureEncodere.h * @brief this library allows the MCU to intepret the signal coming from a quadrature encoder. * @author Lupo Manes * @date 24/07/2017 */ #ifndef _QUADRATUREENCODER_H_ #define _QUADRATUREENCODER_H_ #include "mbed.h" /** QuadrtureEncoder class. * Used to interface with quadrature encoder. */ class QuadratureEncoder { public: /** Create QuadratureEncode instance * @param pinA Pin to which is connected channel A of the encoder * @param pinB Pin to which is connected channel Bof the encoder */ QuadratureEncoder(PinName pinA, PinName pinB); /** Return the total number of pulses sent by the encoder. */ int getTicks(); /** Set the total number of ticks back to 0. */ void reset(); private: void _Bfalling(); void _Brising(); InterruptIn _channelB; DigitalIn _channelA; int _ticks; }; #endif