Demo showing opening a webpage on a mac

Dependencies:   USBDevice mbed-rtos mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Revision:
7:e5faccf72400
Parent:
5:03a4211d593a
--- 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