void SensorKeepAliveImpl::Pack() { Buffer[0] = 8; Buffer[1] = UByte(CommandId & 0xFF); Buffer[2] = UByte(CommandId >> 8); Buffer[3] = UByte(KeepAliveIntervalMs & 0xFF); Buffer[4] = UByte(KeepAliveIntervalMs >> 8); }
void SensorConfigImpl::Pack() { Buffer[0] = 2; Buffer[1] = UByte(CommandId & 0xFF); Buffer[2] = UByte(CommandId >> 8); Buffer[3] = Flags; Buffer[4] = UByte(PacketInterval); Buffer[5] = UByte(SampleRate & 0xFF); Buffer[6] = UByte(SampleRate >> 8); }
void SensorRangeImpl::Pack() { Buffer[0] = 4; Buffer[1] = UByte(CommandId & 0xFF); Buffer[2] = UByte(CommandId >> 8); Buffer[3] = UByte(AccelScale); Buffer[4] = UByte(GyroScale & 0xFF); Buffer[5] = UByte(GyroScale >> 8); Buffer[6] = UByte(MagScale & 0xFF); Buffer[7] = UByte(MagScale >> 8); }
void Pack() { Buffer[0] = 5; Buffer[1] = UByte(Configuration.SendSamples); Buffer[2] = Configuration.Threshold.R; Buffer[3] = Configuration.Threshold.G; Buffer[4] = Configuration.Threshold.B; }
//------------------------------------------------------------------------------ int genTri2(UByte pntCnt,PntDef* pntArray,UByte* orgPolyDesc,UByte*& triangleList) { int totalFans=0; UByte* pTri=triangleList; //place to store triangle fan data int pointsLeft=pntCnt; UByte* localPoly=new UByte[pointsLeft]; UByte* swapPoly=new UByte[pointsLeft]; for (int x=0;x<pointsLeft;localPoly[x]=orgPolyDesc[x],x++) {} int fanMin=2; //minimum no of triangles allowed in a fan int p0=0; int testCnt=0; abortNow=FALSE; while (pointsLeft>3 && !abortNow) { int p1=(p0+1)%pointsLeft; int p2=(p0+2)%pointsLeft; int fanCount=0; //try to make as large a fan as possible while (CheckTri(pointsLeft,localPoly,pntArray,p0,p1,p2)) { fanCount++; p1=p2; p2=(p1+1)%pointsLeft; } //Check to see if we've generated a fan properly if (fanCount>=fanMin) { globalTriCount+=fanCount; //Add this fan to the list *pTri++=UByte(fanCount); for (int x=0;x<fanCount+2;x++) *pTri++=localPoly[(p0+x)%pointsLeft]; //remove points that are no longer required UByte* tmp=swapPoly; for (x=p1;x!=p0;x=(x+1)%pointsLeft) *tmp++=localPoly[x]; *tmp++=localPoly[x]; tmp=swapPoly; swapPoly=localPoly; localPoly=tmp; p0=0; testCnt=0; fanMin=2; pointsLeft-=fanCount; totalFans++; } else { p0=(p0+1)%pointsLeft; testCnt++; //number of tests done with no fans produced if (testCnt==pointsLeft) { testCnt=0; if (fanMin==2) fanMin=1; else abortNow=TRUE; } } } if (pointsLeft==3&&!abortNow) { //add the last single triangle *pTri++=UByte(1); //fan of 1 triangle *pTri++=localPoly[0]; *pTri++=localPoly[1]; *pTri++=localPoly[2]; totalFans++; } delete[]localPoly; delete[]swapPoly; triangleList=pTri; return totalFans; }