Hello,
I am attempting to use the Pixy with a PIC24 Microchip controller in order to do some simple object position recording. I’m having a hard time because the example codes that are written require headers and such which then require more headers within those and so on.
I’ve been looking to find a basic initialization that I need to send to the pixy (if there is one at all) in order to get the block bytes 0-15. I was going to use the UART example of an Arduino to see if it would provide me the info I needed through the logic analyzer on the oscilloscope but the Arduino UART example wouldn’t load correctly. One of the include files had serial1 undefined in it.
I did see the example code in the porting guide and saw a function called getBlock:
uint16_t getBlocks(uint16_t maxBlocks)
{
uint8_t i;
uint16_t w, blockCount, checksum, sum;
Block *block;
if (!g_skipStart)
{
if (getStart()==0)
return 0;
}
else
g_skipStart = 0;
for(blockCount=0; blockCount<maxBlocks && blockCount<PIXY_ARRAYSIZE;)
{
checksum = getWord();
if (checksum==PIXY_START_WORD) // we’ve reached the beginning of the next frame
{
g_skipStart = 1;
g_blockType = NORMAL_BLOCK;
return blockCount;
}
else if (checksum==PIXY_START_WORD_CC)
{
g_skipStart = 1;
g_blockType = CC_BLOCK;
return blockCount;
}
else if (checksum==0)
return blockCount;
block = g_blocks + blockCount;
for (i=0, sum=0; i<sizeof(Block)/sizeof(uint16_t); i++)
{
if (g_blockType==NORMAL_BLOCK && i>=5) // no angle for normal block
{
block->angle = 0;
break;
}
w = getWord();
sum += w;
*((uint16_t *)block + i) = w;
}
// check checksum
if (checksum==sum)
blockCount++;
else
printf("checksum error!\n");
w = getWord();
if (w==PIXY_START_WORD)
g_blockType = NORMAL_BLOCK;
else if (w==PIXY_START_WORD_CC)
g_blockType = CC_BLOCK;
else
return blockCount;
}
}
Unfortunately coding is not my strongest suit and so I haven’t quite determined what exactly is going on in this function. Does anyone know if this is what I need to be translating into my IDE in order to get the blocks for the recognized object?