![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
for senior design
Fork of pixyHelloWorld by
main.cpp@2:85d539948111, 2015-04-19 (annotated)
- Committer:
- CheeseW
- Date:
- Sun Apr 19 04:31:51 2015 +0000
- Revision:
- 2:85d539948111
- Parent:
- 1:97221820a967
published
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
acracan | 0:63532ae95efe | 1 | #include "mbed.h" |
acracan | 0:63532ae95efe | 2 | #include "Pixy.h" |
acracan | 0:63532ae95efe | 3 | |
CheeseW | 1:97221820a967 | 4 | Pixy pixyL(Pixy::SPI, p11, p12, p13); |
CheeseW | 1:97221820a967 | 5 | Pixy pixyR(Pixy::SPI, p5, p6, p7); |
acracan | 0:63532ae95efe | 6 | Serial pc(USBTX, USBRX); |
acracan | 0:63532ae95efe | 7 | |
CheeseW | 1:97221820a967 | 8 | |
acracan | 0:63532ae95efe | 9 | int main() { |
CheeseW | 1:97221820a967 | 10 | pc.baud(115200); |
CheeseW | 1:97221820a967 | 11 | pixyL.setSerialOutput(&pc); |
CheeseW | 1:97221820a967 | 12 | pixyR.setSerialOutput(&pc); |
CheeseW | 1:97221820a967 | 13 | pc.printf("Hello World!\n\r"); |
acracan | 0:63532ae95efe | 14 | while (1) { |
acracan | 0:63532ae95efe | 15 | static int i = 0; |
acracan | 0:63532ae95efe | 16 | int j; |
acracan | 0:63532ae95efe | 17 | uint16_t blocks; |
acracan | 0:63532ae95efe | 18 | |
CheeseW | 1:97221820a967 | 19 | blocks = pixyL.getBlocks(); |
acracan | 0:63532ae95efe | 20 | |
acracan | 0:63532ae95efe | 21 | if (blocks) { |
acracan | 0:63532ae95efe | 22 | i++; |
acracan | 0:63532ae95efe | 23 | |
CheeseW | 1:97221820a967 | 24 | //pc.printf("Detected %d:\n\r", blocks); |
CheeseW | 1:97221820a967 | 25 | //pc.printf("\n\r"); |
acracan | 0:63532ae95efe | 26 | for (j = 0; j < blocks; j++) { |
CheeseW | 1:97221820a967 | 27 | // pc.printf(" block %d: \n\r", j); |
CheeseW | 1:97221820a967 | 28 | pixyL.blocks[j].print(pc); |
acracan | 0:63532ae95efe | 29 | } |
CheeseW | 1:97221820a967 | 30 | |
acracan | 0:63532ae95efe | 31 | } |
CheeseW | 1:97221820a967 | 32 | |
CheeseW | 1:97221820a967 | 33 | blocks = pixyR.getBlocks(); |
CheeseW | 1:97221820a967 | 34 | |
CheeseW | 1:97221820a967 | 35 | if (blocks) { |
CheeseW | 1:97221820a967 | 36 | i++; |
CheeseW | 1:97221820a967 | 37 | |
CheeseW | 1:97221820a967 | 38 | //pc.printf("Detected %d:\n\r", blocks); |
CheeseW | 1:97221820a967 | 39 | //pc.printf("\n\r"); |
CheeseW | 1:97221820a967 | 40 | for (j = 0; j < blocks; j++) { |
CheeseW | 1:97221820a967 | 41 | // pc.printf(" block %d: \n\r", j); |
CheeseW | 1:97221820a967 | 42 | pixyR.blocks[j].print(pc); |
CheeseW | 1:97221820a967 | 43 | } |
CheeseW | 1:97221820a967 | 44 | |
CheeseW | 1:97221820a967 | 45 | } |
CheeseW | 1:97221820a967 | 46 | pc.printf("\n\r"); |
acracan | 0:63532ae95efe | 47 | } |
acracan | 0:63532ae95efe | 48 | } |