LimitSwitches

Revision:
0:a298c2462f4f
diff -r 000000000000 -r a298c2462f4f LimitSwitches.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LimitSwitches.cpp	Tue Jun 04 17:00:17 2019 +0000
@@ -0,0 +1,30 @@
+#include "LimitSwitches.h"
+#include "mbed.h"
+#include "stdio.h"
+
+SWITCHES::SWITCHES(PinName S1, PinName S2) : Switch1(S1),Switch2(S2) {
+    Switch1.rise(this,&SWITCHES::InterruptDisable);
+    Switch2.rise(this,&SWITCHES::InterruptDisable);
+}
+ 
+int SWITCHES::Read()
+{
+    if(Switch1.read()) {
+        return 1;
+    }
+    if(Switch2.read()) {
+        return 2;
+    }
+    return 0;
+}
+
+void SWITCHES::InterruptDisable()
+{
+    Switch1.disable_irq();
+    Switch2.disable_irq();
+}
+void SWITCHES::InterruptEnable()
+{
+    Switch1.enable_irq();
+    Switch2.enable_irq();
+}