我好不容易找出来一个。
int SignalProcess( unsigned int signal )
{
const int BitValue[8] = {43,26,12,6,-6,-12,-26,-43}; //MAX:28
int i,CurrPoint=0,LastPoint=0,BitNum=0;
unsigned char SignalBit[8];
for(i=0;i<8;i++)
{
SignalBit[i] = signal & 0x0001;
BitNum += SignalBit[i];
signal >>= 1;
}
switch(BitNum)
{
case 1:
for(i=0;i<8;i++)
if(SignalBit[i] != 0)
CurrPoint += BitValue[i];
CarState.E0 = CurrPoint;
break;
case 2:
for(i=0;i<8;i++)
if(SignalBit[i] != 0)
CurrPoint += BitValue[i];
CurrPoint >>= 1;
CarState.E0 = CurrPoint;
break;
default:
CarState.E0 = CarState.E1;
break;
}
return CalculateP()*100;
}
晕~飞思卡尔智能车比赛都没开始,谁会乐意告诉你啊?