Joe Shotton / ll16j23s_test_docs

Files at this revision

API Documentation at this revision

Comitter:
valavanisalex
Date:
Fri Mar 03 12:51:13 2017 +0000
Parent:
12:1b0b6355da4f
Child:
14:688bdcbdd3a5
Commit message:
Use forward declaration of mbed classes so that we can avoid pulling the whole of the mbed header into our own API

Changed in this revision

Gamepad.cpp Show annotated file Show diff for this revision Revisions of this file
Gamepad.h Show annotated file Show diff for this revision Revisions of this file
--- a/Gamepad.cpp	Fri Mar 03 12:35:43 2017 +0000
+++ b/Gamepad.cpp	Fri Mar 03 12:51:13 2017 +0000
@@ -1,5 +1,7 @@
 #include "Gamepad.h"
 
+#include "mbed.h"
+
 //////////// constructor/destructor ////////////
 Gamepad::Gamepad()
 {
--- a/Gamepad.h	Fri Mar 03 12:35:43 2017 +0000
+++ b/Gamepad.h	Fri Mar 03 12:51:13 2017 +0000
@@ -3,7 +3,16 @@
 
 #include <bitset>
 
-#include "mbed.h"
+// Forward declaration of the classes that we use from the mbed library
+// This avoids the need for us to include the huge mbed.h header inside our
+// own library API
+namespace mbed
+{
+class AnalogIn;
+class InterruptIn;
+class PwmOut;
+class Timeout;
+}
 
 #define TOL 0.1f
 #define RAD2DEG 57.2957795131f
@@ -58,30 +67,30 @@
 class Gamepad
 {
 private:
-    PwmOut *_led1;
-    PwmOut *_led2;
-    PwmOut *_led3;
-    PwmOut *_led4;
-    PwmOut *_led5;
-    PwmOut *_led6;
+    mbed::PwmOut *_led1;
+    mbed::PwmOut *_led2;
+    mbed::PwmOut *_led3;
+    mbed::PwmOut *_led4;
+    mbed::PwmOut *_led5;
+    mbed::PwmOut *_led6;
 
-    InterruptIn *_button_A;
-    InterruptIn *_button_B;
-    InterruptIn *_button_X;
-    InterruptIn *_button_Y;
-    InterruptIn *_button_back;
-    InterruptIn *_button_start;
-    InterruptIn *_button_L;
-    InterruptIn *_button_R;
-    InterruptIn *_button_joystick;
+    mbed::InterruptIn *_button_A;
+    mbed::InterruptIn *_button_B;
+    mbed::InterruptIn *_button_X;
+    mbed::InterruptIn *_button_Y;
+    mbed::InterruptIn *_button_L;
+    mbed::InterruptIn *_button_R;
+    mbed::InterruptIn *_button_back;
+    mbed::InterruptIn *_button_start;
+    mbed::InterruptIn *_button_joystick;
 
-    AnalogIn *_vert;
-    AnalogIn *_horiz;
+    mbed::AnalogIn *_vert;
+    mbed::AnalogIn *_horiz;
 
-    PwmOut   *_buzzer;
-    AnalogIn *_pot;
+    mbed::PwmOut   *_buzzer;
+    mbed::AnalogIn *_pot;
 
-    Timeout *_timeout;
+    mbed::Timeout *_timeout;
 
     std::bitset<N_EVENTS> _event_state; ///< A binary list of buttons that has been pressed
 
@@ -158,7 +167,7 @@
      * @return true if the event occurred
      */
     bool check_event(GamepadEvent const id);
-    
+
     /** Get magnitude of joystick movement
     * @returns value in range 0.0 to 1.0
     */