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.
Dependencies: USBHost USBHostXpad mbed-rtos mbed
Diff: main.cpp
- Revision:
- 2:5e870c215495
- Parent:
- 1:3bae10d2507c
- Child:
- 3:c1620db50a75
--- a/main.cpp Thu Nov 13 23:29:03 2014 +0000
+++ b/main.cpp Sat Nov 15 21:42:16 2014 +0000
@@ -8,34 +8,30 @@
Serial pc(USBTX, USBRX);
Serial robotCom(p13, p14);
AnalogIn ir(p20);
-Speaker speaker(p18); // the pin must be the AnalogOut pin - p18
+//Speaker speaker(p18); // the pin must be the AnalogOut pin - p18
+DigitalOut led(LED1);
-Audio audio(speaker);
-USBHostXpad controller;
+//Audio audio(speaker);
Xbox360ControllerState controlState;
Traxster tank(robotCom);
//comment added
void onControlInput(int buttons, int stick_lx, int stick_ly, int stick_rx, int stick_ry, int trigger_l, int trigger_r){
- pc.printf("buttons: %04x Lstick X,Y: %-5d, %-5d Rstick X,Y: %-5d, %-5d LTrig: %02x (%d) RTrig: %02x (%d)\n", buttons, stick_lx, stick_ly, stick_rx, stick_ry, trigger_l,trigger_l, trigger_r,trigger_r);
+ pc.printf("buttons: %04x Lstick X,Y: %-5d, %-5d Rstick X,Y: %-5d, %-5d LTrig: %02x (%d) RTrig: %02x (%d)\r\n", buttons, stick_lx, stick_ly, stick_rx, stick_ry, trigger_l,trigger_l, trigger_r,trigger_r);
controlState = Xbox360ControllerState(buttons, stick_lx, stick_ly, stick_rx, stick_ry, trigger_l, trigger_r);
};
-void thread_audio_run(void const* arg){
- audio.run();
-}
+//void thread_audio_run(void const* arg){
+// audio.run();
+//}
-int main() {
- pc.baud(19200);
+void thread_controller(void const* arg){
+ USBHostXpad controller;
controller.attachEvent(&onControlInput);
- Thread audio_thread(thread_audio_run);
-
- audio.playMario();
-
while(1){
//acts as a failsafe
while(controller.connected()) {
@@ -62,3 +58,19 @@
controller.connect();
}
}
+
+int main() {
+ led = 1;
+ pc.baud(19200);
+ pc.printf("TANK\r\n");
+
+ Thread t_controller(thread_controller);
+
+ //Thread audio_thread(thread_audio_run);
+
+ //audio.playMario();
+
+ while(1){
+ Thread::wait(0);
+ }
+}
