test

Dependencies:   ESP8266 HCSR04 PID

Fork of car_test_v1 by 涂 桂旺

Revision:
3:9e51de1050a1
diff -r 35738c77d454 -r 9e51de1050a1 HALLFX/HALLFX_ENCODER.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HALLFX/HALLFX_ENCODER.cpp	Sat Nov 25 03:36:58 2017 +0000
@@ -0,0 +1,20 @@
+#include "HALLFX_ENCODER.h"
+
+HALLFX_ENCODER::HALLFX_ENCODER(PinName enc_in): _enc_in(enc_in){
+    _enc_in.mode(PullUp);
+    // Invoke interrupt on both falling and rising edges
+    _enc_in.fall(callback(this, &HALLFX_ENCODER::callback_c));
+    _enc_in.rise(callback(this, &HALLFX_ENCODER::callback_c));
+}
+
+long HALLFX_ENCODER::read(){
+    return count;
+}
+
+void HALLFX_ENCODER::reset(){
+    count = 0;
+}
+
+void HALLFX_ENCODER::callback_c(){
+    count++;   
+}
\ No newline at end of file