NerfUS / HardwareInterface

Dependents:   NerfUS_cmake_add_library_from_mbed NerfUS NerfUSGameCoordinator

Files at this revision

API Documentation at this revision

Comitter:
Maxime Dupuis
Date:
Thu Feb 16 11:42:32 2017 -0500
Child:
1:001a600870d9
Commit message:
Initial commit

Add a BlinkerInterface from which different hardware implementations
could be made (e.g. for the LPC1768)

Changed in this revision

CMakeLists.txt Show annotated file Show diff for this revision Revisions of this file
include/BlinkerInterface.hpp Show annotated file Show diff for this revision Revisions of this file
include/MbedBlinker.hpp Show annotated file Show diff for this revision Revisions of this file
source/MbedBlinker.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt	Thu Feb 16 11:42:32 2017 -0500
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(hardware_interface_lpc1768)
+
+include_directories(include)
+
+file(GLOB SOURCES "source/*.cpp")
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/BlinkerInterface.hpp	Thu Feb 16 11:42:32 2017 -0500
@@ -0,0 +1,4 @@
+class BlinkerInterface
+{
+    virtual void blink() = 0;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/MbedBlinker.hpp	Thu Feb 16 11:42:32 2017 -0500
@@ -0,0 +1,12 @@
+#include "BlinkerInterface.hpp"
+#include "mbed.h"
+
+class MbedBlinker : public BlinkerInterface
+{
+    public:
+        MbedBlinker(DigitalOut led);
+        virtual void blink();
+        
+    private:
+        DigitalOut led;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/MbedBlinker.cpp	Thu Feb 16 11:42:32 2017 -0500
@@ -0,0 +1,14 @@
+#include "MbedBlinker.hpp"
+
+MbedBlinker::MbedBlinker(DigitalOut led) :
+    led(led)
+{
+}
+
+void MbedBlinker::blink()
+{
+    led = 1;
+    wait(0.5);
+    led = 0;
+    wait(0.5);
+}