abc
Dependencies: mbed pixy pixy_test
Fork of pixy_test by
main.cpp@0:6618ecb9567e, 2015-11-18 (annotated)
- Committer:
- jfields
- Date:
- Wed Nov 18 21:03:06 2015 +0000
- Revision:
- 0:6618ecb9567e
- Child:
- 1:5302a23c97c4
mbed pixy code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jfields | 0:6618ecb9567e | 1 | #include "mbed.h" |
jfields | 0:6618ecb9567e | 2 | #include "Pixy.h" |
jfields | 0:6618ecb9567e | 3 | |
jfields | 0:6618ecb9567e | 4 | Pixy pixy(Pixy::SPI, p11, p12, p13); |
jfields | 0:6618ecb9567e | 5 | Serial pc(USBTX, USBRX); |
jfields | 0:6618ecb9567e | 6 | |
jfields | 0:6618ecb9567e | 7 | int main() { |
jfields | 0:6618ecb9567e | 8 | pc.printf("ready\n\r"); |
jfields | 0:6618ecb9567e | 9 | pixy.setSerialOutput(&pc); |
jfields | 0:6618ecb9567e | 10 | while (1) { |
jfields | 0:6618ecb9567e | 11 | static int i = 0; |
jfields | 0:6618ecb9567e | 12 | int j; |
jfields | 0:6618ecb9567e | 13 | uint16_t blocks; |
jfields | 0:6618ecb9567e | 14 | |
jfields | 0:6618ecb9567e | 15 | blocks = pixy.getBlocks(); |
jfields | 0:6618ecb9567e | 16 | |
jfields | 0:6618ecb9567e | 17 | if (blocks) { |
jfields | 0:6618ecb9567e | 18 | i++; |
jfields | 0:6618ecb9567e | 19 | |
jfields | 0:6618ecb9567e | 20 | if (i % 50 == 0) { |
jfields | 0:6618ecb9567e | 21 | pc.printf("Detected %d:\n\r", blocks); |
jfields | 0:6618ecb9567e | 22 | for (j = 0; j < blocks; j++) { |
jfields | 0:6618ecb9567e | 23 | pc.printf(" block %d: ", j); |
jfields | 0:6618ecb9567e | 24 | pixy.blocks[j].print(pc); |
jfields | 0:6618ecb9567e | 25 | } |
jfields | 0:6618ecb9567e | 26 | } |
jfields | 0:6618ecb9567e | 27 | } |
jfields | 0:6618ecb9567e | 28 | } |
jfields | 0:6618ecb9567e | 29 | } |