Prometheus / Mbed 2 deprecated PixyTest2

Dependencies:   mbed

Committer:
ZHAW_Prometheus
Date:
Wed May 17 13:08:18 2017 +0000
Revision:
0:4a23b84b733e
PixyTest2 Vers. 17.05.2017

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ZHAW_Prometheus 0:4a23b84b733e 1 #include "mbed.h"
ZHAW_Prometheus 0:4a23b84b733e 2 #include "Pixy.h"
ZHAW_Prometheus 0:4a23b84b733e 3 #include "cstdlib"
ZHAW_Prometheus 0:4a23b84b733e 4
ZHAW_Prometheus 0:4a23b84b733e 5 Pixy pixy(Pixy::UART, PC_5, PB_10);
ZHAW_Prometheus 0:4a23b84b733e 6 Serial pc(SERIAL_TX, SERIAL_RX);
ZHAW_Prometheus 0:4a23b84b733e 7
ZHAW_Prometheus 0:4a23b84b733e 8 int main() {
ZHAW_Prometheus 0:4a23b84b733e 9 wait(3);
ZHAW_Prometheus 0:4a23b84b733e 10 //pc.printf("ready\n\r");
ZHAW_Prometheus 0:4a23b84b733e 11 printf("ready\n\r");
ZHAW_Prometheus 0:4a23b84b733e 12
ZHAW_Prometheus 0:4a23b84b733e 13 pixy.setSerialOutput(&pc);
ZHAW_Prometheus 0:4a23b84b733e 14 while (1) {
ZHAW_Prometheus 0:4a23b84b733e 15 //printf("while");
ZHAW_Prometheus 0:4a23b84b733e 16 static int i = 0;
ZHAW_Prometheus 0:4a23b84b733e 17 int j;
ZHAW_Prometheus 0:4a23b84b733e 18 uint16_t blocks;
ZHAW_Prometheus 0:4a23b84b733e 19
ZHAW_Prometheus 0:4a23b84b733e 20 blocks = pixy.getBlocks();
ZHAW_Prometheus 0:4a23b84b733e 21
ZHAW_Prometheus 0:4a23b84b733e 22 if (blocks) {
ZHAW_Prometheus 0:4a23b84b733e 23 i++;
ZHAW_Prometheus 0:4a23b84b733e 24
ZHAW_Prometheus 0:4a23b84b733e 25 if (i % 50 == 0) {
ZHAW_Prometheus 0:4a23b84b733e 26 //pc.printf("Detected %d:\n\r", blocks);
ZHAW_Prometheus 0:4a23b84b733e 27 printf("Detected %d:\n\r", blocks);
ZHAW_Prometheus 0:4a23b84b733e 28 for (j = 0; j < blocks; j++) {
ZHAW_Prometheus 0:4a23b84b733e 29 printf(" block %d: ", j);
ZHAW_Prometheus 0:4a23b84b733e 30 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:4a23b84b733e 31
ZHAW_Prometheus 0:4a23b84b733e 32
ZHAW_Prometheus 0:4a23b84b733e 33 //pc.printf(" block %d: ", j);
ZHAW_Prometheus 0:4a23b84b733e 34 //pixy.blocks[j].print(pc);
ZHAW_Prometheus 0:4a23b84b733e 35 }
ZHAW_Prometheus 0:4a23b84b733e 36 }
ZHAW_Prometheus 0:4a23b84b733e 37 }
ZHAW_Prometheus 0:4a23b84b733e 38 wait( 0.01);
ZHAW_Prometheus 0:4a23b84b733e 39 }
ZHAW_Prometheus 0:4a23b84b733e 40 }