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@2:d3a99fd96468, 2012-04-19 (annotated)
- Committer:
- stvnrhodes
- Date:
- Thu Apr 19 22:26:00 2012 +0000
- Revision:
- 2:d3a99fd96468
- Parent:
- 1:648d1f317624
- Child:
- 3:39ae37b9c936
First public copy
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 | 2:d3a99fd96468 | 7 | DigitalOut solenoid(p29); |
| stvnrhodes | 0:22803b0c80a9 | 8 | Wifly wifi(p9, p10, p8); |
| stvnrhodes | 0:22803b0c80a9 | 9 | Command * cmd; |
| stvnrhodes | 1:648d1f317624 | 10 | Bitmap bmp; |
| stvnrhodes | 0:22803b0c80a9 | 11 | |
| stvnrhodes | 0:22803b0c80a9 | 12 | int main() { |
| stvnrhodes | 2:d3a99fd96468 | 13 | solenoid = 0; |
| stvnrhodes | 0:22803b0c80a9 | 14 | pc.baud(460800); |
| stvnrhodes | 0:22803b0c80a9 | 15 | printf("Test Airbrush!\r\n"); |
| stvnrhodes | 0:22803b0c80a9 | 16 | wifi.createAdhocNetwork(); |
| stvnrhodes | 1:648d1f317624 | 17 | bmp.openImg("/local/a.bmp"); |
| stvnrhodes | 2:d3a99fd96468 | 18 | for (int i=0; i < bmp.getHeight(); i++) { |
| stvnrhodes | 2:d3a99fd96468 | 19 | pc.printf("Row %3d: ", i); |
| stvnrhodes | 1:648d1f317624 | 20 | bmp.setRow(i); |
| stvnrhodes | 2:d3a99fd96468 | 21 | for (int j=0; j < bmp.getWidth(); j++) { |
| stvnrhodes | 1:648d1f317624 | 22 | if(bmp.isPixel(j)) { |
| stvnrhodes | 1:648d1f317624 | 23 | pc.printf("1"); |
| stvnrhodes | 1:648d1f317624 | 24 | } else { |
| stvnrhodes | 2:d3a99fd96468 | 25 | pc.printf(" "); |
| stvnrhodes | 1:648d1f317624 | 26 | } |
| stvnrhodes | 1:648d1f317624 | 27 | } |
| stvnrhodes | 1:648d1f317624 | 28 | pc.printf("\n\r"); |
| stvnrhodes | 1:648d1f317624 | 29 | } |
| stvnrhodes | 2:d3a99fd96468 | 30 | bmp.closeImg(); |
| stvnrhodes | 0:22803b0c80a9 | 31 | while (1) { |
| stvnrhodes | 0:22803b0c80a9 | 32 | while(pc.readable()) { |
| stvnrhodes | 0:22803b0c80a9 | 33 | wifi.putc(pc.getc()); |
| stvnrhodes | 0:22803b0c80a9 | 34 | } |
| stvnrhodes | 0:22803b0c80a9 | 35 | while(wifi.readable()){ |
| stvnrhodes | 0:22803b0c80a9 | 36 | pc.putc(wifi.getc()); |
| stvnrhodes | 0:22803b0c80a9 | 37 | } |
| stvnrhodes | 0:22803b0c80a9 | 38 | if(wifi.hasCmd()){ |
| stvnrhodes | 0:22803b0c80a9 | 39 | cmd = wifi.getCmd(); |
| stvnrhodes | 0:22803b0c80a9 | 40 | switch(cmd->cmd) { |
| stvnrhodes | 0:22803b0c80a9 | 41 | case 0x00: |
| stvnrhodes | 0:22803b0c80a9 | 42 | pc.printf("Move to x: %d, y:%d, z:%d\n\r", cmd->l[0], cmd->l[1], cmd->l[2]); |
| stvnrhodes | 0:22803b0c80a9 | 43 | wait(3); |
| stvnrhodes | 0:22803b0c80a9 | 44 | wifi.send("Done"); // Make sure to always send confirmation |
| stvnrhodes | 0:22803b0c80a9 | 45 | break; |
| stvnrhodes | 0:22803b0c80a9 | 46 | default: |
| stvnrhodes | 0:22803b0c80a9 | 47 | pc.printf("You should probably do something with case %x\n\r", cmd->cmd); |
| stvnrhodes | 0:22803b0c80a9 | 48 | wifi.send("No code"); |
| stvnrhodes | 0:22803b0c80a9 | 49 | } |
| stvnrhodes | 0:22803b0c80a9 | 50 | } |
| stvnrhodes | 0:22803b0c80a9 | 51 | } |
| stvnrhodes | 0:22803b0c80a9 | 52 | } |