Demo showing opening a webpage on a mac

Dependencies:   USBDevice mbed-rtos mbed

Fork of USBKeyboard_HelloWorld by Samuel Mokrani

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "USBKeyboard.h"
00003 #include "rtos.h"
00004  
00005 DigitalOut led1(LED1);
00006 DigitalOut led2(LED2);
00007 DigitalOut led3(LED3);
00008 DigitalOut led4(LED4);
00009 
00010 DigitalIn button(p14);
00011 
00012 USBKeyboard keyboard;
00013 
00014 void launch_site() {
00015   keyboard.keyCode(' ', 8);
00016   led1 = 1;
00017   wait_ms(750);
00018   keyboard.printf("terminal");
00019   wait_ms(50);
00020   keyboard.printf("\n");
00021   led2 = 1;
00022   wait_ms(750);
00023   keyboard.keyCode('n', 8);
00024   led3 = 1;
00025   wait_ms(750);
00026   keyboard.printf("open http://dan.f-box.org/tmp/3/\n");
00027   led4 = 1;
00028 }
00029 
00030 void button_thread(void const *args) {
00031     while (true) {
00032       if (button) {
00033         launch_site();
00034       }
00035       Thread::wait(500);
00036     }
00037 }
00038 int main(void) {
00039     Thread thread(button_thread);
00040     while (1) {
00041       Thread::wait(500000);
00042     }
00043 }