Rotary Encoder handling library for mbed

Dependents:   MIDI_CW Gemphet8

Files at this revision

API Documentation at this revision

Comitter:
ChuckTimber
Date:
Tue Aug 12 02:59:22 2014 +0000
Parent:
5:3e6931797218
Commit message:
Rotary Encoder handling library for mbed

Changed in this revision

REnc.cpp Show annotated file Show diff for this revision Revisions of this file
REnc.h Show annotated file Show diff for this revision Revisions of this file
diff -r 3e6931797218 -r abd0d8d58fed REnc.cpp
--- a/REnc.cpp	Tue Aug 12 01:56:59 2014 +0000
+++ b/REnc.cpp	Tue Aug 12 02:59:22 2014 +0000
@@ -1,6 +1,3 @@
-#include "REnc.h"
-#include "mbed.h"
-
 /**
  *  @file       REnc.cpp
  *  Project     Rotary Encoder handling Library
@@ -9,7 +6,10 @@
  *  @author     Chuck Timber
  *  @date       12/08/2014
  */
-/** class to handle a rotary encoder
+#include "REnc.h"
+#include "mbed.h"
+
+/* class to handle a rotary encoder
  *
  */
 
@@ -61,6 +61,8 @@
  *
  * @param pina - Digital Input to A-phase of the rotary encoder
  * @param pinb - Digital Input to B-phase of the rotary encoder   
+ *
+ *  The pins are PullUp internally.
  */
 REnc::REnc(PinName pina, PinName pinb) : _pina(pina), _pinb(pinb)
 {
diff -r 3e6931797218 -r abd0d8d58fed REnc.h
--- a/REnc.h	Tue Aug 12 01:56:59 2014 +0000
+++ b/REnc.h	Tue Aug 12 02:59:22 2014 +0000
@@ -1,8 +1,3 @@
-#ifndef MBED_RENC_H
-#define MBED_RENC_H
-
-#include "mbed.h"
-
 /**
  *  @file       REnc.h
  *  Project     Rotary Encoder handling Library
@@ -11,8 +6,27 @@
  *  @author     Chuck Timber
  *  @date       12/08/2014
  */
-/** class to handle a rotary encoder 
- *   The class use DigitalIn and Ticker
+
+#ifndef MBED_RENC_H
+#define MBED_RENC_H
+
+#include "mbed.h"
+
+/**
+ *  @define
+ *
+ */
+#define RENC_SAMPLING_PERIOD 0.002
+#define RENC_EXECUTION_DELAY 300
+
+namespace mbed {
+
+    enum { STOP, CLOCKWISE, COUNTERCLOCKWISE };
+//    enum { STOP, CC,        CCW              };
+
+/** Class: REnc
+ *  A class to handle a rotary encoder 
+ *   This class uses DigitalIn and Ticker
  *
  * Refered to: http://elm-chan.org/docs/tec/te04.html
  *
@@ -50,33 +64,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
- */
 class REnc {
 
 public:
-    unsigned char CMD;    /*!< @brief CMD represents the state of rotation
+    unsigned char CMD;    /*!< CMD represents the state of rotation
                            *   @retval STOP
                            *   @retval CLOCKWISE
                            *   @retval COUNTERCLOCKWISE
                            */
-    unsigned char STABLE; /*!< @brief STABLE represents the rotation stability,
-                           *  @brief raises RENC_EXECUTION_DELAY counts after REnc STOPping
-                           *  @retval 1 - stable
+    unsigned char STABLE; /*!< STABLE represents the rotation stability,
+                           *   raises RENC_EXECUTION_DELAY counts after REnc STOPping
+                           *   @retval 1 - stable
                            */ 
 
     /** set callback function to Clockwise TURN */