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.
Dependents: Project_MaZe1_copy Labirint Game_Controller_Project 200943373MAZE ... more
Revision 0:a6288c29b936, committed 2017-02-04
- Comitter:
- eencae
- Date:
- Sat Feb 04 15:31:44 2017 +0000
- Child:
- 1:6d25cd49059b
- Commit message:
- Initial commit. Untested. Under development.
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Gamepad.cpp Sat Feb 04 15:31:44 2017 +0000
@@ -0,0 +1,53 @@
+#include "Gamepad.h"
+
+Gamepad::Gamepad()
+{
+ led_1 = new PwmOut(PTA1);
+ led_2 = new PwmOut(PTA2);
+ led_3 = new PwmOut(PTC2);
+ led_4 = new PwmOut(PTC3);
+ led_5 = new PwmOut(PTC4);
+ led_6 = new PwmOut(PTD3);
+
+ lcd = new N5110(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+ joystick = new Joystick(PTB10,PTB11,PTC16);
+
+ button_A = new InterruptIn(PTB9);
+ button_B = new InterruptIn(D10);
+ button_X = new InterruptIn(PTC17);
+ button_Y = new InterruptIn(PTC12); // changed pin
+ button_back = new InterruptIn(PTB19);
+ button_start = new InterruptIn(PTC5);
+ button_L = new InterruptIn(PTB18);
+ button_R = new InterruptIn(PTB3);
+
+ buzzer = new PwmOut(PTC10);
+ pot = new AnalogIn(PTB2);
+
+}
+
+void Gamepad::init()
+{
+ lcd->init();
+ joystick->init();
+}
+
+void Gamepad::leds_off()
+{
+ led_1->write(1.0);
+ led_2->write(1.0);
+ led_3->write(1.0);
+ led_4->write(1.0);
+ led_5->write(1.0);
+ led_6->write(1.0);
+}
+
+void Gamepad::leds_on()
+{
+ led_1->write(0.0);
+ led_2->write(0.0);
+ led_3->write(0.0);
+ led_4->write(0.0);
+ led_5->write(0.0);
+ led_6->write(0.0);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Gamepad.h Sat Feb 04 15:31:44 2017 +0000
@@ -0,0 +1,44 @@
+#ifndef GAMEPAD_H
+#define GAMEPAD_H
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Joystick.h"
+
+class Gamepad
+{
+
+public:
+
+ Gamepad();
+ N5110 *lcd;
+ Joystick *joystick;
+
+ void init();
+ void leds_on();
+ void leds_off();
+
+private:
+
+ PwmOut *led_1;
+ PwmOut *led_2;
+ PwmOut *led_3;
+ PwmOut *led_4;
+ PwmOut *led_5;
+ PwmOut *led_6;
+
+ InterruptIn *button_A(PTB9);
+ InterruptIn *button_B(D10);
+ InterruptIn *button_X(PTC17);
+ InterruptIn *button_Y(PTC12); // changed pin
+ InterruptIn *button_back(PTB19);
+ InterruptIn *button_start(PTC5);
+ InterruptIn *button_L(PTB18);
+ InterruptIn *button_R(PTB3);
+
+ PwmOut *buzzer(PTC10);
+ AnalogIn *pot(PTB2);
+
+};
+
+#endif
\ No newline at end of file
