UVic Assistive Technology Lab / Mbed 2 deprecated DSLR_Camera_Gimbal

Dependencies:   mbed ros_lib_kinetic

Revision:
2:0537a8007a39
Parent:
1:1ac7d472cfa2
Child:
4:89ebfa37663b
diff -r 1ac7d472cfa2 -r 0537a8007a39 interrupts.cpp
--- a/interrupts.cpp	Tue Feb 06 20:50:55 2018 +0000
+++ b/interrupts.cpp	Thu Feb 08 22:23:40 2018 +0000
@@ -1,21 +1,8 @@
-
+#include "mbed.h"
 #include <definitions.h>
 
-void liftInterrupt(){
 
-    liftFlag = 1;
-}
-
-void motorInterrupt(){
-    
-    motorFlag = 1;
-}
-
-void rosInterrupt(){
-    
-    rosFlag = 1;
-}
-
+//Stall Check Interrupt
 void hallInterrupt(){
     if(prevPosition == currentPosition){
         stall = true;
@@ -25,3 +12,27 @@
         stall  = false;          
     }
 }
+
+//External Interrupt Counter
+class Hall_Counter_1 {
+public:
+    Hall_Counter_1(PinName pin) : _interrupt(pin) {        // create the InterruptIn on the pin specified to Counter
+        _interrupt.rise(this, &Hall_Counter_1::increment); // attach increment function of this counter instance
+    }
+    void increment() {
+        if(filter_hall1.read_ms() > 5){
+            if(liftDirection.read() == LIFTUP){
+                currentPosition++;
+            }
+            else{
+                currentPosition--;
+            }
+            filter_hall1.reset();
+        }
+    }
+ 
+private:
+    InterruptIn _interrupt;
+};
+
+Hall_Counter_1 hall_Counter_1(PC_7);
\ No newline at end of file