SPI read Pixi Cam V1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "pixyUART.h"
00003 //SPI spi(PC_12, PC_11, PC_10);
00004 BufferedSerial uart(PA_9,PA_10,115200);
00005 pixyUART pixy(&uart);
00006 uint8_t buffer[200];
00007 static BufferedSerial serial_port(USBTX, USBRX,115200);
00008 int main(void)
00009     {
00010         printf("Start\r\n");
00011         uart.set_blocking(false);
00012         uart.set_format(
00013         /* bits */ 8,
00014         /* parity */ BufferedSerial::None,
00015         /* stop bit */ 1);
00016         Timer ti;
00017         ti.reset();
00018         ti.start();
00019         uint8_t kk=0;
00020         while(1)
00021             {
00022             ThisThread::sleep_for(20);
00023             pixy.capture();
00024             if(ti.read() > .25 && pixy.captured_blocks>0)
00025                 {
00026                 ti.reset();
00027                 printf("captBl: %d\r\n",pixy.captured_blocks);
00028                 for(int k=0;k<pixy.captured_blocks;k++)
00029                     {   
00030                     printf("sig: %d x: %d y: %d \r\n",pixy.blocks[k].signature,pixy.blocks[k].x,pixy.blocks[k].y);
00031                     }
00032                 printf("\r\n- - - - - - - - - \r\n");
00033                 }
00034             }
00035         //pixy.blocks[0].printBlock();
00036     }