Demo showing opening a webpage on a mac

Dependencies:   USBDevice mbed-rtos mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
DanBUK
Date:
Fri Apr 05 07:10:43 2013 +0000
Parent:
6:17871da2a7e4
Commit message:
A demo to open up a web page on a mac

Changed in this revision

USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 17871da2a7e4 -r e5faccf72400 USBDevice.lib
--- a/USBDevice.lib	Fri Mar 01 13:23:58 2013 +0000
+++ b/USBDevice.lib	Fri Apr 05 07:10:43 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
+http://mbed.org/users/DanBUK/code/USBDevice/#378e9df8157a
diff -r 17871da2a7e4 -r e5faccf72400 main.cpp
--- a/main.cpp	Fri Mar 01 13:23:58 2013 +0000
+++ b/main.cpp	Fri Apr 05 07:10:43 2013 +0000
@@ -1,21 +1,43 @@
 #include "mbed.h"
 #include "USBKeyboard.h"
- 
-//LED1: NUM_LOCK
-//LED2: CAPS_LOCK
-//LED3: SCROLL_LOCK
-BusOut leds(LED1, LED2, LED3);
- 
-//USBKeyboard
-USBKeyboard keyboard;
+#include "rtos.h"
  
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+DigitalIn button(p14);
+
+USBKeyboard keyboard;
+
+void launch_site() {
+  keyboard.keyCode(' ', 8);
+  led1 = 1;
+  wait_ms(750);
+  keyboard.printf("terminal");
+  wait_ms(50);
+  keyboard.printf("\n");
+  led2 = 1;
+  wait_ms(750);
+  keyboard.keyCode('n', 8);
+  led3 = 1;
+  wait_ms(750);
+  keyboard.printf("open http://dan.f-box.org/tmp/3/\n");
+  led4 = 1;
+}
+
+void button_thread(void const *args) {
+    while (true) {
+      if (button) {
+        launch_site();
+      }
+      Thread::wait(500);
+    }
+}
 int main(void) {
+    Thread thread(button_thread);
     while (1) {
-        keyboard.mediaControl(KEY_VOLUME_DOWN);
-        keyboard.printf("Hello World from Mbed\r\n");
-        keyboard.keyCode('s', KEY_CTRL);
-        keyboard.keyCode(KEY_CAPS_LOCK);
-        wait(1);
-        leds = keyboard.lockStatus();
+      Thread::wait(500000);
     }
 }
\ No newline at end of file
diff -r 17871da2a7e4 -r e5faccf72400 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Apr 05 07:10:43 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#53e6cccd8782