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@6:7a38f754e030, 2015-11-28 (annotated)
- Committer:
- Xiaofei
- Date:
- Sat Nov 28 02:35:43 2015 +0000
- Revision:
- 6:7a38f754e030
- Parent:
- 5:c1b3251ba5d5
- Child:
- 7:348c8891e542
C
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Xiaofei | 2:d77f669c7feb | 1 | #pragma once |
| Xiaofei | 0:526a865b9b03 | 2 | #include "mbed.h" |
| Xiaofei | 0:526a865b9b03 | 3 | #include "CommandPool.h" |
| Xiaofei | 2:d77f669c7feb | 4 | #include "Xbee.h" |
| Xiaofei | 5:c1b3251ba5d5 | 5 | #include "GenCMD.h" |
| Xiaofei | 0:526a865b9b03 | 6 | |
| Xiaofei | 0:526a865b9b03 | 7 | Command* cmd; |
| Xiaofei | 0:526a865b9b03 | 8 | CommandPool pool; |
| Xiaofei | 5:c1b3251ba5d5 | 9 | GenCMD gen_cmd; |
| Xiaofei | 5:c1b3251ba5d5 | 10 | Xbee xbee(p9,p10,p11); |
| Xiaofei | 6:7a38f754e030 | 11 | DigitalOut led(LED1); |
| Xiaofei | 5:c1b3251ba5d5 | 12 | |
| Xiaofei | 6:7a38f754e030 | 13 | char cmd_buffer[3]; |
| Xiaofei | 2:d77f669c7feb | 14 | |
| Xiaofei | 0:526a865b9b03 | 15 | |
| Xiaofei | 6:7a38f754e030 | 16 | Serial pc(USBTX, USBRX); |
| Xiaofei | 6:7a38f754e030 | 17 | |
| Xiaofei | 0:526a865b9b03 | 18 | int main() |
| Xiaofei | 0:526a865b9b03 | 19 | { |
| Xiaofei | 0:526a865b9b03 | 20 | /* draft of main code*/ |
| Xiaofei | 0:526a865b9b03 | 21 | pool.init(); |
| Xiaofei | 5:c1b3251ba5d5 | 22 | gen_cmd.init(); |
| Xiaofei | 2:d77f669c7feb | 23 | |
| Xiaofei | 0:526a865b9b03 | 24 | while(1) |
| Xiaofei | 0:526a865b9b03 | 25 | { |
| Xiaofei | 5:c1b3251ba5d5 | 26 | gen_cmd.GenerateCMD(cmd_buffer); |
| Xiaofei | 6:7a38f754e030 | 27 | xbee.Send(cmd_buffer); |
| Xiaofei | 6:7a38f754e030 | 28 | led = !led; |
| Xiaofei | 0:526a865b9b03 | 29 | //if(med1.readable()) |
| Xiaofei | 0:526a865b9b03 | 30 | //{ |
| Xiaofei | 0:526a865b9b03 | 31 | //med1.read(cmd_buffer,20,callBack); // read to cmd buffer, and update command |
| Xiaofei | 5:c1b3251ba5d5 | 32 | //cmd = pool.getCommand(cmd_buffer); // if cmd is valid |
| Xiaofei | 6:7a38f754e030 | 33 | //if(cmd) |
| Xiaofei | 6:7a38f754e030 | 34 | //{ |
| Xiaofei | 6:7a38f754e030 | 35 | //cmd->execute(); // execute cmd |
| Xiaofei | 6:7a38f754e030 | 36 | //} |
| Xiaofei | 6:7a38f754e030 | 37 | wait(0.01); |
| Xiaofei | 0:526a865b9b03 | 38 | //} |
| Xiaofei | 0:526a865b9b03 | 39 | } |
| Xiaofei | 0:526a865b9b03 | 40 | return 0; |
| Xiaofei | 0:526a865b9b03 | 41 | } |
