basic Quadrature Encoder Library

Dependents:   ESP8266_pid_mtrPos_webserver_SDcard_v2 ESP8266_pid_mtrSpeed_Webserver_SDcard ESP8266_pid_spd_and_pos_webserver_SDcard pid_encoder_speed_demo ... more

Revision:
0:50aae578cb89
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.cpp	Mon Nov 23 02:44:15 2015 +0000
@@ -0,0 +1,21 @@
+#include "QEI.h"
+
+QEI::QEI(PinName encA, PinName encB): _encA(encA), _encB(encB){
+    _encA.mode(PullUp);
+    _encA.rise(this, &QEI::callback);
+    
+    _encB.mode(PullUp);
+}
+
+long QEI::read(){
+    return count;
+}
+
+void QEI::reset(){
+    count = 0;
+}
+
+void QEI::callback(){
+    if(_encB) count--;  // CCW count
+    else count++;       // CW count    
+}
\ No newline at end of file