Bumper

Files at this revision

API Documentation at this revision

Comitter:
dupm2216
Date:
Sat Mar 11 20:27:16 2017 +0000
Commit message:
Initial commit

Changed in this revision

Bumper.cpp Show annotated file Show diff for this revision Revisions of this file
Bumper.hpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 712cf0eef294 Bumper.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bumper.cpp	Sat Mar 11 20:27:16 2017 +0000
@@ -0,0 +1,14 @@
+#include "Bumper.hpp"
+
+Bumper::Bumper(TargetManager& target_manager, const int id, PinName pin) :
+    interrupt_in(pin),
+    target_manager(target_manager),
+    id(id)
+{        
+    interrupt_in.rise(callback(this, &Bumper::bumped));
+}
+
+void Bumper::bumped()
+{
+    target_manager.target_hit(id);
+}
diff -r 000000000000 -r 712cf0eef294 Bumper.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bumper.hpp	Sat Mar 11 20:27:16 2017 +0000
@@ -0,0 +1,24 @@
+#ifndef BUMPER_HPP
+#define BUMPER_HPP
+
+//How to connect limit switch:
+//  C (common): pin to read
+//  NO (normally open): VCC
+//  NC (normally closed): Not connected
+
+#include "mbed.h"
+#include "TargetManager.hpp"
+
+class Bumper
+{
+    public:
+        Bumper(TargetManager& target_manager, int id, PinName pin);
+        void bumped();
+        
+    private:
+        InterruptIn interrupt_in;
+        TargetManager& target_manager;
+        const int id;
+};
+
+#endif
\ No newline at end of file