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.
Fork of frdm_echo by
main.cpp
- Committer:
- silverpanda
- Date:
- 2014-04-18
- Revision:
- 13:019e24491f32
- Parent:
- 12:b846b64e3980
- Child:
- 14:73ef945b8def
File content as of revision 13:019e24491f32:
// Print "Hello World" to the PC // push buttons: // sw2 on PTC6 // sw3 on PTA4 #include "mbed.h" #include "shell.h" #include "LEDColors.h" #include "PushButtons.h" Ticker *scanTicker; Shell *usbSerialShell; LEDColors *ledColors; PushButtons *pushButtons; bool scanUSBSerialRxFlag; void pushButtonPressed() { if(pushButtons->getPressed(pb2)) ledColors->flash(lcBlue, 10); if(pushButtons->getPressed(pb3)) ledColors->flash(lcGreen, 10); if(pushButtons->getJustPressed(pb2)) usbSerialShell->reportPushButtonPress(pb2); if(pushButtons->getJustPressed(pb3)) usbSerialShell->reportPushButtonPress(pb3); } //----------------------------------------------------------------------------- void at10msTick() { scanUSBSerialRxFlag = true; ledColors->tick10ms(); if(pushButtons->tick10ms()) pushButtonPressed(); } //----------------------------------------------------------------------------- void initMain() { // increase the baud rate for the USB serial port usbSerialShell = new Shell(115200); // send greeting with first cursor usbSerialShell->sendStartMessage(); // start polling for characters scanTicker = new Ticker(); scanTicker->attach(&at10msTick, 0.01); scanUSBSerialRxFlag = false; ledColors = new LEDColors(); pushButtons = new PushButtons(); } //----------------------------------------------------------------------------- int main() { initMain(); while(true) { // check the flag if(scanUSBSerialRxFlag) { usbSerialShell->scanUSBSerialRx(); scanUSBSerialRxFlag = false; } // give the main loop some time wait(0.02); } } //-----------------------------------------------------------------------------