pixy

Dependencies:   mbed

Committer:
halusis
Date:
Thu Oct 25 03:57:08 2018 +0000
Revision:
0:fc7c5285fa79
for pixy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
halusis 0:fc7c5285fa79 1 #include "mbed.h"
halusis 0:fc7c5285fa79 2 #include "PixyData.h"
halusis 0:fc7c5285fa79 3 #include "GlobalVariables.h"
halusis 0:fc7c5285fa79 4 #include "PinAssign.h"
halusis 0:fc7c5285fa79 5
halusis 0:fc7c5285fa79 6 void PixyParse(void)
halusis 0:fc7c5285fa79 7 {
halusis 0:fc7c5285fa79 8 SigNum = PixyBuf[4]|(PixyBuf[5]<<8);
halusis 0:fc7c5285fa79 9 XObs = PixyBuf[6]|(PixyBuf[7]<<8);
halusis 0:fc7c5285fa79 10 YObs = PixyBuf[8]|(PixyBuf[9]<<8);
halusis 0:fc7c5285fa79 11 WidObs = PixyBuf[10]|(PixyBuf[11]<<8);
halusis 0:fc7c5285fa79 12 HeiObs = PixyBuf[12]|(PixyBuf[13]<<8);
halusis 0:fc7c5285fa79 13 AngObs = PixyBuf[14]|(PixyBuf[15]<<8);
halusis 0:fc7c5285fa79 14 }
halusis 0:fc7c5285fa79 15
halusis 0:fc7c5285fa79 16 void PixyData(void)
halusis 0:fc7c5285fa79 17 {
halusis 0:fc7c5285fa79 18 uint8_t buf;
halusis 0:fc7c5285fa79 19 buf = pixy.getc();
halusis 0:fc7c5285fa79 20 pc.putc(buf);
halusis 0:fc7c5285fa79 21
halusis 0:fc7c5285fa79 22 if(PixyCnt==0&&buf==0x56||PixyCnt==1&&buf==0xaa||PixyCnt>=2&&PixyCnt<=15)
halusis 0:fc7c5285fa79 23 {
halusis 0:fc7c5285fa79 24 PixyBuf[PixyCnt]=buf;
halusis 0:fc7c5285fa79 25 PixyCnt++;
halusis 0:fc7c5285fa79 26
halusis 0:fc7c5285fa79 27 //pc.printf("proc\n");
halusis 0:fc7c5285fa79 28 }
halusis 0:fc7c5285fa79 29 else if(PixyCnt==16)
halusis 0:fc7c5285fa79 30 {
halusis 0:fc7c5285fa79 31 //pc.printf("chks\n");
halusis 0:fc7c5285fa79 32
halusis 0:fc7c5285fa79 33 PixyChks = PixyBuf[2]|(PixyBuf[3]<<8);
halusis 0:fc7c5285fa79 34 int chks=0;
halusis 0:fc7c5285fa79 35 for(uint8_t i=4;i<=15;i++)
halusis 0:fc7c5285fa79 36 {
halusis 0:fc7c5285fa79 37 chks+=PixyBuf[i];
halusis 0:fc7c5285fa79 38 }
halusis 0:fc7c5285fa79 39 if(chks==PixyChks)
halusis 0:fc7c5285fa79 40 {
halusis 0:fc7c5285fa79 41 PixyParse();
halusis 0:fc7c5285fa79 42 //pc.printf("pars\n");
halusis 0:fc7c5285fa79 43 }
halusis 0:fc7c5285fa79 44 PixyCnt=0;
halusis 0:fc7c5285fa79 45 }
halusis 0:fc7c5285fa79 46 else PixyCnt=0;
halusis 0:fc7c5285fa79 47 }