Using markdown to write mbed wiki

This notebook is written by markdown, then converted to mbed wiki(a custom creole wiki) format. A ruby script - md2cre.rb is used. Let's get started on Ubuntu.

Setup

sudo apt-get install ruby ruby1.9.1-dev
sudo gem install redcarpet
git clone https://gist.github.com/xiongyihui/7869398.git

Usage

In a markdown file, a link with "!program" or "!library" name will be converted to a program or library link on mbed.org.

ruby md2cre.rb note.md > note.cre

Example

This is a part of [Arch Cookbook][Arch Cookbook].
### Recipe 8: Working with USB Keyboard
#### Ingredients
In addition to things listed in [Recipe 1][Arch Cookbook], we require
* Grove - Button
#### Procedure
* Connect Grove - Button to on-board grove connector marked UART.
* Build and upload the program to Arch platform. follow procedure listed in **Recipe 1**.

The following program demonstrates a USB keyboard with one button. 
Press the button to mute your computer and press CapsLock, NumLock or 
ScrollLock of your keyboard to turn on/off Arch's LEDs.

[!program][Arch_USB_Keyboard_Ex1]

[Arch Cookbook]: http://mbed.org/users/viswesr/notebook/arch-cookbook/
[Arch_USB_Keyboard_Ex1]: /users/yihui/code/Arch_USB_Keyboard_Ex1/docs/9692f894c2b7/main_8cpp_source.html

Result

This is a part of Arch Cookbook.

Recipe 8: Working with USB Keyboard

Ingredients

In addition to things listed in Recipe 1, we require

  • Grove - Button

Procedure

  • Connect Grove - Button to on-board grove connector marked UART.
  • Build and upload the program to Arch platform. follow procedure listed in Recipe 1.

The following program demonstrates a USB keyboard with one button. Press the button to mute your computer and press CapsLock, NumLock or ScrollLock of your keyboard to turn on/off Arch's LEDs.

Import program

00001 #include "mbed.h"
00002 #include "USBKeyboard.h"
00003 
00004 //LED1: NUM_LOCK, LED2: CAPS_LOCK, LED3: SCROLL_LOCK
00005 BusOut leds(LED1, LED2, LED3);
00006 DigitalOut button(P1_14);               // Configure P1_14 pin as input
00007 USBKeyboard keyboard;
00008 
00009 int main() {
00010     int buttonPressedCount = 0; 
00011     
00012     while (!keyboard.configured()) {    // wait until keyboard is configured
00013     }
00014     
00015     while (1) {
00016         leds = keyboard.lockStatus();
00017         
00018         if (button.read()) {
00019             buttonPressedCount++;
00020             if (2 == buttonPressedCount) { // when button is pressed about 0.02s
00021                 keyboard.mediaControl(KEY_MUTE); // send mute key
00022             }
00023         } else {
00024             buttonPressedCount = 0;
00025         }
00026         wait(0.01);
00027     }
00028 }


Please log in to post comments.