Prometheus
/
PixyTest
PixyTest-0.1
Fork of PixyTest by
main.cpp@1:09fdd6790d58, 2017-05-09 (annotated)
- Committer:
- ZHAW_Prometheus
- Date:
- Tue May 09 12:27:48 2017 +0000
- Revision:
- 1:09fdd6790d58
- Parent:
- 0:cb20dc12e879
PixyTest-0.2;
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 | 1:09fdd6790d58 | 12 | static int i = 0; |
ZHAW_Prometheus | 1:09fdd6790d58 | 13 | pixy.setSerialOutput(&pc); |
ZHAW_Prometheus | 0:cb20dc12e879 | 14 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 15 | while (1) { |
ZHAW_Prometheus | 0:cb20dc12e879 | 16 | //printf("while"); |
ZHAW_Prometheus | 1:09fdd6790d58 | 17 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 18 | int j; |
ZHAW_Prometheus | 0:cb20dc12e879 | 19 | uint16_t blocks; |
ZHAW_Prometheus | 0:cb20dc12e879 | 20 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 21 | blocks = pixy.getBlocks(); |
ZHAW_Prometheus | 0:cb20dc12e879 | 22 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 23 | if (blocks) { |
ZHAW_Prometheus | 0:cb20dc12e879 | 24 | i++; |
ZHAW_Prometheus | 0:cb20dc12e879 | 25 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 26 | if (i % 50 == 0) { |
ZHAW_Prometheus | 0:cb20dc12e879 | 27 | //pc.printf("Detected %d:\n\r", blocks); |
ZHAW_Prometheus | 0:cb20dc12e879 | 28 | printf("Detected %d:\n\r", blocks); |
ZHAW_Prometheus | 0:cb20dc12e879 | 29 | for (j = 0; j < blocks; j++) { |
ZHAW_Prometheus | 0:cb20dc12e879 | 30 | printf(" block %d: ", j); |
ZHAW_Prometheus | 0:cb20dc12e879 | 31 | 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 | 32 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 33 | |
ZHAW_Prometheus | 0:cb20dc12e879 | 34 | //pc.printf(" block %d: ", j); |
ZHAW_Prometheus | 0:cb20dc12e879 | 35 | //pixy.blocks[j].print(pc); |
ZHAW_Prometheus | 0:cb20dc12e879 | 36 | } |
ZHAW_Prometheus | 0:cb20dc12e879 | 37 | } |
ZHAW_Prometheus | 0:cb20dc12e879 | 38 | } |
ZHAW_Prometheus | 0:cb20dc12e879 | 39 | wait( 0.01); |
ZHAW_Prometheus | 0:cb20dc12e879 | 40 | } |
ZHAW_Prometheus | 0:cb20dc12e879 | 41 | } |