Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Gamepad.h
- Revision:
- 13:ef5fc9f58805
- Parent:
- 12:1b0b6355da4f
- Child:
- 15:c582b3326d44
--- 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
*/