Minor modification to the original library to fit into our project
Fork of pixy by
Diff: Pixy.cpp
- Revision:
- 1:910d941e3cc2
- Parent:
- 0:ed8dc4531ac1
--- a/Pixy.cpp Sun Nov 16 11:52:55 2014 +0000 +++ b/Pixy.cpp Thu Mar 12 08:15:07 2015 +0000 @@ -30,14 +30,17 @@ { uint8_t i; uint16_t w, checksum, sum; - Block *block; + //Block *block; if (!skipStart) { if (getStart() == false) return 0; } else skipStart = false; - + for (int i = 0; i < PIXY_INITIAL_ARRAYSIZE; i++) + { + blocks[i].width = 0; + } for (blockCount = 0; blockCount < maxBlocks && blockCount < PIXY_MAXIMUM_ARRAYSIZE;) { checksum = m_link->getWord(); if (checksum == PIXY_START_WORD) { // we've reached the beginning of the next frame @@ -48,19 +51,26 @@ } else if (checksum == 0) return blockCount; - if (blockCount > blockArraySize) - resize(); - - block = blocks + blockCount; - - for (i = 0, sum = 0; i < sizeof(Block) / sizeof(uint16_t); i++) { - w = m_link->getWord(); - sum += w; - *((uint16_t *)block + i) = w; - } + //if (blockCount > blockArraySize) + //resize(); + + //block = blocks + blockCount; + uint16_t signature = m_link->getWord(); + uint16_t x = m_link->getWord(); + uint16_t y = m_link->getWord(); + uint16_t width = m_link->getWord(); + uint16_t height = m_link->getWord(); + + sum = signature + x +y + width + height; if (checksum == sum) + { + blocks[signature-1].x = x; + blocks[signature-1].y = y; + blocks[signature-1].width = width; + blocks[signature-1].height = height; blockCount++; + } else if (pc) pc->printf("cs error\n\r");