Rotary Encoder handling library for mbed
Diff: REnc.h
- Revision:
- 4:916992052518
- Parent:
- 3:9dfe441065e9
- Child:
- 5:3e6931797218
diff -r 9dfe441065e9 -r 916992052518 REnc.h --- a/REnc.h Wed Aug 06 23:54:19 2014 +0000 +++ b/REnc.h Tue Aug 12 01:49:49 2014 +0000 @@ -3,6 +3,14 @@ #include "mbed.h" +/** + * @file REnc.h + * Project Rotary Encoder handling Library + * @brief Rotary Encoder handling library for mbed + * @version 1.0 + * @author Chuck Timber + * @date 12/08/2014 + */ /** class to handle a rotary encoder * The class use DigitalIn and Ticker * @@ -43,12 +51,17 @@ * @endcode */ +/** + * @define + * + */ #define RENC_SAMPLING_PERIOD 0.002 #define RENC_EXECUTION_DELAY 300 namespace mbed { enum { STOP, CLOCKWISE, COUNTERCLOCKWISE }; +// enum { STOP, CC, CCW }; /** class to handle a rotary encoder * The class uses DigitalIn and Ticker @@ -56,17 +69,32 @@ class REnc { public: - unsigned char CMD; - unsigned char STABLE; - void setHandleRight(void (*fptr)(void)); - void setHandleLeft(void (*fptr)(void)); + unsigned char CMD; /// @brief CMD represents the state of rotation + /** @brief CMD represents the state of rotation + * + * @retval STOP + * @retval CLOCKWISE + * @retval COUNTERCLOCKWISE + */ + unsigned char STABLE; /// @brief STABLE represents the rotation stability, + /** @brief STABLE represents the rotation stability, + * @brief raises RENC_EXECUTION_DELAY counts after REnc STOPping + * + * @retval 1 - stable + */ + + /** set callback function to Clockwise TURN */ + void setHandleCC(void (*fptr)(void)); + /** set callback function to Counterclockwise TURN */ + void setHandleCCW(void (*fptr)(void)); REnc(PinName pina, PinName pinb); + virtual ~REnc() { }; private: void sample_encoder(void); - void (*mRightCallback)(void); - void (*mLeftCallback)(void); + void (*mCCCallback)(void); + void (*mCCWCallback)(void); DigitalIn _pina; DigitalIn _pinb;