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: Command CommandPool GenCMD LSM9DS0 Mode Motor PinDetect Xbee mbed
Fork of VR_Robot by
main.cpp@0:526a865b9b03, 2015-11-21 (annotated)
- Committer:
- Xiaofei
- Date:
- Sat Nov 21 17:19:27 2015 +0000
- Revision:
- 0:526a865b9b03
- Child:
- 2:d77f669c7feb
hj
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Xiaofei | 0:526a865b9b03 | 1 | #include "mbed.h" |
| Xiaofei | 0:526a865b9b03 | 2 | #include "CommandPool.h" |
| Xiaofei | 0:526a865b9b03 | 3 | |
| Xiaofei | 0:526a865b9b03 | 4 | /* draft code |
| Xiaofei | 0:526a865b9b03 | 5 | |
| Xiaofei | 0:526a865b9b03 | 6 | Serial med1(ptx,prx); // used for read data from another mbed |
| Xiaofei | 0:526a865b9b03 | 7 | |
| Xiaofei | 0:526a865b9b03 | 8 | Command* cmd; |
| Xiaofei | 0:526a865b9b03 | 9 | |
| Xiaofei | 0:526a865b9b03 | 10 | char cmd_buffer[20]; // data buffer |
| Xiaofei | 0:526a865b9b03 | 11 | CommandPool pool; |
| Xiaofei | 0:526a865b9b03 | 12 | |
| Xiaofei | 0:526a865b9b03 | 13 | void callBack() // when cmd_buffer obtained something, update cmd |
| Xiaofei | 0:526a865b9b03 | 14 | { |
| Xiaofei | 0:526a865b9b03 | 15 | cmd = pool.getCommand(cmd_buffer); |
| Xiaofei | 0:526a865b9b03 | 16 | } |
| Xiaofei | 0:526a865b9b03 | 17 | |
| Xiaofei | 0:526a865b9b03 | 18 | */ |
| Xiaofei | 0:526a865b9b03 | 19 | |
| Xiaofei | 0:526a865b9b03 | 20 | |
| Xiaofei | 0:526a865b9b03 | 21 | Command* cmd; |
| Xiaofei | 0:526a865b9b03 | 22 | CommandPool pool; |
| Xiaofei | 0:526a865b9b03 | 23 | char CMD = LED; |
| Xiaofei | 0:526a865b9b03 | 24 | Serial pc(USBTX,USBRX); |
| Xiaofei | 0:526a865b9b03 | 25 | |
| Xiaofei | 0:526a865b9b03 | 26 | int main() |
| Xiaofei | 0:526a865b9b03 | 27 | { |
| Xiaofei | 0:526a865b9b03 | 28 | /* draft of main code*/ |
| Xiaofei | 0:526a865b9b03 | 29 | pool.init(); |
| Xiaofei | 0:526a865b9b03 | 30 | |
| Xiaofei | 0:526a865b9b03 | 31 | while(1) |
| Xiaofei | 0:526a865b9b03 | 32 | { |
| Xiaofei | 0:526a865b9b03 | 33 | //if(med1.readable()) |
| Xiaofei | 0:526a865b9b03 | 34 | //{ |
| Xiaofei | 0:526a865b9b03 | 35 | //med1.read(cmd_buffer,20,callBack); // read to cmd buffer, and update command |
| Xiaofei | 0:526a865b9b03 | 36 | cmd = pool.getCommand(CMD); // if cmd is valid |
| Xiaofei | 0:526a865b9b03 | 37 | if(cmd) |
| Xiaofei | 0:526a865b9b03 | 38 | { |
| Xiaofei | 0:526a865b9b03 | 39 | cmd->execute(); // execute cmd |
| Xiaofei | 0:526a865b9b03 | 40 | } |
| Xiaofei | 0:526a865b9b03 | 41 | wait(0.5); |
| Xiaofei | 0:526a865b9b03 | 42 | //} |
| Xiaofei | 0:526a865b9b03 | 43 | } |
| Xiaofei | 0:526a865b9b03 | 44 | return 0; |
| Xiaofei | 0:526a865b9b03 | 45 | } |
