Rotary Encoder handling library for mbed

Dependents:   MIDI_CW Gemphet8

Revision:
1:2732adb68dad
Parent:
0:c905f9e6866f
Child:
2:46173a05338e
diff -r c905f9e6866f -r 2732adb68dad REnc.h
--- a/REnc.h	Sat Jul 26 22:49:27 2014 +0000
+++ b/REnc.h	Wed Aug 06 06:35:47 2014 +0000
@@ -3,26 +3,56 @@
 
 #include "mbed.h"
 
-/** class to make 
- *   The class use 
+/** class to handle a rotary encoder 
+ *   The class use DigitalIn and Ticker
+ *
+ * Refered to: http://elm-chan.org/docs/tec/te04.html
  *
  * Example:
  * @code
+ * // REnc sample
+ * #include "mbed.h"
+ * #include "REnc.h"
+ * void proc_REnc_right(void);
+ * void proc_REnc_left(void);
+ * 
+ * // void proc_REnc_right(void) { }
+ * // void proc_REnc_left(void)  { }
+ * 
+ * REnc renc(dp1, dp2);
+ * 
+ * int main()
+ * {
+ * 
+ *     // renc.setHandleRight(&proc_REnc_right);
+ *     // renc.setHandleLeft(&proc_REnc_left);
+ *  
+ *     while(1) {
+ *         if (renc.CMD == FORWARD) {
+ *             proc_REnc_right();
+ *             renc.CMD = STOP;
+ *         } else if (renc.CMD == REVERSE) {
+ *             proc_REnc_left();
+ *             renc.CMD = STOP;
+ *         }
+ *     }
+ * }
  * @endcode
  */
 
 
 namespace mbed {
 
-    enum { IDLE, FORWARD, BACKWARD };
+    enum { STOP, FORWARD, REVERSE };
 
-/* Class: REnc
- *  A class witch uses 
+/** class to handle a rotary encoder 
+ *   The class uses DigitalIn and Ticker
  */
 class REnc {
 
 public:
     unsigned char CMD;
+    unsigned char STABLE;
     void setHandleRight(void (*fptr)(void));
     void setHandleLeft(void (*fptr)(void));