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.
Dependencies: mbed SerialInputReactionHandler StrCommandHandler
main.cpp
00001 #include "mbed.h" 00002 #include "StrCommandHandler.h" 00003 #include "SerialInputReactionHandler.h" 00004 00005 DigitalOut myled1(LED1); 00006 00007 DigitalOut myled2(LED2); 00008 00009 DigitalOut myled3(LED3); 00010 00011 DigitalOut myled4(LED4); 00012 00013 Serial pc(USBTX, USBRX); // tx, rx 00014 00015 StrCommandHandler cmdHandler(5); 00016 00017 00018 void * func1(void) 00019 { 00020 myled1 = 1; 00021 myled2 = 0; 00022 myled3 = 0; 00023 return NULL; 00024 } 00025 00026 void * func2(void) 00027 { 00028 myled1 = 0; 00029 myled2 = 1; 00030 myled3 = 0; 00031 return NULL; 00032 } 00033 00034 void * func3(void) 00035 { 00036 myled1 = 0; 00037 myled2 = 0; 00038 myled3 = 1; 00039 return NULL; 00040 } 00041 00042 int main() 00043 { 00044 pc.baud(921600); 00045 cmdHandler.map("func1", func1); 00046 cmdHandler.map("func2", func2); 00047 cmdHandler.map(SerialInputReactionHandler::ARROW_UP, func3); 00048 cmdHandler.list(); 00049 00050 SerialInputReactionHandler *reactor = new SerialInputReactionHandler(); 00051 //reactor->attach(callback(&cmdHandler, &StrCommandHandler::exe)); 00052 //reactor.startReception(&pc, SerialInputReactionHandler::KB_TILL_ENTER); 00053 00054 00055 00056 PRELOOP: 00057 pc.puts("\ncommand: "); 00058 while(1) { 00059 myled4 = !myled4; 00060 wait(.5); 00061 } 00062 goto PRELOOP; 00063 }
Generated on Sat Aug 13 2022 22:28:39 by
1.7.2