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@0:cb20dc12e879, 2017-05-05 (annotated)
- Committer:
- ZHAW_Prometheus
- Date:
- Fri May 05 12:06:06 2017 +0000
- Revision:
- 0:cb20dc12e879
Vers-0.1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ZHAW_Prometheus | 0:cb20dc12e879 | 1 | #include "mbed.h" |
| ZHAW_Prometheus | 0:cb20dc12e879 | 2 | #include "Pixy.h" |
| ZHAW_Prometheus | 0:cb20dc12e879 | 3 | #include "cstdlib" |
| ZHAW_Prometheus | 0:cb20dc12e879 | 4 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 5 | Pixy pixy(Pixy::I2C, PB_9, PB_8); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 6 | Serial pc(USBTX, USBRX); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 7 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 8 | int main() { |
| ZHAW_Prometheus | 0:cb20dc12e879 | 9 | wait(3); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 10 | //pc.printf("ready\n\r"); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 11 | printf("ready\n\r"); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 12 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 13 | pixy.setSerialOutput(&pc); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 14 | while (1) { |
| ZHAW_Prometheus | 0:cb20dc12e879 | 15 | //printf("while"); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 16 | static int i = 0; |
| ZHAW_Prometheus | 0:cb20dc12e879 | 17 | int j; |
| ZHAW_Prometheus | 0:cb20dc12e879 | 18 | uint16_t blocks; |
| ZHAW_Prometheus | 0:cb20dc12e879 | 19 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 20 | blocks = pixy.getBlocks(); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 21 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 22 | if (blocks) { |
| ZHAW_Prometheus | 0:cb20dc12e879 | 23 | i++; |
| ZHAW_Prometheus | 0:cb20dc12e879 | 24 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 25 | if (i % 50 == 0) { |
| ZHAW_Prometheus | 0:cb20dc12e879 | 26 | //pc.printf("Detected %d:\n\r", blocks); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 27 | printf("Detected %d:\n\r", blocks); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 28 | for (j = 0; j < blocks; j++) { |
| ZHAW_Prometheus | 0:cb20dc12e879 | 29 | printf(" block %d: ", j); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 30 | printf("sig: %d x: %d y: %d width: %d height: %d\n", pixy.blocks[j].signature, pixy.blocks[j].x, pixy.blocks[j].y, pixy.blocks[j].width, pixy.blocks[j].height); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 31 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 32 | |
| ZHAW_Prometheus | 0:cb20dc12e879 | 33 | //pc.printf(" block %d: ", j); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 34 | //pixy.blocks[j].print(pc); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 35 | } |
| ZHAW_Prometheus | 0:cb20dc12e879 | 36 | } |
| ZHAW_Prometheus | 0:cb20dc12e879 | 37 | } |
| ZHAW_Prometheus | 0:cb20dc12e879 | 38 | wait( 0.01); |
| ZHAW_Prometheus | 0:cb20dc12e879 | 39 | } |
| ZHAW_Prometheus | 0:cb20dc12e879 | 40 | } |