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.
main.cpp@1:648d1f317624, 2012-04-18 (annotated)
- Committer:
- stvnrhodes
- Date:
- Wed Apr 18 22:33:00 2012 +0000
- Revision:
- 1:648d1f317624
- Parent:
- 0:22803b0c80a9
- Child:
- 2:d3a99fd96468
Still for Adam
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| stvnrhodes | 0:22803b0c80a9 | 1 | #include "mbed.h" |
| stvnrhodes | 0:22803b0c80a9 | 2 | #include "Wifly.h" |
| stvnrhodes | 1:648d1f317624 | 3 | #include "Bitmap.h" |
| stvnrhodes | 0:22803b0c80a9 | 4 | LocalFileSystem local("local"); |
| stvnrhodes | 0:22803b0c80a9 | 5 | Serial pc(USBTX, USBRX); |
| stvnrhodes | 0:22803b0c80a9 | 6 | DigitalOut led(LED1); |
| stvnrhodes | 0:22803b0c80a9 | 7 | Wifly wifi(p9, p10, p8); |
| stvnrhodes | 0:22803b0c80a9 | 8 | Command * cmd; |
| stvnrhodes | 1:648d1f317624 | 9 | Bitmap bmp; |
| stvnrhodes | 0:22803b0c80a9 | 10 | |
| stvnrhodes | 0:22803b0c80a9 | 11 | int main() { |
| stvnrhodes | 0:22803b0c80a9 | 12 | pc.baud(460800); |
| stvnrhodes | 0:22803b0c80a9 | 13 | printf("Test Airbrush!\r\n"); |
| stvnrhodes | 0:22803b0c80a9 | 14 | wifi.createAdhocNetwork(); |
| stvnrhodes | 1:648d1f317624 | 15 | bmp.openImg("/local/a.bmp"); |
| stvnrhodes | 1:648d1f317624 | 16 | bmp.setRow(0); |
| stvnrhodes | 1:648d1f317624 | 17 | bmp.closeImg(); |
| stvnrhodes | 1:648d1f317624 | 18 | for (int i = 0; i < bmp.getHeight(); i++) { |
| stvnrhodes | 1:648d1f317624 | 19 | bmp.setRow(i); |
| stvnrhodes | 1:648d1f317624 | 20 | for (int j =0; j < bmp.getWidth(); j++) { |
| stvnrhodes | 1:648d1f317624 | 21 | if(bmp.isPixel(j)) { |
| stvnrhodes | 1:648d1f317624 | 22 | pc.printf("1"); |
| stvnrhodes | 1:648d1f317624 | 23 | } else { |
| stvnrhodes | 1:648d1f317624 | 24 | pc.printf("0"); |
| stvnrhodes | 1:648d1f317624 | 25 | } |
| stvnrhodes | 1:648d1f317624 | 26 | } |
| stvnrhodes | 1:648d1f317624 | 27 | pc.printf("\n\r"); |
| stvnrhodes | 1:648d1f317624 | 28 | } |
| stvnrhodes | 0:22803b0c80a9 | 29 | while (1) { |
| stvnrhodes | 0:22803b0c80a9 | 30 | while(pc.readable()) { |
| stvnrhodes | 0:22803b0c80a9 | 31 | wifi.putc(pc.getc()); |
| stvnrhodes | 0:22803b0c80a9 | 32 | } |
| stvnrhodes | 0:22803b0c80a9 | 33 | while(wifi.readable()){ |
| stvnrhodes | 0:22803b0c80a9 | 34 | pc.putc(wifi.getc()); |
| stvnrhodes | 0:22803b0c80a9 | 35 | } |
| stvnrhodes | 0:22803b0c80a9 | 36 | if(wifi.hasCmd()){ |
| stvnrhodes | 0:22803b0c80a9 | 37 | cmd = wifi.getCmd(); |
| stvnrhodes | 0:22803b0c80a9 | 38 | switch(cmd->cmd) { |
| stvnrhodes | 0:22803b0c80a9 | 39 | case 0x00: |
| stvnrhodes | 0:22803b0c80a9 | 40 | pc.printf("Move to x: %d, y:%d, z:%d\n\r", cmd->l[0], cmd->l[1], cmd->l[2]); |
| stvnrhodes | 0:22803b0c80a9 | 41 | wait(3); |
| stvnrhodes | 0:22803b0c80a9 | 42 | wifi.send("Done"); // Make sure to always send confirmation |
| stvnrhodes | 0:22803b0c80a9 | 43 | break; |
| stvnrhodes | 0:22803b0c80a9 | 44 | default: |
| stvnrhodes | 0:22803b0c80a9 | 45 | pc.printf("You should probably do something with case %x\n\r", cmd->cmd); |
| stvnrhodes | 0:22803b0c80a9 | 46 | wifi.send("No code"); |
| stvnrhodes | 0:22803b0c80a9 | 47 | } |
| stvnrhodes | 0:22803b0c80a9 | 48 | } |
| stvnrhodes | 0:22803b0c80a9 | 49 | } |
| stvnrhodes | 0:22803b0c80a9 | 50 | } |