舵機(jī)程序之?dāng)?shù)據(jù)的處理
#define BIAOZHI(x,y,z) Biaozhi=x;Biaozhip=y;Biaozhit=z
char ASC_zhuan_Valu(char asc)
{
char valu;
switch(asc)
{
case 0x30:valu=0;break; //0的ASC碼時(shí)0x30,,十進(jìn)制48
case 0x31:valu=1;break;
case 0x32:valu=2;break;
case 0x33:valu=3;break;
case 0x34:valu=4;break;
case 0x35:valu=5;break;
case 0x36:valu=6;break;
case 0x37:valu=7;break;
case 0x38:valu=8;break;
case 0x39:valu=9;break;
}
return valu;
}
void shujuchuli(char *Huancen,unsigned int *Pwm)//數(shù)據(jù)處理
{
char Biaozhi,Biaozhip,Biaozhit;
unsigned int Shuju=0,Shujup=0,Shujut=0;
while(*Huancen!=10)
{
if(Biaozhi==1&*Huancen!=80&*Huancen!=84)
{
Shuju=Shuju*10+ASC_zhuan_Valu(*Huancen);
}
if(Biaozhip==1&*Huancen!=35&*Huancen!=84)
{
Shujup=Shujup*10+ASC_zhuan_Valu(*Huancen);
}
if(Biaozhit==1&*Huancen!=80&*Huancen!=35)
{
Shujut=Shujut*10+ASC_zhuan_Valu(*Huancen);
}
if(*Huancen==35) //#
{
BIAOZHI(1,0,0);
}
if(*Huancen==80) //P
{
BIAOZHI(0,1,0);
}
if(*Huancen==84) //T
{
BIAOZHI(0,0,1);
}
Huancen++;
if(*Huancen==10)
{
if(Shujup>500)
{
*(Pwm+Shuju-1)=Shujup;//新的位置數(shù)據(jù)產(chǎn)生進(jìn)行調(diào)度
}
return;
}
}
}
評(píng)論