Minor modification to the original library to fit into our project
Fork of pixy by
Revision 1:910d941e3cc2, committed 2015-03-12
- Comitter:
- CheeseW
- Date:
- Thu Mar 12 08:15:07 2015 +0000
- Parent:
- 0:ed8dc4531ac1
- Commit message:
- Minor modification to the original code
Changed in this revision
Pixy.cpp | Show annotated file Show diff for this revision Revisions of this file |
Pixy.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ed8dc4531ac1 -r 910d941e3cc2 Pixy.cpp --- 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");
diff -r ed8dc4531ac1 -r 910d941e3cc2 Pixy.h --- a/Pixy.h Sun Nov 16 11:52:55 2014 +0000 +++ b/Pixy.h Thu Mar 12 08:15:07 2015 +0000 @@ -8,9 +8,10 @@ struct Block { void print(Serial &pc) { - pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height); + //pc.printf("sig: %d x: %d y: %d width: %d height: %d\n", signature, x, y, width, height); + pc.printf(" x: %d y: %d width: %d height: %d\n", x, y, width, height); }; - uint16_t signature; + //uint16_t signature; uint16_t x; uint16_t y; uint16_t width; @@ -31,7 +32,7 @@ Block *blocks; private: - static const uint8_t PIXY_INITIAL_ARRAYSIZE = 30; + static const uint8_t PIXY_INITIAL_ARRAYSIZE = 7; static const uint8_t PIXY_MAXIMUM_ARRAYSIZE = 130; static const uint16_t PIXY_START_WORD = 0xaa55; static const uint16_t PIXY_START_WORDX = 0x55aa;