Program utama test puxt cmucam5 di stm32f446re
Fork of PIXY_KRPAI_ITB by
main.cpp@3:070376242d2d, 2017-10-29 (annotated)
- Committer:
- achmad_fathoni
- Date:
- Sun Oct 29 07:06:42 2017 +0000
- Revision:
- 3:070376242d2d
- Parent:
- 1:97221820a967
Buat Johan
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 | |
achmad_fathoni | 3:070376242d2d | 4 | Pixy pixy(Pixy::SPI, PB_5, PB_4, PB_3); |
acracan | 0:63532ae95efe | 5 | Serial pc(USBTX, USBRX); |
acracan | 0:63532ae95efe | 6 | |
acracan | 0:63532ae95efe | 7 | int main() { |
achmad_fathoni | 3:070376242d2d | 8 | pixy.setSerialOutput(&pc); |
CheeseW | 1:97221820a967 | 9 | pc.printf("Hello World!\n\r"); |
acracan | 0:63532ae95efe | 10 | while (1) { |
achmad_fathoni | 3:070376242d2d | 11 | wait(0.5); |
acracan | 0:63532ae95efe | 12 | static int i = 0; |
acracan | 0:63532ae95efe | 13 | int j; |
acracan | 0:63532ae95efe | 14 | uint16_t blocks; |
acracan | 0:63532ae95efe | 15 | |
achmad_fathoni | 3:070376242d2d | 16 | blocks = pixy.getBlocks(); |
acracan | 0:63532ae95efe | 17 | |
acracan | 0:63532ae95efe | 18 | if (blocks) { |
acracan | 0:63532ae95efe | 19 | i++; |
achmad_fathoni | 3:070376242d2d | 20 | |
achmad_fathoni | 3:070376242d2d | 21 | pc.printf("Detected %d:\n\r", blocks); |
achmad_fathoni | 3:070376242d2d | 22 | pc.printf("\n\r"); |
acracan | 0:63532ae95efe | 23 | for (j = 0; j < blocks; j++) { |
achmad_fathoni | 3:070376242d2d | 24 | pc.printf(" block %d: \n\r", j); |
achmad_fathoni | 3:070376242d2d | 25 | //pixy.blocks[j].print(pc); |
achmad_fathoni | 3:070376242d2d | 26 | pc.printf("%d cm\n\r",pixy.blocks[j].width/6); |
acracan | 0:63532ae95efe | 27 | } |
CheeseW | 1:97221820a967 | 28 | |
acracan | 0:63532ae95efe | 29 | } |
acracan | 0:63532ae95efe | 30 | } |
acracan | 0:63532ae95efe | 31 | } |