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.
Diff: shell.cpp
- Revision:
- 5:03b7c237c4c4
- Child:
- 7:19da09fe546b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shell.cpp Mon Apr 14 01:47:31 2014 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "shell.h" + +// create contructor +Shell::Shell(uint32_t thisBaudRate) +{ + usbSerial = new Serial(USBTX, USBRX); + usbSerial->baud(115200); +} +//----------------------------------------------------------------------------- + +void Shell::sendText(char *thisText) +{ + // this can send any text + usbSerial->printf(thisText); +} +//----------------------------------------------------------------------------- + +void Shell::sendHelloWorld() +{ + // sends the first greeting + sendText("** Hello World **\n\n> "); +} +//----------------------------------------------------------------------------- + +void Shell::scanUSBSerialRx() +{ + // check if there is something to read + if(usbSerial->readable()) { + + // if so ... + char character = usbSerial->getc(); + + // see if this is a semi colon or a carriage return + // if so, give a new line cursor + if((character == ';') || (character == 13)) usbSerial->printf("\n> "); + + // if not, just print the character + else usbSerial->printf("%c", character); + } +} +//----------------------------------------------------------------------------- + \ No newline at end of file